@arcgis/core 4.27.0-next.20230321 → 4.27.0-next.20230322

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 (136) hide show
  1. package/analysis/LineOfSightAnalysisObserver.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/02b6227c156ee0d8eb66.js +1 -0
  4. package/assets/esri/core/workers/chunks/{7e0c65aa61c2ff0c3504.js → 1c98b92933a48cf96c1e.js} +1 -1
  5. package/assets/esri/core/workers/chunks/321f272d4c7ed6b0cb46.js +1 -0
  6. package/assets/esri/core/workers/chunks/47bd558e2ce89f47f908.js +1 -0
  7. package/assets/esri/core/workers/chunks/76d6c1fc25f02bcf258e.js +1 -0
  8. package/assets/esri/core/workers/chunks/{c5d872adce711ec61ede.js → 8980c5dc389c27368b73.js} +1 -1
  9. package/assets/esri/core/workers/chunks/8d0143c0ff009b98a31f.js +1 -0
  10. package/assets/esri/core/workers/chunks/{6acaf28cba5d49a98fb6.js → 91b292f310f06a0cbf72.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{ff9efa829497557ec26a.js → aa4640a0207e0be224e2.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{92951b85676df776961f.js → ab8139e3a875a8b8dab9.js} +23 -25
  13. package/assets/esri/core/workers/chunks/{c8cd3fde6d8d43ddb954.js → b6cdf4daf07d9e55f61e.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{6b14673a4afd6ef81487.js → c76cabd2d2510a653dff.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{4be7647605300e07e843.js → c90fff7e28ba5b443b11.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{e637e47000f4dc48054d.js → cc7f4fd20443a2acf0f1.js} +1 -1
  17. package/assets/esri/core/workers/chunks/d19e9fab4f4fb765c6a3.js +1 -0
  18. package/assets/esri/core/workers/chunks/d9ef4891c8b0bdd90f5b.js +1 -0
  19. package/assets/esri/core/workers/chunks/{d92d6a43270fb0d366b4.js → de4f5c48efbcee82c3c1.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{32f9b488915a4a8864e5.js → f8b9e0c1671e55b61904.js} +1 -1
  21. package/assets/esri/views/3d/analysis/Slice/images/heading-rotate.ts.svg +7 -28
  22. package/assets/esri/views/3d/analysis/Slice/images/tilt-rotate.ts.svg +11 -0
  23. package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
  24. package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
  25. package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
  26. package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
  27. package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
  28. package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
  29. package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
  30. package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
  31. package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
  32. package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
  33. package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
  34. package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
  35. package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
  36. package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
  37. package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
  38. package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
  39. package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
  40. package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
  41. package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
  42. package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
  43. package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
  44. package/assets/esri/widgets/Editor/t9n/Editor_nb.json +1 -1
  45. package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
  46. package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
  47. package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
  48. package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
  49. package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
  50. package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
  51. package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
  52. package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
  53. package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
  54. package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
  55. package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
  56. package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
  57. package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
  58. package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
  59. package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
  60. package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
  61. package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
  62. package/chunks/ComponentShader.glsl.js +1 -1
  63. package/chunks/DefaultMaterial.glsl.js +4 -4
  64. package/chunks/vec42.js +1 -1
  65. package/core/Loadable.js +1 -1
  66. package/core/accessorSupport/Property.js +1 -1
  67. package/core/accessorSupport/tracking/SimpleTrackingTarget.js +1 -1
  68. package/geometry/support/buffer/math/vec4.js +1 -1
  69. package/interfaces.d.ts +1 -1
  70. package/layers/LineOfSightLayer.js +1 -1
  71. package/layers/SceneLayer.js +1 -1
  72. package/layers/mixins/ImageryTileMixin.js +1 -1
  73. package/layers/mixins/RefreshableLayer.js +1 -1
  74. package/layers/support/rasterFunctions/clipUtils.js +1 -1
  75. package/layers/support/rasterFunctions/stretchUtils.js +1 -1
  76. package/package.json +1 -1
  77. package/support/revision.js +1 -1
  78. package/views/2d/engine/vectorTiles/TileHandler.js +1 -1
  79. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  80. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  81. package/views/3d/analysis/Slice/images/Factory.js +1 -1
  82. package/views/3d/analysis/Slice/images/generateTextures.js +1 -1
  83. package/views/3d/analysis/Slice/images/heading-rotate-svg.js +1 -1
  84. package/views/3d/analysis/Slice/images/tilt-rotate-svg.js +5 -0
  85. package/views/3d/analysis/Slice/settings.js +5 -0
  86. package/views/3d/environment/Stars.js +1 -1
  87. package/views/3d/interactive/Manipulator3D.js +1 -1
  88. package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
  89. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  90. package/views/3d/layers/PointCloudWorker.js +1 -1
  91. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  92. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  93. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  94. package/views/3d/layers/i3s/PointCloudRendererUtil.js +1 -1
  95. package/views/3d/layers/i3s/PointCloudWorkerUtil.js +1 -1
  96. package/views/3d/layers/i3s/PointGraphic.js +1 -1
  97. package/views/3d/state/ViewState.js +1 -1
  98. package/views/3d/state/controllers/SurfaceCollisionCorrectionController.js +1 -1
  99. package/views/3d/terrain/GeometryState.js +1 -1
  100. package/views/3d/terrain/PatchGeometry.js +1 -1
  101. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  102. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  103. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  104. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  105. package/views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js +6 -5
  106. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js +1 -1
  107. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +11 -11
  108. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeShadingNormal.glsl.js +1 -1
  109. package/views/3d/webgl-engine/lib/AnimationTimeStep.js +1 -1
  110. package/views/3d/webgl-engine/lib/AttributeArray.js +1 -1
  111. package/views/3d/webgl-engine/lib/DefaultVertexAttributeLocations.js +1 -1
  112. package/views/3d/webgl-engine/lib/Normals.js +5 -0
  113. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  114. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  115. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  116. package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
  117. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  118. package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
  119. package/views/3d/webgl-engine/shaders/RealisticTreeTechnique.js +1 -1
  120. package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
  121. package/views/LayerViewManager.js +1 -1
  122. package/views/SceneView.js +1 -1
  123. package/views/layers/SceneLayerView.js +1 -1
  124. package/views/webgl/ShaderTranspiler.js +1 -1
  125. package/widgets/Expand.js +1 -1
  126. package/assets/esri/core/workers/chunks/0487ab23a20ec356ab4c.js +0 -1
  127. package/assets/esri/core/workers/chunks/29ee4f14602caf6967e4.js +0 -1
  128. package/assets/esri/core/workers/chunks/2c0775541cfec9d43acb.js +0 -1
  129. package/assets/esri/core/workers/chunks/4879164b48da9ad4547a.js +0 -1
  130. package/assets/esri/core/workers/chunks/69060e5cffc19e76062a.js +0 -1
  131. package/assets/esri/core/workers/chunks/a71a5c8a9aa302bf6f01.js +0 -1
  132. package/assets/esri/core/workers/chunks/bc002e4dff8859571a7a.js +0 -1
  133. package/assets/esri/views/3d/analysis/Slice/images/tilt-rotate.svg +0 -80
  134. package/assets/esri/views/3d/analysis/Slice/images/tilt-rotate.ts.png +0 -0
  135. package/views/3d/analysis/Slice/images/tilt-rotate-png.js +0 -5
  136. package/views/3d/webgl-engine/core/shaderLibrary/util/DecodeNormal.glsl.js +0 -8
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../Color.js";import"../../../../geometry.js";import{LengthDimensionMeasureType as i}from"../../../../analysis/dimensionUtils.js";import n from"../../../../analysis/LengthDimension.js";import{HandleOwner as a}from"../../../../core/HandleOwner.js";import o from"../../../../core/Handles.js";import{equals as s}from"../../../../core/lang.js";import{destroyMaybe as r,applySome as p}from"../../../../core/maybe.js";import{memoize as l}from"../../../../core/memoize.js";import{ignoreAbortErrors as u}from"../../../../core/promiseUtils.js";import{watch as d,sync as c,syncAndInitial as m,initial as h,when as g}from"../../../../core/reactiveUtils.js";import{property as f}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../../../core/accessorSupport/decorators/subclass.js";import{c as M}from"../../../../chunks/vec3f64.js";import{clonePoint as y}from"../../../../layers/graphics/hydratedFeatures.js";import{reapplyConstraint as v,LengthDimensionConstraint as C,applyConstraint as S,computeConstraint as b,constraintDependencies as w}from"./lengthDimensionConstraintUtils.js";import{LengthDimensionManipulators as P,createPointManipulator as O,pointManipulatorHandles as D,createOffsetManipulator as j,offsetManipulatorHandles as H,createOrientationManipulator as T,headingManipulatorHandles as G,rotationManipulatorHandles as I,createMeasureTypeManipulator as z,measureTypeManipulatorHandles as x,updateOffsetManipulatorTransform as V,updateHeadingManipulatorTransform as U,updateRotationManipulatorTransform as R,updateMeasureTypeManipulatorTransform as A,unfocusedOffsetWidth as k,focusedOffsetWidth as E,updateOrientationManipulator as F}from"./lengthDimensionManipulatorUtils.js";import{isValidComputation as L,arePointsVerticallyAligned as q,computeGeometryFromDimension as B,computationToGeometryDependencies as N}from"./lengthDimensionUtils.js";import{settings as J}from"./settings.js";import{getRotateHeadingTexture as K}from"../Slice/images/Factory.js";import{SnappingVisualizer3D as Q}from"../../interactive/SnappingVisualizer3D.js";import{LineVisualElement as W}from"../../interactive/visualElements/LineVisualElement.js";import{VerticesVisualElement as X}from"../../interactive/visualElements/VerticesVisualElement.js";import{RenderOccludedFlag as Y}from"../../webgl-engine/lib/Material.js";import{ImageMaterial as Z}from"../../webgl-engine/materials/ImageMaterial.js";import{createStipplePatternSimple as $}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as tt}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{createCoordinateHelper as et}from"../../../interactive/coordinateHelper.js";import{EditGeometry as it}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as nt}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{acquire as at}from"../../../interactive/snapping/SceneSnappingManagerPool.js";import{SnappingContext as ot}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as st}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as rt}from"../../../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as pt}from"../../../interactive/snapping/snappingUtils.js";import lt from"../../../../geometry/Point.js";let ut=class extends a{constructor(t){super(t),this._stagedDimension=null,this._computationManipulators=new Map,this._computationHandles=new o,this._getSnappingContext=l((t=>new ot({elevationInfo:{mode:"absolute-height",offset:0},pointer:t,editGeometryOperations:new nt(new it("point",et(!0,!1,this.view.spatialReference))),visualizer:new Q}))),this._snappingManagerResult=at(t.view),this.addHandles(this._snappingManagerResult),this._unfocusedOffsetManipulatorMaterial=dt(),this._focusedOffsetManipulatorMaterial=dt(),this._thinOffsetManipulatorMaterial=dt(),this._thinOffsetManipulatorMaterial.setParameters({stipplePattern:$(2)}),this._constraintSnappingIndicator=new W({view:t.view,attached:!0,width:1,color:e.toUnitRGBA(J.constraint.color),renderOccluded:Y.OccludeAndTransparent,stipplePattern:$(5)});const i=e.toUnitRGBA(J.disabledPointIndicator.color);i[3]*=J.disabledPointIndicator.opacity,this._stagedStartIndicator=new X({view:t.view,attached:!1,color:i,size:2*J.disabledPointIndicator.radius,elevationInfo:{mode:"absolute-height",offset:0},spatialReference:t.view.renderCoordsHelper.spatialReference,outlineSize:0,renderOccluded:Y.OccludeAndTransparent})}initialize(){this._snappingOperation=new rt({view:this.view});const{color:t,contrastColor:e}=J.orientationManipulator,i=!this.view._stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this._orientationManipulatorTexture=K(this.view.toolViewManager.textures,{accentColor:t,contrastColor:e,premultiplyAlpha:i}),this._orientationManipulatorMaterial=new Z({transparent:!0,writeDepth:!1,textureId:this._orientationManipulatorTexture.texture.id,renderOccluded:Y.Opaque});const{computations:n}=this.analysisViewData;for(const a of n)this._addComputation(a);this.addHandles([n.on("after-add",(t=>this._addComputation(t.item))),n.on("after-remove",(t=>this._removeComputation(t.item)))]),this.addHandles([d((()=>({stagedPoint:this._snappingOperation.stagedPoint,stagedComputation:this._stagedComputation})),(({stagedPoint:t,stagedComputation:e})=>{if(null==e||null==t)return;const i=y(t,new lt);this._applyPointUpdate(e,{endPoint:i})}),c),d((()=>({stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator})),((t,e)=>{const{stagedDimension:i,selectedComputation:n,firstGrabbedManipulator:a}=t;if(i===e?.stagedDimension&&a===e?.firstGrabbedManipulator){for(const o of[n,e?.selectedComputation])if(null!=o){const e=this._computationManipulators.get(o);this._updateManipulators(o,e,t)}}else for(const[o,s]of this._computationManipulators)this._updateManipulators(o,s,t)}),m),d((()=>this.analysis.style.lineSize),(t=>{this._updateManipulatorStyle(t)}),h),d((()=>this.view.state.camera),(()=>{null!=this._stagedComputation&&this._updateStagedDimensionOffset(this._stagedComputation)})),d((()=>p(this._stagedComputation,(t=>{const e=t.elevationAlignedStartPoint,i=M();return null!=e&&this.view.renderCoordsHelper.toRenderCoords(e,i)?i:null}))),(t=>{null!=t?(this._stagedStartIndicator.vertices=[t],this._stagedStartIndicator.attached=!0):this._stagedStartIndicator.attached=!1}))]),this.addHandles(this._constraintHandles),this.addHandles(this._snappingIndicatorHandles),pt(this,(()=>{const t=this._activeComputation,e=this._stagedComputation;if(null==t||null!=e){const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);this.updatingHandles.addPromise(u(this._snappingOperation.resnap(this._snappingManager,e)))}if(null!=t){const{start:e,end:i}=this._computationManipulators.get(t);if(e.grabbing||i.grabbing){const i=e.grabbing?"start":"end",n=this._computeConstraint(t);v(t,i,{constraint:n,view:this.view})}}}))}destroy(){this._snappingOperation=r(this._snappingOperation),this._computationHandles.destroy(),this._constraintSnappingIndicator.destroy(),this._stagedStartIndicator.destroy(),this._orientationManipulatorMaterial.dispose(),this._orientationManipulatorTexture.release()}get updating(){return this.updatingHandles.updating||this._snappingManager.updating}get firstGrabbedManipulator(){return this.parentTool.firstGrabbedManipulator}get hasGrabbedManipulators(){return this.parentTool.hasGrabbedManipulators}get snappingOptions(){return this._snappingManager.options}get _snappingManager(){return this._snappingManagerResult.snappingManager}get _activeComputation(){if(null!=this._stagedComputation)return this._stagedComputation;const{selectedComputation:t}=this.analysisViewData;return this.hasGrabbedManipulators&&null!=t?t:null}get _stagedComputation(){const t=this._stagedDimension,e=this.analysisViewData.computations.at(-1);return null==t||null==e||e.dimension!==t?null:e}get _constraintHandles(){return[g((()=>this.analysisViewData.selectedComputation),(t=>{t.previousConstraint=this._computeConstraint(t)}),{...m,equals:s}),d((()=>{const t=this._activeComputation;if(null==t)return null;const{measureType:e,orientation:i}=t.dimension;return{measureType:e,orientation:i,computation:t}}),((t,e)=>{if(null!=t&&null==e){const{measureType:e,orientation:n,computation:a}=t;switch(a.previousConstraint){case C.Horizontal:a.preConstraintProperties={measureType:i.Horizontal,orientation:0};break;case C.Vertical:a.preConstraintProperties={measureType:i.Vertical,orientation:0};break;case C.Direct:a.preConstraintProperties={measureType:i.Direct,orientation:n};break;default:a.preConstraintProperties={measureType:e,orientation:n}}}null==t&&null!=e&&(e.computation.preConstraintProperties=null)}),c)]}get _snappingIndicatorHandles(){const t="snapping-indicator-event-handles";return[d((()=>({stagedComputation:this._stagedComputation,activeComputation:this._activeComputation})),(({stagedComputation:e,activeComputation:i})=>{const n=this._constraintSnappingIndicator;if(this.removeHandles(t),null!=i)if(i===e)n.attached=!0;else{const{start:e,end:a}=this._computationManipulators.get(i),o=()=>{n.attached=e.grabbing||a.grabbing};o(),this.addHandles([e.events.on("grab-changed",o),a.events.on("grab-changed",o)],t)}else n.attached=!1})),d((()=>{const t=this._activeComputation;return null!=t?{geometry:t.geometry,constraint:t.previousConstraint}:{}}),(({geometry:t,constraint:e})=>{const i=this._constraintSnappingIndicator;null!=t&&null!=e&&e!==C.Direct?(i.visible=!0,i.setGeometryFromSegment(t.directSegment)):i.visible=!1}))]}removeStaged(){return null!=this._stagedDimension&&(this.analysis.dimensions.remove(this._stagedDimension),this._stagedDimension=null,!0)}onDeactivate(){this.removeStaged(),this._resetSnappingState()}onClick(t){const{_stagedDimension:e}=this;if(null==e){const e=this._onUnstagedClick(t);return this.analysis.dimensions.add(e),null}return this._onStagedClick(t),e}onPointerMove({mapPoint:t,pointerType:e}){if("touch"===e)return;const i=this._getSnappingContext(e);this.updatingHandles.addPromise(u(this._snappingOperation.snap({point:t},this._snappingManager,i)))}onManipulatorSelectionChanged(){if(null!=this.analysisViewData.selectedComputation){this._computationManipulators.get(this.analysisViewData.selectedComputation).offset.selected||(this.analysisViewData.selectedDimension=null)}}_onUnstagedClick({mapPoint:t,pointerType:e}){let a=t;if("mouse"===e){const i=this._getSnappingContext(e);a=this._snappingManager.update({point:t,context:i})}const o=new n({startPoint:y(a,new lt),endPoint:null,measureType:i.Horizontal});return this._stagedDimension=o,this._resetSnappingState(),o}_onStagedClick({mapPoint:t,pointerType:e}){const i=this._stagedComputation;if(null==i)return;let n=t;if("mouse"===e){const i=this._getSnappingContext(e);n=this._snappingManager.update({point:t,context:i})}const a=y(n,new lt);this._applyPointUpdate(i,{endPoint:a}),this._stagedDimension=null,this._resetSnappingState()}_resetSnappingState(){this._snappingManager.doneSnapping(),this._snappingOperation.abort(),this._snappingOperation.stagedPoint=null}_addComputation(t){if(this._computationManipulators.has(t))return;const e=this._setupPointManipulator(t,{isStart:!0}),n=this._setupPointManipulator(t,{isStart:!1}),a=this._setupOffsetManipulator(t),o=this._setupHeadingManipulator(t),s=this._setupRotationManipulator(t),r=this._setupMeasureTypeManipulator(t,i.Direct),p=this._setupMeasureTypeManipulator(t,i.Horizontal),l=this._setupMeasureTypeManipulator(t,i.Vertical),u=new P({start:e,end:n,offset:a,heading:o,rotation:s,direct:r,horizontal:p,vertical:l});this._setupComputationToManipulatorsSync(t,u),this._computationManipulators.set(t,u),this.manipulators.addMany(u.values())}_removeComputation(t){const e=this._computationManipulators.get(t);if(null!=e){this._computationHandles.remove(t),this._computationManipulators.delete(t);for(const t of e.values())this.manipulators.remove(t)}}_setupComputationToManipulatorsSync(t,e){this._computationHandles.add([d((()=>t.geometry),(()=>this._updateManipulators(t,e)),{...m,equals:s})],t)}_setupPointManipulator(t,e){const{view:i}=this,{dimension:n}=t,a=O(i,{metadata:n}),o=D(a,{isStart:e.isStart,createSnappingPipelineStep:t=>st({snappingContext:this._getSnappingContext(t),snappingManager:this._snappingManager,updatingHandles:this.updatingHandles}),dimension:n,onUpdate:e=>this._applyPointUpdate(t,e),view:i});return this._computationHandles.add(o,t),a}_setupOffsetManipulator(t){const{view:e}=this,i=j(e,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,metadata:t.dimension}),n=H(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupHeadingManipulator(t){const{view:e}=this,i=T(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),n=G(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupRotationManipulator(t){const{view:e}=this,i=T(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),n=I(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupMeasureTypeManipulator(t,e){const{view:i}=this,n=z(i,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,thinOffsetManipulatorMaterial:this._thinOffsetManipulatorMaterial,metadata:t.dimension}),a=x(n,{computation:t,manipulatorMeasureType:e,view:i});return this._computationHandles.add(a,t),n}_updateManipulators(t,e,n={stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator}){const{stagedDimension:a,selectedComputation:o,firstGrabbedManipulator:s}=n,{start:r,end:p,offset:l,heading:u,rotation:d}=e,c=o===t,m=L(t),{dimension:h}=t;for(const i of e.values()){const t=m&&null==a&&(null==s||i===s);i===l?(i.available=t,i.selected=c):i.available=t&&c}if(!m)return;null!=this._computeConstraint(t)?e.forEachMeasureTypeManipulator((t=>t.available=!1)):e.manipulatorForMeasureType(h.measureType).available=!1;for(const _ of[u,d])h.measureType===i.Direct&&0!==h.offset||(_.available=!1);q(t)?d.available=!1:u.available=!1;const{geometry:g}=t;r.renderLocation=g.directSegment.startRenderSpace,p.renderLocation=g.directSegment.endRenderSpace;const{renderCoordsHelper:f}=this.view;V(l,g,f),u.available&&U(u,t,f),d.available&&R(d,t,f),e.forEachMeasureTypeManipulator(((e,i)=>{e.available&&A(e,t,i,f)}))}_updateManipulatorStyle(t){const e=k(t),i=E(t),n={lineSizePt:t,material:this._orientationManipulatorMaterial};for(const{offset:a,heading:o,rotation:s}of this._computationManipulators.values())a.radius=i/2,F(o,n),F(s,n);this._unfocusedOffsetManipulatorMaterial.setParameters({width:e}),this._focusedOffsetManipulatorMaterial.setParameters({width:i})}_applyPointUpdate(t,e){const{view:i}=this,n=N(t);"startPoint"in e&&(n.elevationAlignedStartPoint=e.startPoint),"endPoint"in e&&(n.elevationAlignedEndPoint=e.endPoint);const a=B(n,i.renderCoordsHelper);if(null==a)return;const o=this._computeConstraint({...n,geometry:a});S(t,e,{...n,constraint:o,unconstrainedGeometry:a,view:i}),t===this._stagedComputation&&this._updateStagedDimensionOffset(t)}_updateStagedDimensionOffset(t){if(null==t.geometry)return;t.geometry.directSegment.eval(.5,ct);const e=this.view.state.camera.computeRenderPixelSizeAt(ct);t.dimension.offset=J.initialOffsetPx*e}_computeConstraint(t){return b(w(t,this._snappingManager.options),this.view)}get testInfo(){const t=t=>this.analysisViewData.computations.find((e=>e.dimension===t));return{disableManipulatorPartialOcclusion:()=>{this._stagedStartIndicator.renderOccluded=Y.Occlude,this.manipulators.forEach((({manipulator:t})=>{for(const{geometry:e}of t.renderObjects)e.material.setParameters({renderOccluded:Y.Occlude})}))},getManipulatorsForDimension:e=>this._computationManipulators.get(t(e)),getComputationForDimension:e=>t(e),getConstraintForDimension:e=>{const i=t(e);return null!=i?this._computeConstraint(i):null},stagedDimension:this._stagedDimension,stagedStartIndicator:this._stagedStartIndicator,constraintSnappingIndicator:this._constraintSnappingIndicator,snappingManager:this._snappingManager}}};function dt(){const{color:t,opacity:i}=J.offsetManipulator;return new tt({color:[...e.toUnitRGB(t),i],width:1,renderOccluded:Y.OccludeAndTransparent,writeDepth:!1,hasPolygonOffset:!0})}t([f({constructOnly:!0})],ut.prototype,"analysis",void 0),t([f({constructOnly:!0})],ut.prototype,"analysisViewData",void 0),t([f({constructOnly:!0})],ut.prototype,"manipulators",void 0),t([f({constructOnly:!0})],ut.prototype,"parentTool",void 0),t([f({constructOnly:!0,nonNullable:!0})],ut.prototype,"view",void 0),t([f({readOnly:!0})],ut.prototype,"updating",null),t([f()],ut.prototype,"firstGrabbedManipulator",null),t([f()],ut.prototype,"hasGrabbedManipulators",null),t([f()],ut.prototype,"snappingOptions",null),t([f()],ut.prototype,"_stagedDimension",void 0),t([f()],ut.prototype,"_activeComputation",null),t([f()],ut.prototype,"_stagedComputation",null),ut=t([_("esri.views.3d.analysis.Dimension.LengthDimensionSubTool")],ut);const ct=M();export{ut as LengthDimensionSubTool};
5
+ import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../Color.js";import"../../../../geometry.js";import{LengthDimensionMeasureType as i}from"../../../../analysis/dimensionUtils.js";import n from"../../../../analysis/LengthDimension.js";import{HandleOwner as a}from"../../../../core/HandleOwner.js";import o from"../../../../core/Handles.js";import{equals as s}from"../../../../core/lang.js";import{destroyMaybe as r,applySome as p}from"../../../../core/maybe.js";import{memoize as l}from"../../../../core/memoize.js";import{ignoreAbortErrors as u}from"../../../../core/promiseUtils.js";import{watch as d,sync as c,syncAndInitial as m,initial as h,when as g}from"../../../../core/reactiveUtils.js";import{property as f}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../../../core/accessorSupport/decorators/subclass.js";import{c as M}from"../../../../chunks/vec3f64.js";import{clonePoint as y}from"../../../../layers/graphics/hydratedFeatures.js";import{reapplyConstraint as v,LengthDimensionConstraint as C,applyConstraint as S,computeConstraint as b,constraintDependencies as w}from"./lengthDimensionConstraintUtils.js";import{LengthDimensionManipulators as P,createPointManipulator as O,pointManipulatorHandles as D,createOffsetManipulator as j,offsetManipulatorHandles as H,createOrientationManipulator as T,headingManipulatorHandles as G,rotationManipulatorHandles as I,createMeasureTypeManipulator as z,measureTypeManipulatorHandles as x,updateOffsetManipulatorTransform as V,updateHeadingManipulatorTransform as U,updateRotationManipulatorTransform as R,updateMeasureTypeManipulatorTransform as A,unfocusedOffsetWidth as k,focusedOffsetWidth as E,updateOrientationManipulator as F}from"./lengthDimensionManipulatorUtils.js";import{isValidComputation as L,arePointsVerticallyAligned as q,computeGeometryFromDimension as B,computationToGeometryDependencies as N}from"./lengthDimensionUtils.js";import{settings as J}from"./settings.js";import{getRotateHeadingTexture as K}from"../Slice/images/Factory.js";import{SnappingVisualizer3D as Q}from"../../interactive/SnappingVisualizer3D.js";import{LineVisualElement as W}from"../../interactive/visualElements/LineVisualElement.js";import{VerticesVisualElement as X}from"../../interactive/visualElements/VerticesVisualElement.js";import{RenderOccludedFlag as Y}from"../../webgl-engine/lib/Material.js";import{ImageMaterial as Z}from"../../webgl-engine/materials/ImageMaterial.js";import{createStipplePatternSimple as $}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as tt}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{createCoordinateHelper as et}from"../../../interactive/coordinateHelper.js";import{EditGeometry as it}from"../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as nt}from"../../../interactive/editGeometry/EditGeometryOperations.js";import{acquire as at}from"../../../interactive/snapping/SceneSnappingManagerPool.js";import{SnappingContext as ot}from"../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as st}from"../../../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as rt}from"../../../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as pt}from"../../../interactive/snapping/snappingUtils.js";import lt from"../../../../geometry/Point.js";let ut=class extends a{constructor(t){super(t),this._stagedDimension=null,this._computationManipulators=new Map,this._computationHandles=new o,this._getSnappingContext=l((t=>new ot({elevationInfo:{mode:"absolute-height",offset:0},pointer:t,editGeometryOperations:new nt(new it("point",et(!0,!1,this.view.spatialReference))),visualizer:new Q}))),this._snappingManagerResult=at(t.view),this.addHandles(this._snappingManagerResult),this._unfocusedOffsetManipulatorMaterial=dt(),this._focusedOffsetManipulatorMaterial=dt(),this._thinOffsetManipulatorMaterial=dt(),this._thinOffsetManipulatorMaterial.setParameters({stipplePattern:$(2)}),this._constraintSnappingIndicator=new W({view:t.view,attached:!0,width:1,color:e.toUnitRGBA(J.constraint.color),renderOccluded:Y.OccludeAndTransparent,stipplePattern:$(5)});const i=e.toUnitRGBA(J.disabledPointIndicator.color);i[3]*=J.disabledPointIndicator.opacity,this._stagedStartIndicator=new X({view:t.view,attached:!1,color:i,size:2*J.disabledPointIndicator.radius,elevationInfo:{mode:"absolute-height",offset:0},spatialReference:t.view.renderCoordsHelper.spatialReference,outlineSize:0,renderOccluded:Y.OccludeAndTransparent})}initialize(){this._snappingOperation=new rt({view:this.view});const{color:t,contrastColor:e}=J.orientationManipulator,i=!this.view._stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this._orientationManipulatorTexture=K(this.view.toolViewManager.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}),this._orientationManipulatorMaterial=new Z({transparent:!0,writeDepth:!1,textureId:this._orientationManipulatorTexture.texture.id,renderOccluded:Y.Opaque});const{computations:n}=this.analysisViewData;for(const a of n)this._addComputation(a);this.addHandles([n.on("after-add",(t=>this._addComputation(t.item))),n.on("after-remove",(t=>this._removeComputation(t.item)))]),this.addHandles([d((()=>({stagedPoint:this._snappingOperation.stagedPoint,stagedComputation:this._stagedComputation})),(({stagedPoint:t,stagedComputation:e})=>{if(null==e||null==t)return;const i=y(t,new lt);this._applyPointUpdate(e,{endPoint:i})}),c),d((()=>({stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator})),((t,e)=>{const{stagedDimension:i,selectedComputation:n,firstGrabbedManipulator:a}=t;if(i===e?.stagedDimension&&a===e?.firstGrabbedManipulator){for(const o of[n,e?.selectedComputation])if(null!=o){const e=this._computationManipulators.get(o);this._updateManipulators(o,e,t)}}else for(const[o,s]of this._computationManipulators)this._updateManipulators(o,s,t)}),m),d((()=>this.analysis.style.lineSize),(t=>{this._updateManipulatorStyle(t)}),h),d((()=>this.view.state.camera),(()=>{null!=this._stagedComputation&&this._updateStagedDimensionOffset(this._stagedComputation)})),d((()=>p(this._stagedComputation,(t=>{const e=t.elevationAlignedStartPoint,i=M();return null!=e&&this.view.renderCoordsHelper.toRenderCoords(e,i)?i:null}))),(t=>{null!=t?(this._stagedStartIndicator.vertices=[t],this._stagedStartIndicator.attached=!0):this._stagedStartIndicator.attached=!1}))]),this.addHandles(this._constraintHandles),this.addHandles(this._snappingIndicatorHandles),pt(this,(()=>{const t=this._activeComputation,e=this._stagedComputation;if(null==t||null!=e){const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);this.updatingHandles.addPromise(u(this._snappingOperation.resnap(this._snappingManager,e)))}if(null!=t){const{start:e,end:i}=this._computationManipulators.get(t);if(e.grabbing||i.grabbing){const i=e.grabbing?"start":"end",n=this._computeConstraint(t);v(t,i,{constraint:n,view:this.view})}}}))}destroy(){this._snappingOperation=r(this._snappingOperation),this._computationHandles.destroy(),this._constraintSnappingIndicator.destroy(),this._stagedStartIndicator.destroy(),this._orientationManipulatorMaterial.dispose(),this._orientationManipulatorTexture.release()}get updating(){return this.updatingHandles.updating||this._snappingManager.updating}get firstGrabbedManipulator(){return this.parentTool.firstGrabbedManipulator}get hasGrabbedManipulators(){return this.parentTool.hasGrabbedManipulators}get snappingOptions(){return this._snappingManager.options}get _snappingManager(){return this._snappingManagerResult.snappingManager}get _activeComputation(){if(null!=this._stagedComputation)return this._stagedComputation;const{selectedComputation:t}=this.analysisViewData;return this.hasGrabbedManipulators&&null!=t?t:null}get _stagedComputation(){const t=this._stagedDimension,e=this.analysisViewData.computations.at(-1);return null==t||null==e||e.dimension!==t?null:e}get _constraintHandles(){return[g((()=>this.analysisViewData.selectedComputation),(t=>{t.previousConstraint=this._computeConstraint(t)}),{...m,equals:s}),d((()=>{const t=this._activeComputation;if(null==t)return null;const{measureType:e,orientation:i}=t.dimension;return{measureType:e,orientation:i,computation:t}}),((t,e)=>{if(null!=t&&null==e){const{measureType:e,orientation:n,computation:a}=t;switch(a.previousConstraint){case C.Horizontal:a.preConstraintProperties={measureType:i.Horizontal,orientation:0};break;case C.Vertical:a.preConstraintProperties={measureType:i.Vertical,orientation:0};break;case C.Direct:a.preConstraintProperties={measureType:i.Direct,orientation:n};break;default:a.preConstraintProperties={measureType:e,orientation:n}}}null==t&&null!=e&&(e.computation.preConstraintProperties=null)}),c)]}get _snappingIndicatorHandles(){const t="snapping-indicator-event-handles";return[d((()=>({stagedComputation:this._stagedComputation,activeComputation:this._activeComputation})),(({stagedComputation:e,activeComputation:i})=>{const n=this._constraintSnappingIndicator;if(this.removeHandles(t),null!=i)if(i===e)n.attached=!0;else{const{start:e,end:a}=this._computationManipulators.get(i),o=()=>{n.attached=e.grabbing||a.grabbing};o(),this.addHandles([e.events.on("grab-changed",o),a.events.on("grab-changed",o)],t)}else n.attached=!1})),d((()=>{const t=this._activeComputation;return null!=t?{geometry:t.geometry,constraint:t.previousConstraint}:{}}),(({geometry:t,constraint:e})=>{const i=this._constraintSnappingIndicator;null!=t&&null!=e&&e!==C.Direct?(i.visible=!0,i.setGeometryFromSegment(t.directSegment)):i.visible=!1}))]}removeStaged(){return null!=this._stagedDimension&&(this.analysis.dimensions.remove(this._stagedDimension),this._stagedDimension=null,!0)}onDeactivate(){this.removeStaged(),this._resetSnappingState()}onClick(t){const{_stagedDimension:e}=this;if(null==e){const e=this._onUnstagedClick(t);return this.analysis.dimensions.add(e),null}return this._onStagedClick(t),e}onPointerMove({mapPoint:t,pointerType:e}){if("touch"===e)return;const i=this._getSnappingContext(e);this.updatingHandles.addPromise(u(this._snappingOperation.snap({point:t},this._snappingManager,i)))}onManipulatorSelectionChanged(){if(null!=this.analysisViewData.selectedComputation){this._computationManipulators.get(this.analysisViewData.selectedComputation).offset.selected||(this.analysisViewData.selectedDimension=null)}}_onUnstagedClick({mapPoint:t,pointerType:e}){let a=t;if("mouse"===e){const i=this._getSnappingContext(e);a=this._snappingManager.update({point:t,context:i})}const o=new n({startPoint:y(a,new lt),endPoint:null,measureType:i.Horizontal});return this._stagedDimension=o,this._resetSnappingState(),o}_onStagedClick({mapPoint:t,pointerType:e}){const i=this._stagedComputation;if(null==i)return;let n=t;if("mouse"===e){const i=this._getSnappingContext(e);n=this._snappingManager.update({point:t,context:i})}const a=y(n,new lt);this._applyPointUpdate(i,{endPoint:a}),this._stagedDimension=null,this._resetSnappingState()}_resetSnappingState(){this._snappingManager.doneSnapping(),this._snappingOperation.abort(),this._snappingOperation.stagedPoint=null}_addComputation(t){if(this._computationManipulators.has(t))return;const e=this._setupPointManipulator(t,{isStart:!0}),n=this._setupPointManipulator(t,{isStart:!1}),a=this._setupOffsetManipulator(t),o=this._setupHeadingManipulator(t),s=this._setupRotationManipulator(t),r=this._setupMeasureTypeManipulator(t,i.Direct),p=this._setupMeasureTypeManipulator(t,i.Horizontal),l=this._setupMeasureTypeManipulator(t,i.Vertical),u=new P({start:e,end:n,offset:a,heading:o,rotation:s,direct:r,horizontal:p,vertical:l});this._setupComputationToManipulatorsSync(t,u),this._computationManipulators.set(t,u),this.manipulators.addMany(u.values())}_removeComputation(t){const e=this._computationManipulators.get(t);if(null!=e){this._computationHandles.remove(t),this._computationManipulators.delete(t);for(const t of e.values())this.manipulators.remove(t)}}_setupComputationToManipulatorsSync(t,e){this._computationHandles.add([d((()=>t.geometry),(()=>this._updateManipulators(t,e)),{...m,equals:s})],t)}_setupPointManipulator(t,e){const{view:i}=this,{dimension:n}=t,a=O(i,{metadata:n}),o=D(a,{isStart:e.isStart,createSnappingPipelineStep:t=>st({snappingContext:this._getSnappingContext(t),snappingManager:this._snappingManager,updatingHandles:this.updatingHandles}),dimension:n,onUpdate:e=>this._applyPointUpdate(t,e),view:i});return this._computationHandles.add(o,t),a}_setupOffsetManipulator(t){const{view:e}=this,i=j(e,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,metadata:t.dimension}),n=H(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupHeadingManipulator(t){const{view:e}=this,i=T(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),n=G(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupRotationManipulator(t){const{view:e}=this,i=T(e,{lineSizePt:this.analysis.style.lineSize,material:this._orientationManipulatorMaterial,metadata:t.dimension}),n=I(i,{computation:t,view:e});return this._computationHandles.add(n,t),i}_setupMeasureTypeManipulator(t,e){const{view:i}=this,n=z(i,{lineSizePt:this.analysis.style.lineSize,unfocusedMaterial:this._unfocusedOffsetManipulatorMaterial,focusedMaterial:this._focusedOffsetManipulatorMaterial,thinOffsetManipulatorMaterial:this._thinOffsetManipulatorMaterial,metadata:t.dimension}),a=x(n,{computation:t,manipulatorMeasureType:e,view:i});return this._computationHandles.add(a,t),n}_updateManipulators(t,e,n={stagedDimension:this._stagedDimension,selectedComputation:this.analysisViewData.selectedComputation,firstGrabbedManipulator:this.firstGrabbedManipulator}){const{stagedDimension:a,selectedComputation:o,firstGrabbedManipulator:s}=n,{start:r,end:p,offset:l,heading:u,rotation:d}=e,c=o===t,m=L(t),{dimension:h}=t;for(const i of e.values()){const t=m&&null==a&&(null==s||i===s);i===l?(i.available=t,i.selected=c):i.available=t&&c}if(!m)return;null!=this._computeConstraint(t)?e.forEachMeasureTypeManipulator((t=>t.available=!1)):e.manipulatorForMeasureType(h.measureType).available=!1;for(const _ of[u,d])h.measureType===i.Direct&&0!==h.offset||(_.available=!1);q(t)?d.available=!1:u.available=!1;const{geometry:g}=t;r.renderLocation=g.directSegment.startRenderSpace,p.renderLocation=g.directSegment.endRenderSpace;const{renderCoordsHelper:f}=this.view;V(l,g,f),u.available&&U(u,t,f),d.available&&R(d,t,f),e.forEachMeasureTypeManipulator(((e,i)=>{e.available&&A(e,t,i,f)}))}_updateManipulatorStyle(t){const e=k(t),i=E(t),n={lineSizePt:t,material:this._orientationManipulatorMaterial};for(const{offset:a,heading:o,rotation:s}of this._computationManipulators.values())a.radius=i/2,F(o,n),F(s,n);this._unfocusedOffsetManipulatorMaterial.setParameters({width:e}),this._focusedOffsetManipulatorMaterial.setParameters({width:i})}_applyPointUpdate(t,e){const{view:i}=this,n=N(t);"startPoint"in e&&(n.elevationAlignedStartPoint=e.startPoint),"endPoint"in e&&(n.elevationAlignedEndPoint=e.endPoint);const a=B(n,i.renderCoordsHelper);if(null==a)return;const o=this._computeConstraint({...n,geometry:a});S(t,e,{...n,constraint:o,unconstrainedGeometry:a,view:i}),t===this._stagedComputation&&this._updateStagedDimensionOffset(t)}_updateStagedDimensionOffset(t){if(null==t.geometry)return;t.geometry.directSegment.eval(.5,ct);const e=this.view.state.camera.computeRenderPixelSizeAt(ct);t.dimension.offset=J.initialOffsetPx*e}_computeConstraint(t){return b(w(t,this._snappingManager.options),this.view)}get testInfo(){const t=t=>this.analysisViewData.computations.find((e=>e.dimension===t));return{disableManipulatorPartialOcclusion:()=>{this._stagedStartIndicator.renderOccluded=Y.Occlude,this.manipulators.forEach((({manipulator:t})=>{for(const{geometry:e}of t.renderObjects)e.material.setParameters({renderOccluded:Y.Occlude})}))},getManipulatorsForDimension:e=>this._computationManipulators.get(t(e)),getComputationForDimension:e=>t(e),getConstraintForDimension:e=>{const i=t(e);return null!=i?this._computeConstraint(i):null},stagedDimension:this._stagedDimension,stagedStartIndicator:this._stagedStartIndicator,constraintSnappingIndicator:this._constraintSnappingIndicator,snappingManager:this._snappingManager}}};function dt(){const{color:t,opacity:i}=J.offsetManipulator;return new tt({color:[...e.toUnitRGB(t),i],width:1,renderOccluded:Y.OccludeAndTransparent,writeDepth:!1,hasPolygonOffset:!0})}t([f({constructOnly:!0})],ut.prototype,"analysis",void 0),t([f({constructOnly:!0})],ut.prototype,"analysisViewData",void 0),t([f({constructOnly:!0})],ut.prototype,"manipulators",void 0),t([f({constructOnly:!0})],ut.prototype,"parentTool",void 0),t([f({constructOnly:!0,nonNullable:!0})],ut.prototype,"view",void 0),t([f({readOnly:!0})],ut.prototype,"updating",null),t([f()],ut.prototype,"firstGrabbedManipulator",null),t([f()],ut.prototype,"hasGrabbedManipulators",null),t([f()],ut.prototype,"snappingOptions",null),t([f()],ut.prototype,"_stagedDimension",void 0),t([f()],ut.prototype,"_activeComputation",null),t([f()],ut.prototype,"_stagedComputation",null),ut=t([_("esri.views.3d.analysis.Dimension.LengthDimensionSubTool")],ut);const ct=M();export{ut as LengthDimensionSubTool};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../analysis/SlicePlane.js";import{clock as i}from"../../../../core/clock.js";import a from"../../../../core/Handles.js";import{releaseMaybe as s,destroyMaybe as n,removeMaybe as r}from"../../../../core/maybe.js";import{watch as l,sync as o,syncAndInitial as h}from"../../../../core/reactiveUtils.js";import{addFrameTask as p}from"../../../../core/scheduling.js";import{createScreenPoint as u,screenPointObjectToArray as c,createScreenPointArray as d}from"../../../../core/screenUtils.js";import{property as _}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as v}from"../../../../core/accessorSupport/decorators/subclass.js";import{d as P,E as y,m}from"../../../../chunks/mat4.js";import{e as g,l as w,c as f,g as M,a as D,m as T,n as V,s as b}from"../../../../chunks/vec3.js";import{a as k,c as E}from"../../../../chunks/vec3f64.js";import{a as S,c as H,n as x,f as I}from"../../../../chunks/boundedPlane.js";import{signedDistance as R,create as j,intersectRay as O,normal as C}from"../../../../geometry/support/plane.js";import{create as z}from"../../../../geometry/support/ray.js";import{sv3d as G,sm4d as U,sv2d as L}from"../../../../geometry/support/vectorStacks.js";import{POINTER_MOVE_TIMER_MS as A,PLANE_PREVIEW_OUTLINE_WIDTH as K,forceVerticalModifier as B,forceHorizontalModifier as F,PLANE_OUTLINE_COLOR as N,PLANE_BACKGROUND_COLOR as q,PREVIEW_FADE_DOT_THRESHOLD as Z,PREVIEW_FADE_DURATION_SECONDS as J,INITIAL_DEPTH_OFFSET_FRAC as Q}from"./sliceToolConfig.js";import{createShiftManipulator as W,createRotateManipulator as X,createResizeManipulator as Y,createGridVisualElement as $,createOutlineVisualElement as tt,planeToShape as et,createRotatePlane as it,RotationAxis as at,resizePlane as st,calculatePlaneHalfSize as nt,SliceOrientation as rt,createPlane as lt,DidPointerMoveRecentlyFlag as ot,calculateBoundedPlaneTranslateRotate as ht,updateShiftRestartHandle as pt,updateRotateHeadingHandle as ut,updateRotateTiltHandle as ct,updateResizeHandle as dt,createShiftPlane as _t}from"./sliceToolUtils.js";import{getRotateHeadingTexture as vt,getTiltRotateTexture as Pt}from"./images/Factory.js";import{calculateInputRotationTransform as yt}from"../../interactive/manipulatorUtils.js";import{screenToRenderPlane as mt}from"../../interactive/editingTools/dragEventPipeline3D.js";import{fromScreen as gt}from"../../support/geometryUtils/ray.js";import{newIntersector as wt}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as ft}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{AnalysisToolBase as Mt}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as Dt}from"../../../interactive/dragEventPipeline.js";import{createScreenPointFromEvent as Tt}from"../../../support/screenUtils.js";var Vt;let bt=Vt=class extends Mt{constructor(t){super(t),this._clock=i,this._previewPlaneOpacity=1,this.removeIncompleteOnCancel=!1,this.layersMode="none",this.shiftManipulator=null,this.rotateHeadingManipulator=null,this.rotateTiltManipulator=null,this.resizeManipulators=null,this._handles=new a,this._viewHandles=new a,this._frameTask=null,this._pointerMoveTimerMs=A,this._prevPointerMoveTimeout=null,this._previewPlaneGridVisualElement=null,this._previewPlaneOutlineVisualElement=null,this._startPlane=S(),this._previewPlane=null,this._activeKeyModifiers={},this._lastCursorPosition=u(),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._intersector=wt(t.view.state.viewingMode),this._intersector.options.store=ft.MIN}initialize(){if(null==this.analysis)throw new Error("SliceTool requires valid analysis, but null was provided.");const t=!this.view._stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this._rotateHeadingImage=vt(this.view.toolViewManager.textures,{premultiplyAlpha:t}),this._rotateTiltImage=Pt(this.view.toolViewManager.textures);const e=t=>{this._updateManipulatorsInteractive(t),t.grabbing||(null!=this.analysisViewData.plane&&H(this.analysisViewData.plane,this._startPlane),this.inputState=null)};this.shiftManipulator=W(this.view),this.manipulators.add(this.shiftManipulator),this.shiftManipulator.events.on("grab-changed",(t=>{this._onShiftGrab(t),e(this.shiftManipulator)})),this._handles.add(this._createShiftDragPipeline(this.shiftManipulator)),this.rotateHeadingManipulator=X(this.view,this._rotateHeadingImage.texture),this.manipulators.add(this.rotateHeadingManipulator),this.rotateHeadingManipulator.events.on("grab-changed",(t=>{this._onRotateHeadingGrab(t),e(this.rotateHeadingManipulator)})),this._handles.add(this._createRotateHeadingDragPipeline(this.rotateHeadingManipulator)),this.rotateTiltManipulator=X(this.view,this._rotateTiltImage.texture),this.manipulators.add(this.rotateTiltManipulator),this.rotateTiltManipulator.events.on("grab-changed",(t=>{this._onRotateTiltGrab(t),e(this.rotateTiltManipulator)})),this._handles.add(this._createRotateTiltDragPipeline(this.rotateTiltManipulator)),this.resizeManipulators=this._resizeHandles.map(((t,i)=>{const a=Y(this.view,t);return a.events.on("grab-changed",(t=>{this._onResizeGrab(t,i),e(a)})),this._handles.add(this._createResizeDragPipeline(a)),a})),this.manipulators.addMany(this.resizeManipulators),this._previewPlaneGridVisualElement=$(this.view),this._previewPlaneOutlineVisualElement=tt(this.view),this._previewPlaneOutlineVisualElement.width=K,this._handles.add(l((()=>[this.analysisViewData.plane,this.analysis.tiltEnabled]),(()=>this._updateManipulators()),o));const i=l((()=>this.state),(t=>{"sliced"===t&&this.finishToolCreation()}),h);this._handles.add([i,l((()=>this.view.state.camera),(()=>this._onCameraChange()))])}destroy(){this._rotateHeadingImage=s(this._rotateHeadingImage),this._rotateTiltImage=s(this._rotateTiltImage),this._handles=n(this._handles),this._viewHandles=n(this._viewHandles),this._removeFrameTask(),this._clearPointerMoveTimeout(),this._previewPlaneOutlineVisualElement=n(this._previewPlaneOutlineVisualElement),this._previewPlaneGridVisualElement=n(this._previewPlaneGridVisualElement)}get state(){const t=!!this.analysisViewData.plane,e=!!this.inputState;return t?t&&e?"slicing":t&&!e?"sliced":"ready":"ready"}get cursor(){return this._isPlacingSlicePlane||"exclude"===this.layersMode?"crosshair":null!=this._creatingPointerId?"grabbing":null}set analysis(t){if(null==t)throw new Error("SliceTool requires valid analysis, but null was provided.");this._handles.remove("analysis"),this._set("analysis",t)}get inputState(){return this._get("inputState")}set inputState(t){this._set("inputState",t),this.analysisViewData.showGrid=null!=t&&"resize"===t.type,this._updateMaterials()}get _isPlacingSlicePlane(){return!this.inputState&&!this.analysisViewData.plane&&this.active}get _creatingPointerId(){return null!=this.inputState&&"shift"===this.inputState.type?this.inputState.creatingPointerId:null}enterExcludeLayerMode(){null!=this.analysisViewData.plane&&(this._set("layersMode","exclude"),this.active||(this.view.activeTool=this))}exitExcludeLayerMode(){null!=this.analysisViewData.plane&&(this._set("layersMode","none"),this.active&&(this.view.activeTool=null))}onDeactivate(){this._set("layersMode","none"),this._updatePreviewPlane(null)}onShow(){this._updateVisibility(!0)}onHide(){this._updateVisibility(!1)}_updateVisibility(t){this._updateManipulators(),t||this._clearPointerMoveTimeout()}onInputEvent(t){switch(t.type){case"pointer-drag":if(!Et(t))return;this._isPlacingSlicePlane?this._onClickPlacePlane(t)&&t.stopPropagation():this._onPointerDrag(t)&&t.stopPropagation();break;case"pointer-move":this._onPointerMove(t);break;case"pointer-up":this._onPointerUp(t)&&t.stopPropagation();break;case"immediate-click":if(!Et(t))return;this._onClickPlacePlane(t)&&t.stopPropagation();break;case"click":if(!Et(t))return;this._onClickExcludeLayer(t)&&t.stopPropagation();break;case"drag":this.inputState&&t.stopPropagation();break;case"key-down":this._onKeyDown(t)&&t.stopPropagation();break;case"key-up":this._onKeyUp(t)&&t.stopPropagation()}}onEditableChange(){this.analysisViewData.editable=this.internallyEditable}_onPointerDrag(t){const e=this.inputState;if(t.pointerId===this._creatingPointerId&&null!=e&&"shift"===e.type){const i=Tt(t);return this.shiftManipulator.events.emit("drag",{action:e.hasBeenDragged?"update":"start",pointerType:t.pointerType,start:i,screenPoint:i}),e.hasBeenDragged=!0,!0}return!1}_onPointerMove(t){this._lastCursorPosition.x=t.x,this._lastCursorPosition.y=t.y,this._resetPointerMoveTimeout(),"touch"!==t.pointerType&&this._updatePreviewPlane(Tt(t),this._activeKeyModifiers)}_onCameraChange(){this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),this._updateManipulators()}_onPointerUp(t){if(t.pointerId===this._creatingPointerId&&null!=this.analysisViewData.plane){const e=Tt(t);return this.shiftManipulator.events.emit("drag",{action:"end",start:e,screenPoint:e}),H(this.analysisViewData.plane,this._startPlane),this.inputState=null,!0}return!1}_onClickPlacePlane(t){if("exclude"===this.layersMode)return!1;if(this._isPlacingSlicePlane){const i=Tt(t),a=S();if(this._pickPlane(i,!1,this._activeKeyModifiers,a)){if(H(a,this._startPlane),this.analysis.shape=et(a,this.view,this.view.spatialReference,new e),"pointer-drag"===t.type){const e=this._calculatePickRay(i);this.inputState=kt(e,t.pointerId,a.origin,a)}return!0}}return!1}_onClickExcludeLayer(t){return!("exclude"!==this.layersMode||!this.created)&&(this.view.hitTest(Tt(t)).then((t=>{if(t.results.length){const e=t.results[0],i="graphic"===e?.type&&e.graphic;if(i){const t=i.sourceLayer||i.layer;t&&this.analysis.excludedLayers.push(t)}}else t.ground.layer?this.analysis.excludedLayers.push(t.ground.layer):this.analysis.excludeGroundSurface=!0})),this._set("layersMode","none"),this.active&&(this.view.activeTool=null),!0)}_onKeyDown(t){return(t.key===B||t.key===F)&&(this._activeKeyModifiers[t.key]=!0,null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onKeyUp(t){return!(t.key!==B&&t.key!==F||!this._activeKeyModifiers[t.key])&&(delete this._activeKeyModifiers[t.key],null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onShiftGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=this._calculatePickRay(t.screenPoint);H(this.analysisViewData.plane,this._startPlane),this.inputState=kt(e,null,this.shiftManipulator.renderLocation,this.analysisViewData.plane)}_createShiftDragPipeline(t){return Dt(t,((t,e,i)=>{const a=this.inputState;if(null==a||"shift"!==a.type)return;const s=null!=this.analysisViewData.plane?H(this.analysisViewData.plane,S()):null;e.next(mt(this.view,a.shiftPlane)).next(this._shiftDragAdjustSensitivity(a)).next(this._shiftDragUpdatePlane(a)),i.next((()=>{null!=s&&this._updateBoundedPlane(s)}))}))}_shiftDragAdjustSensitivity(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=.001,a=Math.min((1-Math.abs(g(x(this.analysisViewData.plane),e.ray.direction)/w(e.ray.direction)))/i,1),s=-R(this._startPlane.plane,e.renderEnd),n=-R(this._startPlane.plane,t.startPoint);return t.depth=t.depth*(1-a)+s*a-n,e}}_shiftDragUpdatePlane(t){return()=>{if(null==this.analysisViewData.plane)return;const e=f(G.get(),this._startPlane.origin),i=f(G.get(),x(this._startPlane));M(i,i,-t.depth),D(i,i,e);const a=I(i,this.analysisViewData.plane.basis1,this.analysisViewData.plane.basis2,S());this._updateBoundedPlane(a)}}_onRotateHeadingGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=it(this.analysisViewData.plane,this.view.renderCoordsHelper,at.HEADING,j()),i=this._calculatePickRay(t.screenPoint),a=E();O(e,i,a)&&(H(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateHeadingDragPipeline(t){return Dt(t,((t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?H(this.analysisViewData.plane,S()):null;e.next(mt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next((()=>{null!=s&&this._updateBoundedPlane(s)}))}))}_onRotateTiltGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=it(this.analysisViewData.plane,this.view.renderCoordsHelper,at.TILT,j()),i=this._calculatePickRay(t.screenPoint),a=E();O(e,i,a)&&(H(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateTiltDragPipeline(t){return Dt(t,((t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?H(this.analysisViewData.plane,S()):null;e.next(mt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next((()=>{null!=s&&this._updateBoundedPlane(s)}))}))}_rotateDragRenderPlaneToRotate(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=C(t.rotatePlane),a=yt(t.startPoint,e.renderEnd,this.analysisViewData.plane.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdatePlaneFromRotate(){return t=>{if(null==this.analysisViewData.plane)return;const e=P(U.get(),t.rotateAngle,t.rotateAxis);if(null==e)return;const i=T(G.get(),this._startPlane.basis1,e),a=T(G.get(),this._startPlane.basis2,e),s=I(this.analysisViewData.plane.origin,i,a,S());this._updateBoundedPlane(s)}}_onResizeGrab(t,e){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const i=this._calculatePickRay(t.screenPoint),a=G.get();O(this.analysisViewData.plane.plane,i,a)&&(H(this.analysisViewData.plane,this._startPlane),this.inputState={type:"resize",activeHandleIdx:e,startPoint:k(a)})}_createResizeDragPipeline(t){return Dt(t,((t,e,i)=>{const a=this.inputState;if(null==a||"resize"!==a.type||null==this.analysisViewData.plane)return;const s=H(this.analysisViewData.plane,S());e.next(mt(this.view,this.analysisViewData.plane.plane)).next(this._resizeDragUpdatePlane(a)),i.next((()=>{this._updateBoundedPlane(s)}))}))}_resizeDragUpdatePlane(t){return e=>{if(null==this.analysisViewData.plane)return;const i=this._resizeHandles[t.activeHandleIdx],a=st(i,t.startPoint,e.renderEnd,this.view.state.camera,this._startPlane,H(this.analysisViewData.plane));this._updateBoundedPlane(a)}}_updateBoundedPlane(t){const e=this.analysisViewData;if(null==e)throw new Error("valid internal object expected");e.plane=t}_updatePreviewPlane(t,e={}){let i=this._previewPlane;if(this._previewPlane=null,null==t)return this._removeFrameTask(),void this._updateManipulators();if(!this.analysisViewData.plane&&this.active){const a=null!=i?i:S();if(i=null!=i?H(i,St):null,this._pickPlane(t,!0,e,a)){const t=Z;let e=!1;null!=i&&(e=g(i.plane,a.plane)<t||g(V(G.get(),i.basis1),V(G.get(),a.basis1))<t),e&&(this._previewPlaneOpacity=0),this._previewPlane=a}}null!=this._previewPlane&&null==this._frameTask&&0===this._previewPlaneOpacity?this._frameTask=p({update:({deltaTime:t})=>{this._previewPlaneOpacity=Math.min(this._previewPlaneOpacity+t/(1e3*J),1),this._updateManipulators(),1===this._previewPlaneOpacity&&this._removeFrameTask()}}):null==this._previewPlane&&null!=this._frameTask?this._removeFrameTask():null!=this._previewPlane&&this._updateManipulators()}_removeFrameTask(){this._frameTask=r(this._frameTask)}_calculatePickRay(t){const e=z(),i=c(t,Ht);return gt(this.view.state.camera,i,e),V(e.direction,e.direction),e}_pickMinResult(t){const e=c(t,L.get());return this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(e,this._intersector),this._intersector.results.min}_pickPlane(t,e,i,a){const s=this._pickMinResult(t),n=G.get();if(!s.getIntersectionPoint(n))return!1;const r=s.getTransformedNormal(G.get()),l=this.view.state.camera;g(r,l.viewForward)>0&&M(r,r,-1);const o=nt(n,l),h=(e?1:-1)*o*Q,p=M(G.get(),r,h);D(p,p,n);const u=this.analysis.tiltEnabled?rt.TILTED:rt.HORIZONTAL_OR_VERTICAL,c=i[B]?rt.VERTICAL:i[F]?rt.HORIZONTAL:u;return lt(p,r,o,o,l,c,this.view.renderCoordsHelper,a),!0}_clearPointerMoveTimeout(){this._prevPointerMoveTimeout=r(this._prevPointerMoveTimeout)}_resetPointerMoveTimeout(){this._clearPointerMoveTimeout(),this.shiftManipulator.state|=ot,this.rotateHeadingManipulator.state|=ot,this.rotateTiltManipulator.state|=ot,this._prevPointerMoveTimeout=this._clock.setTimeout((()=>{this.shiftManipulator.state&=~ot,this.rotateHeadingManipulator.state&=~ot,this.rotateTiltManipulator.state&=~ot}),this._pointerMoveTimerMs)}_updateManipulators(){if(Vt.disableEngineLayers)return;let t,e=!1;if(null!=this.analysisViewData.plane)t=this.analysisViewData.plane,e=!1;else{if(null==this._previewPlane)return this.shiftManipulator.available=!1,this.rotateHeadingManipulator.available=!1,this.rotateTiltManipulator.available=!1,this.resizeManipulators.forEach((t=>t.available=!1)),this._previewPlaneOutlineVisualElement.visible=!1,void(this._previewPlaneGridVisualElement.visible=!1);t=this._previewPlane,e=!0}const i=ht(t,U.get());e?(this.shiftManipulator.available=!1,this.rotateHeadingManipulator.available=!1,this.rotateTiltManipulator.available=!1,this.resizeManipulators.forEach((t=>t.available=!1)),this._previewPlaneOutlineVisualElement.attached=!0,this._previewPlaneGridVisualElement.attached=!0,this._previewPlaneOutlineVisualElement.visible=!0,this._previewPlaneGridVisualElement.visible=!0):(this.shiftManipulator.available=!0,this.rotateHeadingManipulator.available=!0,this.rotateTiltManipulator.available=this.analysis.tiltEnabled,this.resizeManipulators.forEach((t=>t.available=!0)),pt(this.shiftManipulator,i,t,this.view.state.camera),ut(this.rotateHeadingManipulator,i,t,this.view.renderCoordsHelper),ct(this.rotateTiltManipulator,i,t),this.resizeManipulators.forEach(((e,a)=>dt(e,this._resizeHandles[a],i,t))),this._previewPlaneOutlineVisualElement.visible=!1,this._previewPlaneGridVisualElement.visible=!1);const a=b(G.get(),w(t.basis1),w(t.basis2),1),s=y(U.get(),a),n=m(s,i,s);this._previewPlaneOutlineVisualElement.transform=n,this._previewPlaneGridVisualElement.transform=n,this._updateMaterials()}_updateMaterials(){const t=[N[0],N[1],N[2],N[3]*this._previewPlaneOpacity];this._previewPlaneOutlineVisualElement.color=t;const e=[q[0],q[1],q[2],q[3]*this._previewPlaneOpacity],i=[0,0,0,0];this._previewPlaneGridVisualElement.backgroundColor=e,this._previewPlaneGridVisualElement.gridColor=i}_updateManipulatorsInteractive(t){if(!t.grabbing)return this.shiftManipulator.interactive=!0,this.rotateHeadingManipulator.interactive=!0,this.rotateTiltManipulator.interactive=!0,void this.resizeManipulators.forEach((t=>{t.interactive=!0}));this.shiftManipulator.interactive=this.shiftManipulator===t,this.rotateHeadingManipulator.interactive=this.rotateHeadingManipulator===t,this.rotateTiltManipulator.interactive=this.rotateTiltManipulator===t,this.resizeManipulators.forEach((e=>{e.interactive=e===t}))}testData(){return{plane:this.analysisViewData.plane,setPointerMoveTimerMs:t=>{this._pointerMoveTimerMs=t}}}};function kt(t,e,i,a){const s=_t(i,x(a),t.direction,j()),n=E();return O(s,t,n)?{type:"shift",creatingPointerId:e,hasBeenDragged:!1,shiftPlane:s,depth:0,startPoint:n}:null}function Et(t){return"mouse"!==t.pointerType||0===t.button}bt.disableEngineLayers=!1,t([_()],bt.prototype,"_clock",void 0),t([_({constructOnly:!0})],bt.prototype,"view",void 0),t([_()],bt.prototype,"analysisViewData",void 0),t([_({readOnly:!0})],bt.prototype,"state",null),t([_({readOnly:!0})],bt.prototype,"cursor",null),t([_()],bt.prototype,"analysis",null),t([_()],bt.prototype,"removeIncompleteOnCancel",void 0),t([_({readOnly:!0})],bt.prototype,"layersMode",void 0),t([_({value:null})],bt.prototype,"inputState",null),t([_()],bt.prototype,"_isPlacingSlicePlane",null),t([_()],bt.prototype,"_creatingPointerId",null),bt=Vt=t([v("esri.views.3d.analysis.Slice.SliceTool")],bt);const St=S(),Ht=d(),xt=bt;export{xt as default};
5
+ import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../analysis/SlicePlane.js";import{clock as i}from"../../../../core/clock.js";import a from"../../../../core/Handles.js";import{releaseMaybe as s,destroyMaybe as n,removeMaybe as r}from"../../../../core/maybe.js";import{watch as l,sync as o,syncAndInitial as h}from"../../../../core/reactiveUtils.js";import{addFrameTask as p}from"../../../../core/scheduling.js";import{createScreenPoint as u,screenPointObjectToArray as c,createScreenPointArray as d}from"../../../../core/screenUtils.js";import{property as _}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as v}from"../../../../core/accessorSupport/decorators/subclass.js";import{d as P,E as y,m}from"../../../../chunks/mat4.js";import{e as g,l as w,c as f,g as M,a as D,m as T,n as V,s as b}from"../../../../chunks/vec3.js";import{a as k,c as E}from"../../../../chunks/vec3f64.js";import{a as S,c as H,n as x,f as I}from"../../../../chunks/boundedPlane.js";import{signedDistance as j,create as R,intersectRay as C,normal as O}from"../../../../geometry/support/plane.js";import{create as z}from"../../../../geometry/support/ray.js";import{sv3d as G,sm4d as U,sv2d as L}from"../../../../geometry/support/vectorStacks.js";import{settings as A}from"./settings.js";import{POINTER_MOVE_TIMER_MS as K,PLANE_PREVIEW_OUTLINE_WIDTH as B,forceVerticalModifier as F,forceHorizontalModifier as N,PLANE_OUTLINE_COLOR as q,PLANE_BACKGROUND_COLOR as Z,PREVIEW_FADE_DOT_THRESHOLD as J,PREVIEW_FADE_DURATION_SECONDS as Q,INITIAL_DEPTH_OFFSET_FRAC as W}from"./sliceToolConfig.js";import{createShiftManipulator as X,createRotateManipulator as Y,createResizeManipulator as $,createGridVisualElement as tt,createOutlineVisualElement as et,planeToShape as it,createRotatePlane as at,RotationAxis as st,resizePlane as nt,calculatePlaneHalfSize as rt,SliceOrientation as lt,createPlane as ot,DidPointerMoveRecentlyFlag as ht,calculateBoundedPlaneTranslateRotate as pt,updateShiftRestartHandle as ut,updateRotateHeadingHandle as ct,updateRotateTiltHandle as dt,updateResizeHandle as _t,createShiftPlane as vt}from"./sliceToolUtils.js";import{getRotateHeadingTexture as Pt,getTiltRotateTexture as yt}from"./images/Factory.js";import{calculateInputRotationTransform as mt}from"../../interactive/manipulatorUtils.js";import{screenToRenderPlane as gt}from"../../interactive/editingTools/dragEventPipeline3D.js";import{fromScreen as wt}from"../../support/geometryUtils/ray.js";import{newIntersector as ft}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as Mt}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{AnalysisToolBase as Dt}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as Tt}from"../../../interactive/dragEventPipeline.js";import{createScreenPointFromEvent as Vt}from"../../../support/screenUtils.js";var bt;let kt=bt=class extends Dt{constructor(t){super(t),this._clock=i,this._previewPlaneOpacity=1,this.removeIncompleteOnCancel=!1,this.layersMode="none",this.shiftManipulator=null,this.rotateHeadingManipulator=null,this.rotateTiltManipulator=null,this.resizeManipulators=null,this._handles=new a,this._viewHandles=new a,this._frameTask=null,this._pointerMoveTimerMs=K,this._prevPointerMoveTimeout=null,this._previewPlaneGridVisualElement=null,this._previewPlaneOutlineVisualElement=null,this._startPlane=S(),this._previewPlane=null,this._activeKeyModifiers={},this._lastCursorPosition=u(),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._intersector=ft(t.view.state.viewingMode),this._intersector.options.store=Mt.MIN}initialize(){if(null==this.analysis)throw new Error("SliceTool requires valid analysis, but null was provided.");const t=!this.view._stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result,e={accentColor:A.rotateManipulators.color,contrastColor:A.rotateManipulators.contrastColor,preMultiplyAlpha:t};this._rotateHeadingImage=Pt(this.view.toolViewManager.textures,e),this._rotateTiltImage=yt(this.view.toolViewManager.textures,e);const i=t=>{this._updateManipulatorsInteractive(t),t.grabbing||(null!=this.analysisViewData.plane&&H(this.analysisViewData.plane,this._startPlane),this.inputState=null)};this.shiftManipulator=X(this.view),this.manipulators.add(this.shiftManipulator),this.shiftManipulator.events.on("grab-changed",(t=>{this._onShiftGrab(t),i(this.shiftManipulator)})),this._handles.add(this._createShiftDragPipeline(this.shiftManipulator)),this.rotateHeadingManipulator=Y(this.view,this._rotateHeadingImage.texture),this.manipulators.add(this.rotateHeadingManipulator),this.rotateHeadingManipulator.events.on("grab-changed",(t=>{this._onRotateHeadingGrab(t),i(this.rotateHeadingManipulator)})),this._handles.add(this._createRotateHeadingDragPipeline(this.rotateHeadingManipulator)),this.rotateTiltManipulator=Y(this.view,this._rotateTiltImage.texture),this.manipulators.add(this.rotateTiltManipulator),this.rotateTiltManipulator.events.on("grab-changed",(t=>{this._onRotateTiltGrab(t),i(this.rotateTiltManipulator)})),this._handles.add(this._createRotateTiltDragPipeline(this.rotateTiltManipulator)),this.resizeManipulators=this._resizeHandles.map(((t,e)=>{const a=$(this.view,t);return a.events.on("grab-changed",(t=>{this._onResizeGrab(t,e),i(a)})),this._handles.add(this._createResizeDragPipeline(a)),a})),this.manipulators.addMany(this.resizeManipulators),this._previewPlaneGridVisualElement=tt(this.view),this._previewPlaneOutlineVisualElement=et(this.view),this._previewPlaneOutlineVisualElement.width=B,this._handles.add(l((()=>[this.analysisViewData.plane,this.analysis.tiltEnabled]),(()=>this._updateManipulators()),o));const a=l((()=>this.state),(t=>{"sliced"===t&&this.finishToolCreation()}),h);this._handles.add([a,l((()=>this.view.state.camera),(()=>this._onCameraChange()))])}destroy(){this._rotateHeadingImage=s(this._rotateHeadingImage),this._rotateTiltImage=s(this._rotateTiltImage),this._handles=n(this._handles),this._viewHandles=n(this._viewHandles),this._removeFrameTask(),this._clearPointerMoveTimeout(),this._previewPlaneOutlineVisualElement=n(this._previewPlaneOutlineVisualElement),this._previewPlaneGridVisualElement=n(this._previewPlaneGridVisualElement)}get state(){const t=!!this.analysisViewData.plane,e=!!this.inputState;return t?t&&e?"slicing":t&&!e?"sliced":"ready":"ready"}get cursor(){return this._isPlacingSlicePlane||"exclude"===this.layersMode?"crosshair":null!=this._creatingPointerId?"grabbing":null}set analysis(t){if(null==t)throw new Error("SliceTool requires valid analysis, but null was provided.");this._handles.remove("analysis"),this._set("analysis",t)}get inputState(){return this._get("inputState")}set inputState(t){this._set("inputState",t),this.analysisViewData.showGrid=null!=t&&"resize"===t.type,this._updateMaterials()}get _isPlacingSlicePlane(){return!this.inputState&&!this.analysisViewData.plane&&this.active}get _creatingPointerId(){return null!=this.inputState&&"shift"===this.inputState.type?this.inputState.creatingPointerId:null}enterExcludeLayerMode(){null!=this.analysisViewData.plane&&(this._set("layersMode","exclude"),this.active||(this.view.activeTool=this))}exitExcludeLayerMode(){null!=this.analysisViewData.plane&&(this._set("layersMode","none"),this.active&&(this.view.activeTool=null))}onDeactivate(){this._set("layersMode","none"),this._updatePreviewPlane(null)}onShow(){this._updateVisibility(!0)}onHide(){this._updateVisibility(!1)}_updateVisibility(t){this._updateManipulators(),t||this._clearPointerMoveTimeout()}onInputEvent(t){switch(t.type){case"pointer-drag":if(!St(t))return;this._isPlacingSlicePlane?this._onClickPlacePlane(t)&&t.stopPropagation():this._onPointerDrag(t)&&t.stopPropagation();break;case"pointer-move":this._onPointerMove(t);break;case"pointer-up":this._onPointerUp(t)&&t.stopPropagation();break;case"immediate-click":if(!St(t))return;this._onClickPlacePlane(t)&&t.stopPropagation();break;case"click":if(!St(t))return;this._onClickExcludeLayer(t)&&t.stopPropagation();break;case"drag":this.inputState&&t.stopPropagation();break;case"key-down":this._onKeyDown(t)&&t.stopPropagation();break;case"key-up":this._onKeyUp(t)&&t.stopPropagation()}}onEditableChange(){this.analysisViewData.editable=this.internallyEditable}_onPointerDrag(t){const e=this.inputState;if(t.pointerId===this._creatingPointerId&&null!=e&&"shift"===e.type){const i=Vt(t);return this.shiftManipulator.events.emit("drag",{action:e.hasBeenDragged?"update":"start",pointerType:t.pointerType,start:i,screenPoint:i}),e.hasBeenDragged=!0,!0}return!1}_onPointerMove(t){this._lastCursorPosition.x=t.x,this._lastCursorPosition.y=t.y,this._resetPointerMoveTimeout(),"touch"!==t.pointerType&&this._updatePreviewPlane(Vt(t),this._activeKeyModifiers)}_onCameraChange(){this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),this._updateManipulators()}_onPointerUp(t){if(t.pointerId===this._creatingPointerId&&null!=this.analysisViewData.plane){const e=Vt(t);return this.shiftManipulator.events.emit("drag",{action:"end",start:e,screenPoint:e}),H(this.analysisViewData.plane,this._startPlane),this.inputState=null,!0}return!1}_onClickPlacePlane(t){if("exclude"===this.layersMode)return!1;if(this._isPlacingSlicePlane){const i=Vt(t),a=S();if(this._pickPlane(i,!1,this._activeKeyModifiers,a)){if(H(a,this._startPlane),this.analysis.shape=it(a,this.view,this.view.spatialReference,new e),"pointer-drag"===t.type){const e=this._calculatePickRay(i);this.inputState=Et(e,t.pointerId,a.origin,a)}return!0}}return!1}_onClickExcludeLayer(t){return!("exclude"!==this.layersMode||!this.created)&&(this.view.hitTest(Vt(t)).then((t=>{if(t.results.length){const e=t.results[0],i="graphic"===e?.type&&e.graphic;if(i){const t=i.sourceLayer||i.layer;t&&this.analysis.excludedLayers.push(t)}}else t.ground.layer?this.analysis.excludedLayers.push(t.ground.layer):this.analysis.excludeGroundSurface=!0})),this._set("layersMode","none"),this.active&&(this.view.activeTool=null),!0)}_onKeyDown(t){return(t.key===F||t.key===N)&&(this._activeKeyModifiers[t.key]=!0,null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onKeyUp(t){return!(t.key!==F&&t.key!==N||!this._activeKeyModifiers[t.key])&&(delete this._activeKeyModifiers[t.key],null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onShiftGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=this._calculatePickRay(t.screenPoint);H(this.analysisViewData.plane,this._startPlane),this.inputState=Et(e,null,this.shiftManipulator.renderLocation,this.analysisViewData.plane)}_createShiftDragPipeline(t){return Tt(t,((t,e,i)=>{const a=this.inputState;if(null==a||"shift"!==a.type)return;const s=null!=this.analysisViewData.plane?H(this.analysisViewData.plane,S()):null;e.next(gt(this.view,a.shiftPlane)).next(this._shiftDragAdjustSensitivity(a)).next(this._shiftDragUpdatePlane(a)),i.next((()=>{null!=s&&this._updateBoundedPlane(s)}))}))}_shiftDragAdjustSensitivity(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=.001,a=Math.min((1-Math.abs(g(x(this.analysisViewData.plane),e.ray.direction)/w(e.ray.direction)))/i,1),s=-j(this._startPlane.plane,e.renderEnd),n=-j(this._startPlane.plane,t.startPoint);return t.depth=t.depth*(1-a)+s*a-n,e}}_shiftDragUpdatePlane(t){return()=>{if(null==this.analysisViewData.plane)return;const e=f(G.get(),this._startPlane.origin),i=f(G.get(),x(this._startPlane));M(i,i,-t.depth),D(i,i,e);const a=I(i,this.analysisViewData.plane.basis1,this.analysisViewData.plane.basis2,S());this._updateBoundedPlane(a)}}_onRotateHeadingGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=at(this.analysisViewData.plane,this.view.renderCoordsHelper,st.HEADING,R()),i=this._calculatePickRay(t.screenPoint),a=E();C(e,i,a)&&(H(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateHeadingDragPipeline(t){return Tt(t,((t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?H(this.analysisViewData.plane,S()):null;e.next(gt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next((()=>{null!=s&&this._updateBoundedPlane(s)}))}))}_onRotateTiltGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=at(this.analysisViewData.plane,this.view.renderCoordsHelper,st.TILT,R()),i=this._calculatePickRay(t.screenPoint),a=E();C(e,i,a)&&(H(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateTiltDragPipeline(t){return Tt(t,((t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?H(this.analysisViewData.plane,S()):null;e.next(gt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next((()=>{null!=s&&this._updateBoundedPlane(s)}))}))}_rotateDragRenderPlaneToRotate(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=O(t.rotatePlane),a=mt(t.startPoint,e.renderEnd,this.analysisViewData.plane.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdatePlaneFromRotate(){return t=>{if(null==this.analysisViewData.plane)return;const e=P(U.get(),t.rotateAngle,t.rotateAxis);if(null==e)return;const i=T(G.get(),this._startPlane.basis1,e),a=T(G.get(),this._startPlane.basis2,e),s=I(this.analysisViewData.plane.origin,i,a,S());this._updateBoundedPlane(s)}}_onResizeGrab(t,e){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const i=this._calculatePickRay(t.screenPoint),a=G.get();C(this.analysisViewData.plane.plane,i,a)&&(H(this.analysisViewData.plane,this._startPlane),this.inputState={type:"resize",activeHandleIdx:e,startPoint:k(a)})}_createResizeDragPipeline(t){return Tt(t,((t,e,i)=>{const a=this.inputState;if(null==a||"resize"!==a.type||null==this.analysisViewData.plane)return;const s=H(this.analysisViewData.plane,S());e.next(gt(this.view,this.analysisViewData.plane.plane)).next(this._resizeDragUpdatePlane(a)),i.next((()=>{this._updateBoundedPlane(s)}))}))}_resizeDragUpdatePlane(t){return e=>{if(null==this.analysisViewData.plane)return;const i=this._resizeHandles[t.activeHandleIdx],a=nt(i,t.startPoint,e.renderEnd,this.view.state.camera,this._startPlane,H(this.analysisViewData.plane));this._updateBoundedPlane(a)}}_updateBoundedPlane(t){const e=this.analysisViewData;if(null==e)throw new Error("valid internal object expected");e.plane=t}_updatePreviewPlane(t,e={}){let i=this._previewPlane;if(this._previewPlane=null,null==t)return this._removeFrameTask(),void this._updateManipulators();if(!this.analysisViewData.plane&&this.active){const a=null!=i?i:S();if(i=null!=i?H(i,Ht):null,this._pickPlane(t,!0,e,a)){const t=J;let e=!1;null!=i&&(e=g(i.plane,a.plane)<t||g(V(G.get(),i.basis1),V(G.get(),a.basis1))<t),e&&(this._previewPlaneOpacity=0),this._previewPlane=a}}null!=this._previewPlane&&null==this._frameTask&&0===this._previewPlaneOpacity?this._frameTask=p({update:({deltaTime:t})=>{this._previewPlaneOpacity=Math.min(this._previewPlaneOpacity+t/(1e3*Q),1),this._updateManipulators(),1===this._previewPlaneOpacity&&this._removeFrameTask()}}):null==this._previewPlane&&null!=this._frameTask?this._removeFrameTask():null!=this._previewPlane&&this._updateManipulators()}_removeFrameTask(){this._frameTask=r(this._frameTask)}_calculatePickRay(t){const e=z(),i=c(t,xt);return wt(this.view.state.camera,i,e),V(e.direction,e.direction),e}_pickMinResult(t){const e=c(t,L.get());return this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(e,this._intersector),this._intersector.results.min}_pickPlane(t,e,i,a){const s=this._pickMinResult(t),n=G.get();if(!s.getIntersectionPoint(n))return!1;const r=s.getTransformedNormal(G.get()),l=this.view.state.camera;g(r,l.viewForward)>0&&M(r,r,-1);const o=rt(n,l),h=(e?1:-1)*o*W,p=M(G.get(),r,h);D(p,p,n);const u=this.analysis.tiltEnabled?lt.TILTED:lt.HORIZONTAL_OR_VERTICAL,c=i[F]?lt.VERTICAL:i[N]?lt.HORIZONTAL:u;return ot(p,r,o,o,l,c,this.view.renderCoordsHelper,a),!0}_clearPointerMoveTimeout(){this._prevPointerMoveTimeout=r(this._prevPointerMoveTimeout)}_resetPointerMoveTimeout(){this._clearPointerMoveTimeout(),this.shiftManipulator.state|=ht,this.rotateHeadingManipulator.state|=ht,this.rotateTiltManipulator.state|=ht,this._prevPointerMoveTimeout=this._clock.setTimeout((()=>{this.shiftManipulator.state&=~ht,this.rotateHeadingManipulator.state&=~ht,this.rotateTiltManipulator.state&=~ht}),this._pointerMoveTimerMs)}_updateManipulators(){if(bt.disableEngineLayers)return;let t,e=!1;if(null!=this.analysisViewData.plane)t=this.analysisViewData.plane,e=!1;else{if(null==this._previewPlane)return this.shiftManipulator.available=!1,this.rotateHeadingManipulator.available=!1,this.rotateTiltManipulator.available=!1,this.resizeManipulators.forEach((t=>t.available=!1)),this._previewPlaneOutlineVisualElement.visible=!1,void(this._previewPlaneGridVisualElement.visible=!1);t=this._previewPlane,e=!0}const i=pt(t,U.get());e?(this.shiftManipulator.available=!1,this.rotateHeadingManipulator.available=!1,this.rotateTiltManipulator.available=!1,this.resizeManipulators.forEach((t=>t.available=!1)),this._previewPlaneOutlineVisualElement.attached=!0,this._previewPlaneGridVisualElement.attached=!0,this._previewPlaneOutlineVisualElement.visible=!0,this._previewPlaneGridVisualElement.visible=!0):(this.shiftManipulator.available=!0,this.rotateHeadingManipulator.available=!0,this.rotateTiltManipulator.available=this.analysis.tiltEnabled,this.resizeManipulators.forEach((t=>t.available=!0)),ut(this.shiftManipulator,i,t,this.view.state.camera),ct(this.rotateHeadingManipulator,i,t,this.view.renderCoordsHelper),dt(this.rotateTiltManipulator,i,t),this.resizeManipulators.forEach(((e,a)=>_t(e,this._resizeHandles[a],i,t))),this._previewPlaneOutlineVisualElement.visible=!1,this._previewPlaneGridVisualElement.visible=!1);const a=b(G.get(),w(t.basis1),w(t.basis2),1),s=y(U.get(),a),n=m(s,i,s);this._previewPlaneOutlineVisualElement.transform=n,this._previewPlaneGridVisualElement.transform=n,this._updateMaterials()}_updateMaterials(){const t=[q[0],q[1],q[2],q[3]*this._previewPlaneOpacity];this._previewPlaneOutlineVisualElement.color=t;const e=[Z[0],Z[1],Z[2],Z[3]*this._previewPlaneOpacity],i=[0,0,0,0];this._previewPlaneGridVisualElement.backgroundColor=e,this._previewPlaneGridVisualElement.gridColor=i}_updateManipulatorsInteractive(t){if(!t.grabbing)return this.shiftManipulator.interactive=!0,this.rotateHeadingManipulator.interactive=!0,this.rotateTiltManipulator.interactive=!0,void this.resizeManipulators.forEach((t=>{t.interactive=!0}));this.shiftManipulator.interactive=this.shiftManipulator===t,this.rotateHeadingManipulator.interactive=this.rotateHeadingManipulator===t,this.rotateTiltManipulator.interactive=this.rotateTiltManipulator===t,this.resizeManipulators.forEach((e=>{e.interactive=e===t}))}testData(){return{plane:this.analysisViewData.plane,setPointerMoveTimerMs:t=>{this._pointerMoveTimerMs=t}}}};function Et(t,e,i,a){const s=vt(i,x(a),t.direction,R()),n=E();return C(s,t,n)?{type:"shift",creatingPointerId:e,hasBeenDragged:!1,shiftPlane:s,depth:0,startPoint:n}:null}function St(t){return"mouse"!==t.pointerType||0===t.button}kt.disableEngineLayers=!1,t([_()],kt.prototype,"_clock",void 0),t([_({constructOnly:!0})],kt.prototype,"view",void 0),t([_()],kt.prototype,"analysisViewData",void 0),t([_({readOnly:!0})],kt.prototype,"state",null),t([_({readOnly:!0})],kt.prototype,"cursor",null),t([_()],kt.prototype,"analysis",null),t([_()],kt.prototype,"removeIncompleteOnCancel",void 0),t([_({readOnly:!0})],kt.prototype,"layersMode",void 0),t([_({value:null})],kt.prototype,"inputState",null),t([_()],kt.prototype,"_isPlacingSlicePlane",null),t([_()],kt.prototype,"_creatingPointerId",null),kt=bt=t([v("esri.views.3d.analysis.Slice.SliceTool")],kt);const Ht=S(),xt=d(),It=kt;export{It 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.27/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../../Color.js";import{generateHeadingRotateTexture as o}from"./generateTextures.js";import r from"./tilt-rotate-png.js";import{Texture as e}from"../../../webgl-engine/lib/Texture.js";const n=64,a={mipmap:!0,preMultiplyAlpha:!0,width:n,height:n},l={accentColor:new t([255,127,0,.5]),contrastColor:new t([255,255,255,1])};function c(t,r){const a=r.accentColor??l.accentColor,c=r.contrastColor??l.contrastColor;return t.fromData(`heading-rotate:[accent:${a},contrast:${c},size:${n}]`,(()=>new e(o({accentColor:a,contrastColor:c,size:n}),{mipmap:!0,preMultiplyAlpha:r.premultiplyAlpha})))}function i(t){return t.fromData(r,(()=>new e(r,a)))}export{c as getRotateHeadingTexture,i as getTiltRotateTexture};
5
+ import{generateStyledTexture as t}from"./generateTextures.js";import o from"./heading-rotate-svg.js";import r from"./tilt-rotate-svg.js";import{Texture as e}from"../../../webgl-engine/lib/Texture.js";const a=64;function n(r,n){const{accentColor:l,contrastColor:c,preMultiplyAlpha:i}=n;return r.fromData(`heading-rotate:[accent:${l},contrast:${c},size:${a}]`,(()=>new e(t(o,{accentColor:l,contrastColor:c,size:a}),{mipmap:!0,preMultiplyAlpha:i})))}function l(o,n){const{accentColor:l,contrastColor:c,preMultiplyAlpha:i}=n;return o.fromData(`tilt-rotate:[accent:${l},contrast:${c},size:${a}]`,(()=>new e(t(r,{accentColor:l,contrastColor:c,size:a}),{mipmap:!0,preMultiplyAlpha:i})))}export{n as getRotateHeadingTexture,l as getTiltRotateTexture};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import t from"./heading-rotate-svg.js";const e="theme-style";function n(e){return s(a(o(r(t),e)),e.size)}function o(t,{accentColor:n,contrastColor:o}){const r=n.toHex(),a=n.a,s=o.toHex(),i=o.a,c=t.getElementsByTagNameNS("http://www.w3.org/2000/svg","style").namedItem(e);return c&&(c.innerHTML=`\n .contrast-fill { fill: ${s}; fill-opacity: ${i}; }\n .contrast-stroke { stroke: ${s}; stroke-opacity: ${i}; }\n .accent-fill { fill: ${r}; fill-opacity: ${a}; }\n .accent-stroke { stroke: ${r}; stroke-opacity: ${a}; }`),t}function r(t){const e=t.split(",")[1],n=atob(e);return(new DOMParser).parseFromString(n,"image/svg+xml")}function a(t){const e=(new XMLSerializer).serializeToString(t);return`data:image/svg+xml;base64,${btoa(e)}`}function s(t,e){const n=new Image(e,e);return n.src=t,n}export{n as generateHeadingRotateTexture};
5
+ const t="theme-style";function e(t,e){return a(r(n(o(t),e)),e.size)}function n(e,{accentColor:n,contrastColor:o}){const r=n.toHex(),a=n.a,s=o.toHex(),i=o.a,c=e.getElementsByTagNameNS("http://www.w3.org/2000/svg","style").namedItem(t);return c&&(c.innerHTML=`\n .contrast-fill { fill: ${s}; fill-opacity: ${i}; }\n .contrast-stroke { stroke: ${s}; stroke-opacity: ${i}; }\n .accent-fill { fill: ${r}; fill-opacity: ${a}; }\n .accent-stroke { stroke: ${r}; stroke-opacity: ${a}; }`),e}function o(t){const e=t.split(",")[1],n=atob(e);return(new DOMParser).parseFromString(n,"image/svg+xml")}function r(t){const e=(new XMLSerializer).serializeToString(t);return`data:image/svg+xml;base64,${btoa(e)}`}function a(t,e){const n=new Image(e,e);return n.src=t,n}export{e as generateStyledTexture};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- const I="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGlkPSJzdmcxMSIgd2lkdGg9IjU2IiBoZWlnaHQ9IjU2IiBmaWxsPSJub25lIiB2ZXJzaW9uPSIyLjAiPjxzdHlsZSBpZD0idGhlbWUtc3R5bGUiPi5jb250cmFzdC1maWxse2ZpbGw6I2ZmZn0uY29udHJhc3Qtc3Ryb2tle3N0cm9rZTojZmZmfS5hY2NlbnQtZmlsbHtmaWxsOiNmZjdmMDA7ZmlsbC1vcGFjaXR5Oi41fTwvc3R5bGU+PHBhdGggaWQ9InBhdGgzIiBkPSJNMjggMGEyOCAyOCAwIDEgMSAwIDU2IDI4IDI4IDAgMCAxIDAtNTZaIiBjbGFzcz0iYWNjZW50LWZpbGwiLz48cGF0aCBpZD0icGF0aDUiIHN0cm9rZS13aWR0aD0iNC45OSIgZD0iTTIwLjA1IDQwLjg2YTE1LjA1IDE1LjA1IDAgMCAwIDE3LjE0LTEuNSAxNS4wNSAxNS4wNSAwIDAgMCA0LjQ3LTE2LjY1IDE1LjA1IDE1LjA1IDAgMCAwLTIyLjcyLTcuMTUgMTUuMDUgMTUuMDUgMCAwIDAtNS41IDcuMTUiIGNsYXNzPSJjb250cmFzdC1zdHJva2UiLz48cGF0aCBpZD0icGF0aDciIGQ9Im0xMC45NyAzNS41NyA1LjM4IDEyLjA3IDcuNzktMTMuNDctMTMuMTcgMS40WiIgY2xhc3M9ImNvbnRyYXN0LWZpbGwiLz48L3N2Zz4=";export{I as default};
5
+ const I="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgZmlsbD0ibm9uZSIgdmVyc2lvbj0iMi4wIj48c3R5bGUgaWQ9InRoZW1lLXN0eWxlIj4uY29udHJhc3QtZmlsbHtmaWxsOiNmZmZ9LmNvbnRyYXN0LXN0cm9rZXtzdHJva2U6I2ZmZn0uYWNjZW50LWZpbGx7ZmlsbDojZmY3ZjAwO2ZpbGwtb3BhY2l0eTouNX08L3N0eWxlPjxwYXRoIGQ9Ik0yOCAwYTI4IDI4IDAgMSAxIDAgNTYgMjggMjggMCAwIDEgMC01NnoiIGNsYXNzPSJhY2NlbnQtZmlsbCIvPjxwYXRoIHN0cm9rZS13aWR0aD0iNC45OSIgZD0iTTIwLjA1IDQwLjg2YTE1LjA1IDE1LjA1IDAgMCAwIDE3LjE0LTEuNSAxNS4wNSAxNS4wNSAwIDAgMCA0LjQ3LTE2LjY1IDE1LjA1IDE1LjA1IDAgMCAwLTIyLjcyLTcuMTUgMTUuMDUgMTUuMDUgMCAwIDAtNS41IDcuMTUiIGNsYXNzPSJjb250cmFzdC1zdHJva2UiLz48cGF0aCBkPSJtMTAuOTcgMzUuNTcgNS4zOCAxMi4wNyA3Ljc5LTEzLjQ3LTEzLjE3IDEuNHoiIGNsYXNzPSJjb250cmFzdC1maWxsIi8+PC9zdmc+";export{I as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
+ */
5
+ const I="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1NiIgaGVpZ2h0PSI1NiIgZmlsbD0ibm9uZSIgdmVyc2lvbj0iMi4wIj48c3R5bGUgaWQ9InRoZW1lLXN0eWxlIj4uY29udHJhc3QtZmlsbHtmaWxsOiNmZmZ9LmNvbnRyYXN0LXN0cm9rZXtzdHJva2U6I2ZmZn0uYWNjZW50LWZpbGx7ZmlsbDojZmY3ZjAwO2ZpbGwtb3BhY2l0eTouNX08L3N0eWxlPjxjaXJjbGUgY3g9IjM5LjQ3OCIgY3k9IjMuMDc4IiByPSIyOCIgY2xhc3M9ImFjY2VudC1maWxsIiB0cmFuc2Zvcm09InJvdGF0ZSg0MC41NDIpIi8+PHBhdGggc3Ryb2tlLXdpZHRoPSI1IiBkPSJtNy4wNzQgMzAuMDUzIDI5LjM5NyAxMS45ODUtMy42NzMtMzMuNDkzIiBjbGFzcz0iY29udHJhc3Qtc3Ryb2tlIi8+PHBhdGggc3Ryb2tlLXdpZHRoPSIyLjk5NiIgZD0iTTI0LjUwNCAyMy4yMDdhMTEuOTgyIDExLjk4MiAwIDAgMC05LjggNy41MDciIGNsYXNzPSJjb250cmFzdC1zdHJva2UgY29udHJhc3QtZmlsbCIvPjxwYXRoIGQ9Im0yOS44MTggMjIuODA4LTYuMTg0IDQuNi0uNTQxLTguMzY0eiIgY2xhc3M9ImNvbnRyYXN0LWZpbGwiLz48L3N2Zz4=";export{I as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
+ */
5
+ import{getAccentColor as t,getContrastColor as r}from"../../../../core/analysisThemeUtils.js";const n={get main(){return t()},get mainTransparent(){return t(.5)},get contrast(){return r()}};class s{constructor(){this.color=n.mainTransparent,this.contrastColor=n.contrast}}class o{constructor(){this.rotateManipulators=new s}}let a=new o;function e(){a=new o}export{e as reloadSettings,a as settings};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import{fetchAsset as e}from"../../../assets.js";import r from"../../../core/Accessor.js";import{createTask as s}from"../../../core/asyncUtils.js";import i from"../../../core/Error.js";import a from"../../../core/Logger.js";import{abortMaybe as o,releaseMaybe as n,disposeMaybe as c}from"../../../core/maybe.js";import{isAbortError as f}from"../../../core/promiseUtils.js";import{initial as u}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{c as p,q as l,m}from"../../../chunks/mat4.js";import{f as g}from"../../../chunks/mat4f64.js";import{WatchUpdatingTracking as _}from"../../../core/support/WatchUpdatingTracking.js";import{StarPassParameters as b,StarsTechnique as y}from"./StarsTechnique.js";import{glLayout as v}from"../support/buffer/glUtil.js";import{newLayout as j}from"../support/buffer/InterleavedLayout.js";import{Default3D as w}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{VertexArrayObject as T}from"../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as k}from"../webgl-engine/lib/VertexAttribute.js";import{BufferObject as D}from"../../webgl/BufferObject.js";import{PrimitiveType as P,Usage as A}from"../../webgl/enums.js";let q=class extends r{get updating(){return this._updatingTracking.updating||this.loading}get loading(){return null!=this._loadDataTask&&!this._loadDataTask.finished}constructor(t){super(t),this._loadDataTask=null,this._numPoints=0,this._renderParameter=new b,this._updatingTracking=new _}initialize(){this._loadDataTask=this._createLoadDataTask()}destroy(){this._loadDataTask=o(this._loadDataTask),this._updatingTracking.destroy(),this._numPoints=0,this._technique=n(this._technique),this._vao=c(this._vao)}render(t){const{rctx:e}=t;if(this._ensureResources(e),null==this._technique||null==this._vao)return;if(!this._technique.compiled)return void this.requestRender();const r=e.bindTechnique(this._technique,this._renderParameter,t.bindParameters);e.bindVAO(this._vao),r.assertCompatibleVertexAttributeLocations(this._vao),e.drawArrays(P.POINTS,0,this._numPoints)}_ensureResources(t){if(null!=this._technique||null==L)return;this._technique=new y({rctx:t,viewingMode:this.view.state.viewingMode}),this._numPoints=L.byteLength/I;const e=new Float32Array(L,0,2*this._numPoints),r=new Uint8Array(L,2*this._numPoints*4,this._numPoints);this._vao=this._createVertexArrayObject(t,e,r,this._numPoints),this._updatingTracking.add((()=>"virtual"!==this.view.environment.lighting.type?this.view.environment.lighting.date:null),(t=>this._update(t)),u)}_computeDayDuration(t){const e=t,r=new Date(t.getFullYear(),0,1,11,58,56);return(+e-+r)/(+new Date(t.getFullYear()+1,0,1,11,58,55)-+r)}_update(t){if(!t)return;const e=(t.getHours()/12+t.getMinutes()/60*(2/24)+t.getSeconds()/60*(2/1440)-.9972222)%2,r=2*this._computeDayDuration(t),s=p(this._renderParameter.modelMatrix,S);l(s,s,-r*Math.PI),m(s,O,s),l(s,s,-e*Math.PI),this.requestRender()}_hexToRGB(t){return[parseInt(t.substring(0,2),16),parseInt(t.substring(2,4),16),parseInt(t.substring(4,6),16)]}_unpackUint8Attributes(t){return t>=192?[2.9,t-192]:t>=160?[2.5,t-160]:t>=128?[2,t-128]:t>=96?[1.5,t-96]:t>=64?[1,t-64]:t>=32?[.7,t-32]:[.4,t]}_createVertexArrayObject(t,e,r,s){const i=M.createBuffer(s),a=i.position,o=i.color,n=i.size;for(let c=0;c<s;c++){const t=e[2*c],s=e[2*c+1];a.set(c,0,-Math.cos(t)*Math.sin(s)),a.set(c,1,-Math.sin(t)*Math.sin(s)),a.set(c,2,-Math.cos(s));const i=this._unpackUint8Attributes(r[c]),f=this._hexToRGB(x[i[1]]);o.set(c,0,255*f[0]),o.set(c,1,255*f[1]),o.set(c,2,255*f[2]),o.set(c,3,255),n.set(c,i[0])}return new T(t,w,{geometry:v(M)},{geometry:D.createVertex(t,A.STATIC_DRAW,i.buffer)})}_createLoadDataTask(){if(null!=L)return null;const t=s((async t=>{const{data:r}=await e("esri/views/3d/environment/resources/stars.wsv",{responseType:"array-buffer",signal:t});this._verifyStarData(r),L=r}));return t.promise.catch((t=>{f(t)||a.getLogger(this.declaredClass).error(t)})).then((()=>{this.destroyed||(this.requestRender(),this.notifyChange("updating"))})),t}_verifyStarData(t){if(!t)throw new i("stars:no-data-received","Failed to create stars because star catalogue is missing");const e=t.byteLength/I;if(e%1!=0||e>5e4||e<5e3)throw new i("stars:invalid-data","Failed to create stars because star catalogue data is invalid")}};t([h({constructOnly:!0})],q.prototype,"view",void 0),t([h({constructOnly:!0})],q.prototype,"requestRender",void 0),t([h({readOnly:!0})],q.prototype,"updating",null),t([h()],q.prototype,"_loadDataTask",void 0),t([h()],q.prototype,"_updatingTracking",void 0),q=t([d("esri.views.3d.environment.Stars")],q);const x=["9bb2ff","9eb5ff","aabfff","bbccff","ccd8ff ","dae2ff","e4e9ff","eeefff","f8f6ff","fff9fb","fff5ef","fff1e5","ffeddb","ffe9d2","ffe6ca","ffe3c3","ffe0bb","ffddb4","ffdaad","ffd6a5","ffd29c","ffcc8f","ffc178","ffa94b","ff7b00"],O=g(1,0,0,0,0,.9174771405229186,.39778850739794974,0,0,-.39778850739794974,.9174771405229186,0,0,0,0,1),S=g(1,0,0,0,0,.9174771405229186,-.39778850739794974,0,0,.39778850739794974,.9174771405229186,0,0,0,0,1),I=9,M=j().vec3f(k.POSITION).vec4u8(k.COLOR).f32(k.SIZE);let L=null;export{q as Stars};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import{fetchAsset as e}from"../../../assets.js";import r from"../../../core/Accessor.js";import{createTask as s}from"../../../core/asyncUtils.js";import i from"../../../core/Error.js";import a from"../../../core/Logger.js";import{abortMaybe as o,releaseMaybe as n,disposeMaybe as c}from"../../../core/maybe.js";import{isAbortError as f}from"../../../core/promiseUtils.js";import{initial as u}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{c as l,q as p,m}from"../../../chunks/mat4.js";import{f as g}from"../../../chunks/mat4f64.js";import{WatchUpdatingTracking as _}from"../../../core/support/WatchUpdatingTracking.js";import{StarPassParameters as b,StarsTechnique as y}from"./StarsTechnique.js";import{glLayout as v}from"../support/buffer/glUtil.js";import{newLayout as j}from"../support/buffer/InterleavedLayout.js";import{Default3D as w}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{VertexArrayObject as T}from"../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as k}from"../webgl-engine/lib/VertexAttribute.js";import{BufferObject as D}from"../../webgl/BufferObject.js";import{PrimitiveType as P,Usage as A}from"../../webgl/enums.js";let q=class extends r{get updating(){return this._updatingTracking.updating||this.loading}get loading(){return null!=this._loadDataTask&&!this._loadDataTask.finished}constructor(t){super(t),this._loadDataTask=null,this._numPoints=0,this._renderParameter=new b,this._updatingTracking=new _}initialize(){this._loadDataTask=this._createLoadDataTask()}destroy(){this._loadDataTask=o(this._loadDataTask),this._updatingTracking.destroy(),this._numPoints=0,this._technique=n(this._technique),this._vao=c(this._vao),L=null}render(t){const{rctx:e}=t;if(this._ensureResources(e),null==this._technique||null==this._vao)return;if(!this._technique.compiled)return void this.requestRender();const r=e.bindTechnique(this._technique,this._renderParameter,t.bindParameters);e.bindVAO(this._vao),r.assertCompatibleVertexAttributeLocations(this._vao),e.drawArrays(P.POINTS,0,this._numPoints)}_ensureResources(t){if(null!=this._technique||null==L)return;this._technique=new y({rctx:t,viewingMode:this.view.state.viewingMode}),this._numPoints=L.byteLength/I;const e=new Float32Array(L,0,2*this._numPoints),r=new Uint8Array(L,2*this._numPoints*4,this._numPoints);this._vao=this._createVertexArrayObject(t,e,r,this._numPoints),this._updatingTracking.add((()=>"virtual"!==this.view.environment.lighting.type?this.view.environment.lighting.date:null),(t=>this._update(t)),u)}_computeDayDuration(t){const e=t,r=new Date(t.getFullYear(),0,1,11,58,56);return(+e-+r)/(+new Date(t.getFullYear()+1,0,1,11,58,55)-+r)}_update(t){if(!t)return;const e=(t.getHours()/12+t.getMinutes()/60*(2/24)+t.getSeconds()/60*(2/1440)-.9972222)%2,r=2*this._computeDayDuration(t),s=l(this._renderParameter.modelMatrix,S);p(s,s,-r*Math.PI),m(s,O,s),p(s,s,-e*Math.PI),this.requestRender()}_hexToRGB(t){return[parseInt(t.substring(0,2),16),parseInt(t.substring(2,4),16),parseInt(t.substring(4,6),16)]}_unpackUint8Attributes(t){return t>=192?[2.9,t-192]:t>=160?[2.5,t-160]:t>=128?[2,t-128]:t>=96?[1.5,t-96]:t>=64?[1,t-64]:t>=32?[.7,t-32]:[.4,t]}_createVertexArrayObject(t,e,r,s){const i=M.createBuffer(s),a=i.position,o=i.color,n=i.size;for(let c=0;c<s;c++){const t=e[2*c],s=e[2*c+1];a.set(c,0,-Math.cos(t)*Math.sin(s)),a.set(c,1,-Math.sin(t)*Math.sin(s)),a.set(c,2,-Math.cos(s));const i=this._unpackUint8Attributes(r[c]),f=this._hexToRGB(x[i[1]]);o.set(c,0,255*f[0]),o.set(c,1,255*f[1]),o.set(c,2,255*f[2]),o.set(c,3,255),n.set(c,i[0])}return new T(t,w,{geometry:v(M)},{geometry:D.createVertex(t,A.STATIC_DRAW,i.buffer)})}_createLoadDataTask(){if(null!=L)return null;const t=s((async t=>{const{data:r}=await e("esri/views/3d/environment/resources/stars.wsv",{responseType:"array-buffer",signal:t});this._verifyStarData(r),L=r}));return t.promise.catch((t=>{f(t)||a.getLogger(this.declaredClass).error(t)})).then((()=>{this.destroyed||(this.requestRender(),this.notifyChange("updating"))})),t}_verifyStarData(t){if(!t)throw new i("stars:no-data-received","Failed to create stars because star catalogue is missing");const e=t.byteLength/I;if(e%1!=0||e>5e4||e<5e3)throw new i("stars:invalid-data","Failed to create stars because star catalogue data is invalid")}};t([h({constructOnly:!0})],q.prototype,"view",void 0),t([h({constructOnly:!0})],q.prototype,"requestRender",void 0),t([h({readOnly:!0})],q.prototype,"updating",null),t([h()],q.prototype,"_loadDataTask",void 0),t([h()],q.prototype,"_updatingTracking",void 0),q=t([d("esri.views.3d.environment.Stars")],q);const x=["9bb2ff","9eb5ff","aabfff","bbccff","ccd8ff ","dae2ff","e4e9ff","eeefff","f8f6ff","fff9fb","fff5ef","fff1e5","ffeddb","ffe9d2","ffe6ca","ffe3c3","ffe0bb","ffddb4","ffdaad","ffd6a5","ffd29c","ffcc8f","ffc178","ffa94b","ff7b00"],O=g(1,0,0,0,0,.9174771405229186,.39778850739794974,0,0,-.39778850739794974,.9174771405229186,0,0,0,0,1),S=g(1,0,0,0,0,.9174771405229186,-.39778850739794974,0,0,.39778850739794974,.9174771405229186,0,0,0,0,1),I=9,M=j().vec3f(k.POSITION).vec4u8(k.COLOR).f32(k.SIZE);let L=null;export{q as Stars};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import"../../../geometry.js";import{neverReached as e}from"../../../core/compilerUtils.js";import t from"../../../core/Evented.js";import{deg2rad as i}from"../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{createScreenPointArray as n,createRenderScreenPointArray3 as o,screenPointObjectToArray as r,castRenderScreenPointArray as a}from"../../../core/screenUtils.js";import{once as c}from"../../../core/accessorSupport/utils.js";import{f as l}from"../../../chunks/mat3.js";import{c as h}from"../../../chunks/mat3f64.js";import{c as d,s as _,m as u,i as g}from"../../../chunks/mat4.js";import{c as m}from"../../../chunks/mat4f64.js";import{k as f}from"../../../chunks/vec2.js";import{a as p,t as b,m as v,g as y,c as j,d as L,s as S,b as R}from"../../../chunks/vec3.js";import{c as O,Z as w}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as T}from"../../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as A,projectPoint as E,sphericalPCPFtoLonLatElevation as D,computeENUToSphericalPCPFLocalRotation as F}from"../../../geometry/projection.js";import{containsPointObject as k}from"../../../geometry/support/aaBoundingRect.js";import{create as z,distance2 as P,fromPoints as C,closestRayDistance2 as I}from"../../../geometry/support/lineSegment.js";import{create as M,fromPositionAndNormal as x,intersectRay as U}from"../../../geometry/support/plane.js";import{create as B}from"../../../geometry/support/ray.js";import{sv3d as W}from"../../../geometry/support/vectorStacks.js";import{clonePoint as N,hydratedSpatialReference as H}from"../../../layers/graphics/hydratedFeatures.js";import{getElevationAtPoint as V}from"../support/ElevationProvider.js";import{fromScreen as G}from"../support/geometryUtils/ray.js";import{Camera as Y}from"../webgl-engine/lib/Camera.js";import{Object3D as Z}from"../webgl-engine/lib/Object3D.js";import{UpdatePolicy as q}from"../webgl-engine/lib/UpdatePolicy.js";import{WebGLLayer as J}from"../webgl-engine/lib/WebGLLayer.js";import{ManipulatorStateCustomFlags as K,ManipulatorStateFlags as Q}from"../../interactive/interfaces.js";import X from"../../../geometry/Point.js";class ${constructor(e){this.metadata=void 0,this._camera=new Y,this._elevation={offset:0,override:null},this.collisionType={type:"point"},this.collisionPriority=0,this._renderObjects=new Array,this.autoScaleRenderObjects=!0,this._available=!0,this._noDisplayCount=0,this._radius=10,this._worldSized=!1,this.focusMultiplier=2,this.touchMultiplier=2.5,this.worldOriented=!1,this._modelTransform=m(),this._worldFrame=null,this._renderLocation=O(),this._renderLocationDirty=!0,this._location=new X({x:0,y:0,z:0}),this._elevationAlignedLocation=new X,this._elevationAlignedLocationDirty=!0,this.interactive=!0,this.selectable=!1,this.grabbable=!0,this.cursor=null,this.grabCursor=null,this._grabbing=!1,this.dragging=!1,this._hovering=!1,this._selected=!1,this._state=K.None,this._focused=!1,this.events=new t.EventEmitter,this._screenLocation={screenPointArray:n(),renderScreenPointArray:o(),pixelSize:0},this._screenLocationDirty=!0,this._engineResourcesAddedToStage=!1,this._attached=!1,this._location.spatialReference=e.view.spatialReference;for(const t in e)this[t]=e[t];const i=this.view.state?.camera;i&&this._camera.copyFrom(i)}destroy(){this._applyObjectTransform=fe,this._removeResourcesFromStage(),this._engineResources=null,this.view=null,this._camera=null}get _stage(){return this.view?._stage}get elevationInfo(){return this._elevationInfo}set elevationInfo(e){this._elevationInfo=e,this._elevationAlignedLocationDirty=!0,this._renderLocationDirty=!0,this._updateEngineObject()}get renderObjects(){return this._renderObjects}set renderObjects(e){this._removeResourcesFromStage(),this._engineResources=null,this._renderObjects=e.slice(),this._updateEngineObject()}set available(e){e!==this._available&&(this._available=e,this._updateEngineObject())}get available(){return this._available}disableDisplay(){return this._noDisplayCount++,1===this._noDisplayCount&&this._updateEngineObject(),{remove:c((()=>{this._noDisplayCount--,0===this._noDisplayCount&&this._updateEngineObject()}))}}set radius(e){e!==this._radius&&(this._radius=e,this._updateEngineObject())}get radius(){return this._radius}set worldSized(e){e!==this._worldSized&&(this._worldSized=e,this._updateEngineObject())}get worldSized(){return this._worldSized}get modelTransform(){return this._modelTransform}set modelTransform(e){ee(e)&&(this._screenLocationDirty=!0),d(this._modelTransform,e),this._updateEngineObject()}get renderLocation(){return this._renderLocationDirty&&(this._renderLocationDirty=!1,this.view.renderCoordsHelper.toRenderCoords(this.elevationAlignedLocation,this._renderLocation),this.worldOriented?(this._worldFrame||(this._worldFrame=m()),te(this.view,this._renderLocation,this._worldFrame)):this._worldFrame&&(this._worldFrame=null)),this._renderLocation}set renderLocation(e){this.view.renderCoordsHelper.fromRenderCoords(e,this._location),this.elevationAlignedLocation=this._location}get location(){return this._location}set location(e){N(e,this._location),this._notifyLocationChanged()}_notifyLocationChanged(){this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!0,this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}get elevationAlignedLocation(){return this._elevationAlignedLocationDirty?(this._evaluateElevationAlignment(),this._updateElevationAlignedLocation(),this._elevationAlignedLocation):this._elevationAlignedLocation}set elevationAlignedLocation(e){N(e,this._location),this._evaluateElevationAlignment(),this._location.z-=this._elevation.offset,this._updateElevationAlignedLocation(),this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}_updateElevationAlignedLocation(){const e=null!=this._elevation.override?this._elevation.override:this.location.z||0;this._elevationAlignedLocation.x=this.location.x,this._elevationAlignedLocation.y=this.location.y,this._elevationAlignedLocation.z=e+this._elevation.offset,this._elevationAlignedLocation.spatialReference=H(this.location.spatialReference),this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!1}grabbableForEvent(){return!0}get grabbing(){return this._grabbing}set grabbing(e){e!==this._grabbing&&(this._grabbing=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get hovering(){return this._hovering}set hovering(e){e!==this._hovering&&(this._hovering=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get selected(){return this._selected}set selected(e){e!==this._selected&&(this._selected=e,this._updateEngineObject(),this.events.emit("select-changed",{action:e?"select":"deselect"}))}get state(){return this._state}set state(e){e!==this._state&&(this._state=e,this._updateEngineObject())}updateStateEnabled(e,t){t?this.state|=e:this.state&=~e}_setFocused(e){e!==this._focused&&(this._focused=e,this.events.emit("focus-changed",{action:!0===e?"focus":"unfocus"}))}get focused(){return this._focused}get screenLocation(){return this._ensureScreenLocation(),this._screenLocation}_ensureScreenLocation(){if(!this._screenLocationDirty)return;this._screenLocation.pixelSize=this._camera.computeScreenPixelSizeAt(this.renderLocation),this._screenLocationDirty=!1;let e;if(ee(this._modelTransform)){const t=this._calculateModelTransformOffset(ge);e=p(t,t,this.renderLocation)}else e=this.renderLocation;this._camera.projectToRenderScreen(e,this._screenLocation.renderScreenPointArray),this._camera.renderToScreen(this._screenLocation.renderScreenPointArray,this._screenLocation.screenPointArray)}get applyObjectTransform(){return this._applyObjectTransform}set applyObjectTransform(e){this._applyObjectTransform=e,this._screenLocationDirty=!0,this._updateEngineObject()}get attached(){return this._attached}intersectionDistance(t,i){if(!this.available)return null;const s=r(t,ie),n=this._getCollisionRadius(i),o=-1*this.collisionPriority;switch(this.collisionType.type){case"point":if(f(this.screenLocation.screenPointArray,s)<n*n)return this.screenLocation.renderScreenPointArray[2]+o;break;case"line":{const e=this.collisionType.paths,t=this._getWorldToScreenObjectScale(),i=this._calculateObjectTransform(t,ae),r=n*this.screenLocation.pixelSize,c=G(this._camera,s,ne);if(null==c)return null;for(const s of e){if(0===s.length)continue;const e=v(le,s[0],i);for(let t=1;t<s.length;t++){const n=v(he,s[t],i),l=I(C(e,n,se),c);if(null!=l&&l<r*r){const t=p(W.get(),e,n);y(t,t,.5);const i=a(W.get());return this._camera.projectToRenderScreen(t,i),i[2]+o}j(e,n)}}break}case"disc":{const e=this.collisionType.direction,t=this.collisionType.offset??w,i=this._getWorldToScreenObjectScale(),r=this._calculateObjectTransform(i,ae),a=n*this.screenLocation.pixelSize,c=G(this._camera,s,ne);if(null==c)return null;const h=l(oe,r),d=b(_e,e,h),_=v(ue,t,r);x(_,d,ce);const u=de;if(U(ce,c,u)&&L(u,_)<a*a)return this.screenLocation.renderScreenPointArray[2]+o;break}case"ribbon":{const{paths:e,direction:t}=this.collisionType,i=this._getWorldToScreenObjectScale(),r=this._calculateObjectTransform(i,ae),c=n*this._camera.computeScreenPixelSizeAt(this.renderLocation),h=G(this._camera,s,ne);if(null==h)return null;const d=l(oe,r),_=b(_e,t,d),u=this._calculateModelTransformPosition(ue);x(u,_,ce);const g=de;if(!U(ce,h,g))break;for(const s of e){if(0===s.length)continue;const e=v(le,s[0],r);for(let t=1;t<s.length;t++){const i=v(he,s[t],r),n=P(C(e,i,se),g);if(null!=n&&n<c*c){const t=p(W.get(),e,i);y(t,t,.5);const s=a(W.get());return this._camera.projectToRenderScreen(t,s),s[2]+o}j(e,i)}}break}default:e(this.collisionType)}return null}attach(e={manipulator3D:{}}){const t=this._stage;if(!t)return;const i=e.manipulator3D;i.engineLayerId?t?.getObject&&(this._engineLayer=t.getObject(i.engineLayerId)):(this._engineLayer=new J(t,{pickable:!1,updatePolicy:q.SYNC}),i.engineLayerId=this._engineLayer.id),i.engineLayerReferences=(i.engineLayerReferences||0)+1,this._materialIdReferences=i.materialIdReferences,null==this._materialIdReferences&&(this._materialIdReferences=new Map,i.materialIdReferences=this._materialIdReferences),this._camera.copyFrom(this.view.state.camera),this._attached=!0,this._updateEngineObject(),A(this._location.spatialReference,this.view.spatialReference)||(this.location=new X({x:0,y:0,z:0,spatialReference:this.view.spatialReference}))}detach(e={manipulator3D:{}}){const t=e.manipulator3D;t.engineLayerReferences--;const i=0===t.engineLayerReferences;this._removeResourcesFromStage(),i&&(t.engineLayerId=null,s(this._engineLayer)),this._engineResources=null,this._engineLayer=null,this._materialIdReferences=null,this._attached=!1}onViewChange(){this._camera.copyFrom(this.view.state.camera),this._screenLocationDirty=!0,this._updateEngineObject()}onElevationChange(e){E(this.location,me,e.spatialReference)&&k(e.extent,me)&&this._notifyLocationChanged()}_evaluateElevationAlignment(){if(null==this.elevationInfo)return;let e=null,t=0;const i=this.elevationInfo.offset??0;switch(this.elevationInfo.mode){case"on-the-ground":e=V(this.view.elevationProvider,this.location,"ground")??0;break;case"relative-to-ground":t=(V(this.view.elevationProvider,this.location,"ground")??0)+i;break;case"relative-to-scene":t=(V(this.view.elevationProvider,this.location,"scene")??0)+i;break;case"absolute-height":t=i}return t!==this._elevation.offset||e!==this._elevation.override?(this._elevation.offset=t,void(this._elevation.override=e)):void 0}_updateEngineObject(){if(!this._attached)return;if(!this.available)return void this._removeResourcesFromStage();const e=this._getWorldToScreenObjectScale(),t=ae;if(!0===this.autoScaleRenderObjects){const i=this._getFocusedSize(this._radius,this.focused)*e;this._calculateObjectTransform(i,t)}else this._calculateObjectTransform(e,t);const{objectsByState:i}=this._ensureEngineResources(),s=(this.focused?Q.Focused:Q.Unfocused)|(this.selected?Q.Selected:Q.Unselected),n=this._noDisplayCount>0;for(const{stateMask:o,objects:r}of i){if(n){for(const e of r)e.visible=!1;continue}const e=(o&Q.All)!==Q.None,i=(o&K.All)!==K.None,a=!e||(s&o)==(o&Q.All),c=!i||(this.state&o)==(o&K.All);if(a&&c)for(const s of r)s.visible=!0,s.transformation=t;else for(const t of r)t.visible=!1}}_ensureEngineResources(){if(null==this._engineResources){const e=this._engineLayer,t=[],i=new Set;this.renderObjects.forEach((({geometry:{material:e}})=>{i.has(e)||(t.push(e),i.add(e))}));const s=new Map;this._renderObjects.forEach((e=>{const t=new Z({castShadow:!1,geometries:[e.geometry]}),i=s.get(e.stateMask)||[];i.push(t),s.set(e.stateMask,i)}));const n=[];s.forEach(((e,t)=>n.push({stateMask:t,objects:e}))),this._engineResources={objectsByState:n,layer:e,materials:t}}return this._addResourcesToStage(),this._engineResources}_addResourcesToStage(){const e=this._stage;if(this._engineResourcesAddedToStage||null==this._engineResources||!e)return;const{objectsByState:t,layer:i,materials:s}=this._engineResources;s.forEach((t=>{const i=this._materialIdReferences,s=i.get(t.id)||0;0===s&&e.add(t),i.set(t.id,s+1)})),t.forEach((({objects:t})=>{i.addMany(t),e.addMany(t)})),this._engineResourcesAddedToStage=!0}_removeResourcesFromStage(){const e=this._stage;if(!this._engineResourcesAddedToStage||null==this._engineResources||!e)return;const{objectsByState:t,layer:i,materials:s}=this._engineResources;t.forEach((({objects:t})=>{i.removeMany(t),e.removeMany(t)})),s.forEach((t=>{const i=this._materialIdReferences,s=i.get(t.id);1===s?(e.remove(t),i.delete(t.id)):i.set(t.id,s-1)})),this._engineResourcesAddedToStage=!1}_getCollisionRadius(e){return this._getFocusedSize(this.radius,!0)*("touch"===e?this.touchMultiplier:1)}_getFocusedSize(e,t){return e*(t?this.focusMultiplier:1)}_getWorldToScreenObjectScale(){return this._worldSized?1:this.screenLocation.pixelSize}_calculateModelTransformPosition(e){const t=this._getWorldToScreenObjectScale(),i=this._calculateObjectTransform(t,re);return S(e,i[12],i[13],i[14])}_calculateModelTransformOffset(e){const t=this._calculateModelTransformPosition(e);return R(e,t,this.renderLocation)}_calculateObjectTransform(e,t){return _(t,e,0,0,0,0,e,0,0,0,0,e,0,0,0,0,1),this._worldFrame&&u(t,t,this._worldFrame),u(t,t,this._modelTransform),t[12]+=this.renderLocation[0],t[13]+=this.renderLocation[1],t[14]+=this.renderLocation[2],t[15]=1,null!=this._applyObjectTransform&&this._applyObjectTransform(t),t}get test(){let e=!1;if(null!=this._engineResources)for(const t in this._engineResources.objectsByState){const i=this._engineResources.objectsByState[t];for(const t of i.objects)if(t.visible){e=!0;break}if(e)break}return{areAnyResourcesVisible:e}}}function ee(e){return 0!==e[12]||0!==e[13]||0!==e[14]}function te(e,t,s){switch(e.viewingMode){case"local":return g(s),!0;case"global":{const n=T(e.renderCoordsHelper.spatialReference);return D(t,0,le,0,n.radius),F(i(le[0]),i(le[1]),s),!0}}}const ie=n(),se=z(),ne=B(),oe=h(),re=m(),ae=m(),ce=M(),le=O(),he=O(),de=O(),_e=O(),ue=O(),ge=O(),me=new X({x:0,y:0,z:0,spatialReference:null}),fe=()=>{};export{$ as Manipulator3D};
5
+ import"../../../geometry.js";import{neverReached as e}from"../../../core/compilerUtils.js";import t from"../../../core/Evented.js";import{deg2rad as i}from"../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{createScreenPointArray as n,createRenderScreenPointArray3 as o,screenPointObjectToArray as r,castRenderScreenPointArray as a}from"../../../core/screenUtils.js";import{once as c}from"../../../core/accessorSupport/utils.js";import{f as l}from"../../../chunks/mat3.js";import{c as h}from"../../../chunks/mat3f64.js";import{c as d,s as _,m as u,i as g}from"../../../chunks/mat4.js";import{c as m}from"../../../chunks/mat4f64.js";import{k as f}from"../../../chunks/vec2.js";import{a as p,t as b,m as v,g as y,c as j,d as L,s as S,b as R}from"../../../chunks/vec3.js";import{c as O,Z as w}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as T}from"../../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as A,projectPoint as E,sphericalPCPFtoLonLatElevation as D,computeENUToSphericalPCPFLocalRotation as F}from"../../../geometry/projection.js";import{containsPointObject as k}from"../../../geometry/support/aaBoundingRect.js";import{create as z,distance2 as P,fromPoints as C,closestRayDistance2 as I}from"../../../geometry/support/lineSegment.js";import{create as M,fromPositionAndNormal as x,intersectRay as U}from"../../../geometry/support/plane.js";import{create as B}from"../../../geometry/support/ray.js";import{sv3d as W}from"../../../geometry/support/vectorStacks.js";import{clonePoint as N,hydratedSpatialReference as H}from"../../../layers/graphics/hydratedFeatures.js";import{getElevationAtPoint as V}from"../support/ElevationProvider.js";import{fromScreen as G}from"../support/geometryUtils/ray.js";import{Camera as Y}from"../webgl-engine/lib/Camera.js";import{Object3D as Z}from"../webgl-engine/lib/Object3D.js";import{UpdatePolicy as q}from"../webgl-engine/lib/UpdatePolicy.js";import{WebGLLayer as J}from"../webgl-engine/lib/WebGLLayer.js";import{ManipulatorStateCustomFlags as K,ManipulatorStateFlags as Q}from"../../interactive/interfaces.js";import X from"../../../geometry/Point.js";class ${constructor(e){this.metadata=void 0,this._camera=new Y,this._elevation={offset:0,override:null},this.collisionType={type:"point"},this.collisionPriority=0,this._renderObjects=new Array,this.autoScaleRenderObjects=!0,this._available=!0,this._noDisplayCount=0,this._radius=10,this._worldSized=!1,this.focusMultiplier=2,this.touchMultiplier=2.5,this.worldOriented=!1,this._modelTransform=m(),this._worldFrame=null,this._renderLocation=O(),this._renderLocationDirty=!0,this._location=new X({x:0,y:0,z:0}),this._elevationAlignedLocation=new X,this._elevationAlignedLocationDirty=!0,this.interactive=!0,this.selectable=!1,this.grabbable=!0,this.cursor=null,this.grabCursor=null,this._grabbing=!1,this.dragging=!1,this._hovering=!1,this._selected=!1,this._state=K.None,this._focused=!1,this.events=new t.EventEmitter,this._screenLocation={screenPointArray:n(),renderScreenPointArray:o(),pixelSize:0},this._screenLocationDirty=!0,this._engineResourcesAddedToStage=!1,this._attached=!1,this._location.spatialReference=e.view.spatialReference;for(const t in e)this[t]=e[t];const i=this.view.state?.camera;i&&this._camera.copyFrom(i)}destroy(){this._applyObjectTransform=fe,this._removeResourcesFromStage(),this._engineResources=null,this.view=null,this._camera=null}get _stage(){return this.view?._stage}get elevationInfo(){return this._elevationInfo}set elevationInfo(e){this._elevationInfo=e,this._elevationAlignedLocationDirty=!0,this._renderLocationDirty=!0,this._updateEngineObject()}get renderObjects(){return this._renderObjects}set renderObjects(e){this._removeResourcesFromStage(),this._engineResources=null,this._renderObjects=e.slice(),this._updateEngineObject()}set available(e){e!==this._available&&(this._available=e,this._updateEngineObject())}get available(){return this._available}disableDisplay(){return this._noDisplayCount++,1===this._noDisplayCount&&this._updateEngineObject(),{remove:c((()=>{this._noDisplayCount--,0===this._noDisplayCount&&this._updateEngineObject()}))}}set radius(e){e!==this._radius&&(this._radius=e,this._updateEngineObject())}get radius(){return this._radius}set worldSized(e){e!==this._worldSized&&(this._worldSized=e,this._updateEngineObject())}get worldSized(){return this._worldSized}get modelTransform(){return this._modelTransform}set modelTransform(e){ee(e)&&(this._screenLocationDirty=!0),d(this._modelTransform,e),this._updateEngineObject()}get renderLocation(){return this._renderLocationDirty&&(this._renderLocationDirty=!1,this.view.renderCoordsHelper.toRenderCoords(this.elevationAlignedLocation,this._renderLocation),this.worldOriented?(this._worldFrame||(this._worldFrame=m()),te(this.view,this._renderLocation,this._worldFrame)):this._worldFrame&&(this._worldFrame=null)),this._renderLocation}set renderLocation(e){this.view.renderCoordsHelper.fromRenderCoords(e,this._location),this.elevationAlignedLocation=this._location}get location(){return this._location}set location(e){N(e,this._location),this._notifyLocationChanged()}_notifyLocationChanged(){this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!0,this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}get elevationAlignedLocation(){return this._elevationAlignedLocationDirty?(this._evaluateElevationAlignment(),this._updateElevationAlignedLocation(),this._elevationAlignedLocation):this._elevationAlignedLocation}set elevationAlignedLocation(e){N(e,this._location),this._evaluateElevationAlignment(),this._location.z-=this._elevation.offset,this._updateElevationAlignedLocation(),this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}_updateElevationAlignedLocation(){const e=null!=this._elevation.override?this._elevation.override:this.location.z||0;this._elevationAlignedLocation.x=this.location.x,this._elevationAlignedLocation.y=this.location.y,this._elevationAlignedLocation.z=e+this._elevation.offset,this._elevationAlignedLocation.spatialReference=H(this.location.spatialReference),this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!1}grabbableForEvent(){return!0}get grabbing(){return this._grabbing}set grabbing(e){e!==this._grabbing&&(this._grabbing=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get hovering(){return this._hovering}set hovering(e){e!==this._hovering&&(this._hovering=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get selected(){return this._selected}set selected(e){e!==this._selected&&(this._selected=e,this._updateEngineObject(),this.events.emit("select-changed",{action:e?"select":"deselect"}))}get state(){return this._state}set state(e){e!==this._state&&(this._state=e,this._updateEngineObject())}updateStateEnabled(e,t){t?this.state|=e:this.state&=~e}_setFocused(e){e!==this._focused&&(this._focused=e,this.events.emit("focus-changed",{action:!0===e?"focus":"unfocus"}))}get focused(){return this._focused}get screenLocation(){return this._ensureScreenLocation(),this._screenLocation}_ensureScreenLocation(){if(!this._screenLocationDirty)return;this._screenLocation.pixelSize=this._camera.computeScreenPixelSizeAt(this.renderLocation),this._screenLocationDirty=!1;let e;if(ee(this._modelTransform)){const t=this._calculateModelTransformOffset(ge);e=p(t,t,this.renderLocation)}else e=this.renderLocation;this._camera.projectToRenderScreen(e,this._screenLocation.renderScreenPointArray),this._camera.renderToScreen(this._screenLocation.renderScreenPointArray,this._screenLocation.screenPointArray)}get applyObjectTransform(){return this._applyObjectTransform}set applyObjectTransform(e){this._applyObjectTransform=e,this._screenLocationDirty=!0,this._updateEngineObject()}get attached(){return this._attached}intersectionDistance(t,i){if(!this.available)return null;const s=r(t,ie),n=this._getCollisionRadius(i),o=-1*this.collisionPriority;switch(this.collisionType.type){case"point":if(f(this.screenLocation.screenPointArray,s)<n*n)return this.screenLocation.renderScreenPointArray[2]+o;break;case"line":{const e=this.collisionType.paths,t=this._getWorldToScreenObjectScale(),i=this._calculateObjectTransform(t,ae),r=n*this.screenLocation.pixelSize,c=G(this._camera,s,ne);if(null==c)return null;for(const s of e){if(0===s.length)continue;const e=v(le,s[0],i);for(let t=1;t<s.length;t++){const n=v(he,s[t],i),l=I(C(e,n,se),c);if(null!=l&&l<r*r){const t=p(W.get(),e,n);y(t,t,.5);const i=a(W.get());return this._camera.projectToRenderScreen(t,i),i[2]+o}j(e,n)}}break}case"disc":{const e=this.collisionType.direction,t=this.collisionType.offset??w,i=this._getWorldToScreenObjectScale(),r=this._calculateObjectTransform(i,ae),a=n*this.screenLocation.pixelSize,c=G(this._camera,s,ne);if(null==c)return null;const h=l(oe,r),d=b(_e,e,h),_=v(ue,t,r);x(_,d,ce);const u=de;if(U(ce,c,u)&&L(u,_)<a*a)return this.screenLocation.renderScreenPointArray[2]+o;break}case"ribbon":{const{paths:e,direction:t}=this.collisionType,i=this._getWorldToScreenObjectScale(),r=this._calculateObjectTransform(i,ae),c=n*this._camera.computeScreenPixelSizeAt(this.renderLocation),h=G(this._camera,s,ne);if(null==h)return null;const d=l(oe,r),_=b(_e,t,d),u=this._calculateModelTransformPosition(ue);x(u,_,ce);const g=de;if(!U(ce,h,g))break;for(const s of e){if(0===s.length)continue;const e=v(le,s[0],r);for(let t=1;t<s.length;t++){const i=v(he,s[t],r),n=P(C(e,i,se),g);if(null!=n&&n<c*c){const t=p(W.get(),e,i);y(t,t,.5);const s=a(W.get());return this._camera.projectToRenderScreen(t,s),s[2]+o}j(e,i)}}break}default:e(this.collisionType)}return null}attach(e={manipulator3D:{}}){const t=this._stage;if(!t)return;const i=e.manipulator3D;null==i.engineLayerId?(this._engineLayer=new J(t,{pickable:!1,updatePolicy:q.SYNC}),i.engineLayerId=this._engineLayer.id):t?.getObject&&(this._engineLayer=t.getObject(i.engineLayerId)),i.engineLayerReferences=(i.engineLayerReferences||0)+1,this._materialIdReferences=i.materialIdReferences,null==this._materialIdReferences&&(this._materialIdReferences=new Map,i.materialIdReferences=this._materialIdReferences),this._camera.copyFrom(this.view.state.camera),this._attached=!0,this._updateEngineObject(),A(this._location.spatialReference,this.view.spatialReference)||(this.location=new X({x:0,y:0,z:0,spatialReference:this.view.spatialReference}))}detach(e={manipulator3D:{}}){const t=e.manipulator3D;t.engineLayerReferences--;const i=0===t.engineLayerReferences;this._removeResourcesFromStage(),i&&(t.engineLayerId=null,s(this._engineLayer)),this._engineResources=null,this._engineLayer=null,this._materialIdReferences=null,this._attached=!1}onViewChange(){this._camera.copyFrom(this.view.state.camera),this._screenLocationDirty=!0,this._updateEngineObject()}onElevationChange(e){E(this.location,me,e.spatialReference)&&k(e.extent,me)&&this._notifyLocationChanged()}_evaluateElevationAlignment(){if(null==this.elevationInfo)return;let e=null,t=0;const i=this.elevationInfo.offset??0;switch(this.elevationInfo.mode){case"on-the-ground":e=V(this.view.elevationProvider,this.location,"ground")??0;break;case"relative-to-ground":t=(V(this.view.elevationProvider,this.location,"ground")??0)+i;break;case"relative-to-scene":t=(V(this.view.elevationProvider,this.location,"scene")??0)+i;break;case"absolute-height":t=i}return t!==this._elevation.offset||e!==this._elevation.override?(this._elevation.offset=t,void(this._elevation.override=e)):void 0}_updateEngineObject(){if(!this._attached)return;if(!this.available)return void this._removeResourcesFromStage();const e=this._getWorldToScreenObjectScale(),t=ae;if(!0===this.autoScaleRenderObjects){const i=this._getFocusedSize(this._radius,this.focused)*e;this._calculateObjectTransform(i,t)}else this._calculateObjectTransform(e,t);const{objectsByState:i}=this._ensureEngineResources(),s=(this.focused?Q.Focused:Q.Unfocused)|(this.selected?Q.Selected:Q.Unselected),n=this._noDisplayCount>0;for(const{stateMask:o,objects:r}of i){if(n){for(const e of r)e.visible=!1;continue}const e=(o&Q.All)!==Q.None,i=(o&K.All)!==K.None,a=!e||(s&o)==(o&Q.All),c=!i||(this.state&o)==(o&K.All);if(a&&c)for(const s of r)s.visible=!0,s.transformation=t;else for(const t of r)t.visible=!1}}_ensureEngineResources(){if(null==this._engineResources){const e=this._engineLayer,t=[],i=new Set;this.renderObjects.forEach((({geometry:{material:e}})=>{i.has(e)||(t.push(e),i.add(e))}));const s=new Map;this._renderObjects.forEach((e=>{const t=new Z({castShadow:!1,geometries:[e.geometry]}),i=s.get(e.stateMask)||[];i.push(t),s.set(e.stateMask,i)}));const n=[];s.forEach(((e,t)=>n.push({stateMask:t,objects:e}))),this._engineResources={objectsByState:n,layer:e,materials:t}}return this._addResourcesToStage(),this._engineResources}_addResourcesToStage(){const e=this._stage;if(this._engineResourcesAddedToStage||null==this._engineResources||!e)return;const{objectsByState:t,layer:i,materials:s}=this._engineResources;s.forEach((t=>{const i=this._materialIdReferences,s=i.get(t.id)||0;0===s&&e.add(t),i.set(t.id,s+1)})),t.forEach((({objects:t})=>{i.addMany(t),e.addMany(t)})),this._engineResourcesAddedToStage=!0}_removeResourcesFromStage(){const e=this._stage;if(!this._engineResourcesAddedToStage||null==this._engineResources||!e)return;const{objectsByState:t,layer:i,materials:s}=this._engineResources;t.forEach((({objects:t})=>{i.removeMany(t),e.removeMany(t)})),s.forEach((t=>{const i=this._materialIdReferences,s=i.get(t.id);1===s?(e.remove(t),i.delete(t.id)):i.set(t.id,s-1)})),this._engineResourcesAddedToStage=!1}_getCollisionRadius(e){return this._getFocusedSize(this.radius,!0)*("touch"===e?this.touchMultiplier:1)}_getFocusedSize(e,t){return e*(t?this.focusMultiplier:1)}_getWorldToScreenObjectScale(){return this._worldSized?1:this.screenLocation.pixelSize}_calculateModelTransformPosition(e){const t=this._getWorldToScreenObjectScale(),i=this._calculateObjectTransform(t,re);return S(e,i[12],i[13],i[14])}_calculateModelTransformOffset(e){const t=this._calculateModelTransformPosition(e);return R(e,t,this.renderLocation)}_calculateObjectTransform(e,t){return _(t,e,0,0,0,0,e,0,0,0,0,e,0,0,0,0,1),this._worldFrame&&u(t,t,this._worldFrame),u(t,t,this._modelTransform),t[12]+=this.renderLocation[0],t[13]+=this.renderLocation[1],t[14]+=this.renderLocation[2],t[15]=1,null!=this._applyObjectTransform&&this._applyObjectTransform(t),t}get test(){let e=!1;if(null!=this._engineResources)for(const t in this._engineResources.objectsByState){const i=this._engineResources.objectsByState[t];for(const t of i.objects)if(t.visible){e=!0;break}if(e)break}return{areAnyResourcesVisible:e}}}function ee(e){return 0!==e[12]||0!==e[13]||0!==e[14]}function te(e,t,s){switch(e.viewingMode){case"local":return g(s),!0;case"global":{const n=T(e.renderCoordsHelper.spatialReference);return D(t,0,le,0,n.radius),F(i(le[0]),i(le[1]),s),!0}}}const ie=n(),se=z(),ne=B(),oe=h(),re=m(),ae=m(),ce=M(),le=O(),he=O(),de=O(),_e=O(),ue=O(),ge=O(),me=new X({x:0,y:0,z:0,spatialReference:null}),fe=()=>{};export{$ as Manipulator3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Evented.js";import i from"../../../../../core/Handles.js";import{makeHandle as a}from"../../../../../core/handleUtils.js";import{rad2deg as s}from"../../../../../core/mathUtils.js";import{createLength as o}from"../../../../../core/quantityUtils.js";import{watch as r,initial as n}from"../../../../../core/reactiveUtils.js";import{screenPointObjectToArray as p}from"../../../../../core/screenUtils.js";import{lengthUnitFromSpatialReference as l,getMetersPerUnitForSR as h}from"../../../../../core/unitUtils.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as u}from"../../../../../core/accessorSupport/decorators/subclass.js";import{q as d}from"../../../../../chunks/mat4.js";import{s as m,a as _,f as g}from"../../../../../chunks/vec2.js";import{a as v}from"../../../../../chunks/vec2f64.js";import{c as y,A as f,b as S,n as M,l as T,e as b}from"../../../../../chunks/vec3.js";import{c as x,a as E}from"../../../../../chunks/vec3f64.js";import{containsXY as A}from"../../../../../geometry/support/aaBoundingRect.js";import{a as B,c as O}from"../../../../../chunks/boundedPlane.js";import{intersectRay as R,create as j,normal as G}from"../../../../../geometry/support/plane.js";import{create as D}from"../../../../../geometry/support/ray.js";import{sv2d as w,sv3d as P,sm4d as z}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as I}from"../../../../../support/elevationInfoUtils.js";import{createShiftManipulator as U,OffsetMode as Z,IsShiftEdgeOnScreenFlag as C,createResizeManipulator as k,resizeNormal as X,resizeOutlineOnly as Y,isDiagonalResizeHandle as L,calculateDiagonalResizeHandleScale as N,createRotatePlane as V,RotationAxis as H,calculateBoundedPlaneTranslateRotate as F,updateRotateHeadingHandle as q,updateResizeHandle as W}from"../../../analysis/Slice/sliceToolUtils.js";import{getRotateHeadingTexture as J}from"../../../analysis/Slice/images/Factory.js";import{Manipulator3D as K}from"../../Manipulator3D.js";import{createRotateManipulator as Q,getGraphicAttachmentOrigin as $,calculateInputRotationTransform as tt}from"../../manipulatorUtils.js";import{screenToZConstrained as et,screenToRenderPlane as it}from"../dragEventPipeline3D.js";import{ManipulatorType as at}from"../ManipulatorType.js";import{canMoveZ as st}from"../manipulatorUtils.js";import{createVisualElements as ot}from"../visualElementUtils.js";import{ManipulationType as rt}from"../manipulations/MoveManipulation.js";import{MoveXYGraphicManipulation as nt}from"../manipulations/MoveXYGraphicManipulation.js";import{PreserveAspectRatio as pt}from"./PreserveAspectRatio.js";import{OutlineVisualElement as lt}from"../../visualElements/OutlineVisualElement.js";import{evaluateElevationAlignmentAtPoint as ht}from"../../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as ct}from"../../../layers/graphics/ElevationContext.js";import{GraphicState as ut}from"../../../layers/graphics/GraphicState.js";import{fromScreen as dt}from"../../../support/geometryUtils/ray.js";import{createManipulatorDragEventPipeline as mt,addMapDelta as _t,addScreenDelta as gt}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as vt}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as yt}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as ft}from"../../../../interactive/editGeometry/interfaces.js";import{AccumulationType as St}from"../../../../interactive/editGeometry/operations/UpdateVertices.js";import{mapPlaneAutoHorizontalSizeByElevationMode as Mt,calculateOrientedBounds as Tt,mapPlaneToRenderPlane as bt,apply as xt,unapply as Et}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";import At from"../../../../interactive/sketch/SketchTooltipOptions.js";import{ExtentRotateTooltipInfo as Bt,ExtentScaleTooltipInfo as Ot}from"../../../../interactive/tooltip/ExtentTooltipInfos.js";import{Tooltip as Rt}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as jt,TranslateGraphicZTooltipInfo as Gt}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as Dt}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistance as wt}from"../../../../support/euclideanLengthMeasurementUtils.js";let Pt=class extends(e.EventedMixin(vt)){constructor(t){super(t),this.enableZ=!0,this.enableRotation=!0,this.enableScaling=!0,this.tooltipOptions=new At,this._preserveAspectRatio=new pt,this.grabbing=!1,this.inputState=null,this.type="transform-3d",this._handles=new i,this._attachmentOrigin=null,this._outlineVisualElement=null,this._mapBounds=B(),this._mapBoundsStart=B(),this._zmax=0,this._sizeStart=null,this._displayBounds=B(),this._displayBoundsStart=B(),this._displayBoundsMarginStart=0,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._moveXYTooltipInfo=null,this._moveZTooltipInfo=null,this._rotateTooltipInfo=null,this._scaleTooltipInfo=null,this._startAngle=0,this._endAngle=0,this._startScale=v(),this._endScale=v()}initialize(){const{view:t,graphic:e,manipulators:i,_handles:s}=this,o=this._graphicState=new ut({graphic:e}),p=e.geometry;this._editGeometryOperations=yt.fromGeometry(p,t.state.viewingMode),this._graphicMoveManipulation=new nt({tool:this,view:t,graphicState:o}),this._moveZManipulator=U(t,Z.CENTER_ON_CALLOUT),this._moveZManipulator.state|=C,s.add([this._createMoveXYGraphicDragPipeline(),r((()=>this.enableZ),(()=>this._updateManipulatorAvailability(this._moveZManipulator,at.TRANSLATE_Z))),this._createMoveZDragPipeline()]),i.add(this._moveZManipulator),this._resizeManipulators=this._resizeHandles.map((e=>{const i=k(t,e);return s.add([r((()=>this.enableScaling),(()=>this._updateManipulatorAvailability(i,at.SCALE))),i.events.on("grab-changed",(t=>this._onResizeGrab(t))),this._createResizeDragPipeline(i,e)]),i})),i.addMany(this._resizeManipulators);const l=!this.view._stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this._rotateManipulatorTexture=J(t.toolViewManager.textures,{premultiplyAlpha:l}),this._rotateManipulator=Q(t,{texture:this._rotateManipulatorTexture.texture}),s.add([r((()=>this.enableRotation),(()=>this._updateManipulatorAvailability(this._rotateManipulator,at.ROTATE))),this._rotateManipulator.events.on("grab-changed",(t=>{this._onRotateGrab(t)})),this._createRotateDragPipeline(this._rotateManipulator)]),i.add(this._rotateManipulator),this._calculateMapBounds(),this._updateDisplayBounds();const h=ot({view:t,graphic:e,forEachManipulator:t=>this._forEachManipulator(t),onManipulatorsChanged:()=>a()});null!=h&&(this._outlineVisualElement=h.visualElement instanceof lt?h.visualElement:null),null!=this._outlineVisualElement&&s.add(this._outlineVisualElement.events.on("attachment-origin-changed",(()=>this._updateDisplayBounds()))),s.add(h),s.add([o.on("changed",(()=>this._onGeometryChanged())),r((()=>o.displaying),(()=>this._updateAllManipulatorAvailability())),r((()=>o.isDraped),(()=>this._graphicDrapedChanged()),n),t.trackGraphicState(o)]);const c=t.pointsOfInterest;s.add(r((()=>c?.centerOnSurfaceFrequent.location),(()=>this._updateDisplayBounds())));const u=t=>{s.add(t.events.on("grab-changed",(()=>{this.grabbing=t.grabbing,this._updateAllManipulatorAvailability()})))};this._forEachManipulator(u);const d=(t,i)=>{s.add(t.events.on("immediate-click",(t=>{i===at.TRANSLATE_XY&&this.emit("immediate-click",{...t,graphic:e}),t.stopPropagation()})))};this._forEachManipulator(d),this._onGeometryChanged(),this._updateAllManipulatorAvailability(),this._initializeTooltip(),this.finishToolCreation()}destroy(){this._mapBounds=null,this._displayBounds=null,this._rotateManipulatorTexture.release(),this._handles.destroy(),this._graphicMoveManipulation.destroy(),this._editGeometryOperations.destroy(),this._tooltip.destroy(),this._set("view",null),this._set("graphic",null)}_initializeTooltip(){const{_handles:t,view:e}=this,i=this._tooltip=new Rt({view:e}),a=()=>{i.info=this._getUpdatedTooltipInfo()};t.add([this.on("graphic-translate-start",a),this.on("graphic-translate",a),this.on("graphic-translate-stop",(()=>{this._moveXYTooltipInfo=null,this._moveZTooltipInfo=null,this._tooltip.clear()})),this.on("graphic-rotate-start",(t=>{this._startAngle=t.angle,a()})),this.on("graphic-rotate",(t=>{this._endAngle=t.angle,a()})),this.on("graphic-rotate-stop",(()=>{this._startAngle=0,this._endAngle=0,a()})),this.on("graphic-scale-start",(t=>{m(this._startScale,t.xScale,t.yScale),m(this._endScale,t.xScale,t.yScale),a()})),this.on("graphic-scale",(t=>{m(this._endScale,t.xScale,t.yScale),a()})),this.on("graphic-scale-stop",(()=>{m(this._startScale,0,0),m(this._endScale,0,0),a()}))]),this._forEachManipulator((e=>{t.add([e.events.on("focus-changed",a),e.events.on("grab-changed",a),e.events.on("drag",(t=>{"cancel"===t.action?this._tooltip.clear():a()}))])}))}_getUpdatedTooltipInfo(){return this.tooltipOptions.enabled?this._graphicMoveManipulation.grabbing||this._graphicMoveManipulation.dragging?this._computeMoveXYTooltipInfo():this._moveZManipulator.focused?this._computeMoveZTooltipInfo():this._rotateManipulator.focused?this._computeRotateTooltipInfo():this._resizeManipulators.some((t=>t.focused))?this._computeScaleTooltipInfo():null:null}_computeMoveXYTooltipInfo(){return this._moveXYTooltipInfo??(this._moveXYTooltipInfo=new jt({tooltipOptions:this.tooltipOptions}))}_computeMoveZTooltipInfo(){const t=this._moveZTooltipInfo??(this._moveZTooltipInfo=new Gt({tooltipOptions:this.tooltipOptions})),e=this._moveUnit;if(this._moveZManipulator.dragging){const e=this._mapBoundsStart.origin,i=this._mapBounds.origin,a=wt(e,i,this.view.spatialReference);if(null==a)return null;t.distance=a}else t.distance=o(0,e);return t}_computeRotateTooltipInfo(){const t=this._rotateTooltipInfo??(this._rotateTooltipInfo=new Bt({tooltipOptions:this.tooltipOptions}));return t.angle=this._startAngle-this._endAngle,t}_computeScaleTooltipInfo(){const t=this.graphic.geometry;if(null==t)return null;const e=this._scaleTooltipInfo??(this._scaleTooltipInfo=new Ot({tooltipOptions:this.tooltipOptions})),i=Mt(this._mapBounds,this._zmax,t.spatialReference,this._graphicState.isDraped);return null==i?null:(e.xSize=i[0],e.ySize=i[1],null!=this._sizeStart&&this._resizeManipulators.some((t=>t.dragging))?(e.xScale=i[0].value/this._sizeStart[0].value,e.yScale=i[1].value/this._sizeStart[1].value):(e.xScale=1,e.yScale=1),e)}_graphicDrapedChanged(){this._handles.remove(zt),this._updateDisplayBounds(),this._graphicState.isDraped&&this._handles.add(this.view.elevationProvider.on("elevation-change",(t=>{null!=this._attachmentOrigin&&A(t.extent,this._attachmentOrigin.x,this._attachmentOrigin.y)&&this._updateDisplayBounds()})),zt)}_updateAllManipulatorAvailability(){this._forEachManipulator(((t,e)=>this._updateManipulatorAvailability(t,e)))}_updateManipulatorAvailability(t,e){const i=this.grabbing&&!t.grabbing;if(t.interactive=!i,t instanceof K){const a=this._graphicState.displaying,s=this.enableZ&&st(this.graphic);switch(e){case at.ROTATE:t.available=a&&this.enableRotation;break;case at.SCALE:t.available=a&&(this.enableScaling||this.enableRotation||s),t.interactive=!i&&this.enableScaling,t.state=this.enableScaling?X:Y;break;case at.TRANSLATE_Z:t.available=a&&s;break;default:t.available=a}}}_forEachManipulator(t){this._graphicMoveManipulation.forEachManipulator(t),this._resizeManipulators.forEach((e=>t(e,at.SCALE))),t(this._rotateManipulator,at.ROTATE),t(this._moveZManipulator,at.TRANSLATE_Z)}get preserveAspectRatio(){return this._preserveAspectRatio.enabled}set preserveAspectRatio(t){this._preserveAspectRatio.enabled=t,this._set("preserveAspectRatio",t)}get _moveUnit(){return l(this.view.spatialReference)??"meters"}reset(){}_onGeometryChanged(){this._updateDisplayBounds()}_calculateMapBounds(){const t=this.graphic.geometry,e=this._editGeometryOperations.data,i=e.components[0].edges[0],a=_(w.get(),i.leftVertex.pos,i.rightVertex.pos);g(a,a);const s=$(this.view,this.graphic)??t.extent?.center;let o=s?Ut*this.view.pixelSizeAt(s):0;const r=this.view.spatialReference,n=t.spatialReference;r.equals(n)||(o*=h(r)/h(n)),Tt(a,e,o,this._mapBounds),this._updateZMax()}_updateZMax(){const t=this._editGeometryOperations.data;if(!t.geometry.hasZ)return void(this._zmax=0);const e=t.coordinateHelper;let i=Number.NEGATIVE_INFINITY;for(const a of t.components)for(const t of a.vertices){const a=e.getZ(t.pos)??0;i=Math.max(a,i)}this._zmax=i}_updateDisplayBounds(){const{geometry:t}=this.graphic;if(null==t)return;const{extent:e}=t;if(!e)return;const i=null==this._outlineVisualElement||this._graphicState.isDraped||null==this._outlineVisualElement.attachmentOrigin?$(this.view,this.graphic):this._outlineVisualElement.attachmentOrigin;this._attachmentOrigin=i??e.center;const a=null!=i?i.z:ht(this._mapBounds.origin,this.view.elevationProvider,ct.fromElevationInfo(I(this.graphic)),this.view.renderCoordsHelper),s=O(this._mapBounds);s.origin[2]=a??0,bt(s,this.view.renderCoordsHelper,t.spatialReference,this._displayBoundsMargin,this._displayBounds),this._updateManipulators()}get _displayBoundsMargin(){const t=this.view.pointsOfInterest,e=t?t.centerOnSurfaceFrequent.location:this._editGeometryOperations.data.geometry.extent?.center;return e?It*this.view.pixelSizeAt(e):0}_createMoveXYGraphicDragPipeline(){return this._graphicMoveManipulation.createDragPipeline(((t,e,i)=>this._applyGraphicMoveSteps(e,i,rt.XY)))}_createMoveZDragPipeline(){const t=this.view,e=this._editGeometryOperations.data.spatialReference;return mt(this._moveZManipulator,((i,a,s)=>{const o=E(i.renderLocation),r=a.next(et(t,o,e)).next(gt());this._applyGraphicMoveSteps(r,s,rt.Z)}))}_applyGraphicMoveSteps(t,e,i){const a=t.next((t=>("start"===t.action&&(this.inputState={type:"move"},this._updateOperationStartProperties(),this.emit("graphic-translate-start",{graphic:this.graphic,dxScreen:t.screenDeltaX,dyScreen:t.screenDeltaY})),t))).next(_t()).next(this._moveDragUpdateGeometry()).next((t=>{const e={graphic:this.graphic,dxScreen:t.screenDeltaX,dyScreen:t.screenDeltaY};switch(t.action){case"start":case"update":(t.mapEnd.x-t.mapStart.x||t.mapEnd.y-t.mapStart.y||(t.mapEnd.z??0)-(t.mapStart.z??0))&&this.emit("graphic-translate",e);break;case"end":this.inputState=null,this.emit("graphic-translate-stop",e)}return t})).next((t=>this._updateMoveTooltip(t,i)));return e.next((()=>{null!=this.inputState&&this.emit("graphic-translate-stop",{graphic:this.graphic,dxScreen:0,dyScreen:0}),this._cancel()})),a}_updateOperationStartProperties(){O(this._displayBounds,this._displayBoundsStart),O(this._mapBounds,this._mapBoundsStart),null!=this.graphic.geometry?this._sizeStart=Mt(this._mapBoundsStart,this._zmax,this.graphic.geometry.spatialReference,this._graphicState.isDraped):this._sizeStart=null}_moveDragUpdateGeometry(){return t=>{if(null==this.inputState||"move"!==this.inputState.type)return t;const e=[];for(const s of this._editGeometryOperations.data.components)e.push(...s.vertices);const i="start"===t.action?ft.NEW_STEP:ft.ACCUMULATE_STEPS,a=this._editGeometryOperations.moveVertices(e,t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i);return xt(a,this._mapBounds),this.graphic.geometry=this._editGeometryOperations.data.geometry,t}}_updateMoveTooltip(t,e){if(e===rt.XY||e===rt.XY_AXIS){const e=Dt(t.mapStart,t.mapEnd,this._graphicState.isDraped?"on-the-ground":"absolute-height");null!=e&&null!=this._moveXYTooltipInfo&&(this._moveXYTooltipInfo.distance=e)}return t}_onResizeGrab({action:t,screenPoint:e}){if("start"!==t||!e)return;const i=this._calculatePickRay(e);R(this._displayBounds.plane,i,P.get())&&(this._updateOperationStartProperties(),this._displayBoundsMarginStart=this._displayBoundsMargin,this.inputState={type:"resize"})}_createResizeDragPipeline(t,e){return mt(t,((t,i,a)=>{null!=this.inputState&&(i.next((t=>("start"===t.action&&this.emit("graphic-scale-start",{graphic:this.graphic,xScale:1,yScale:1}),t))).next(it(this.view,this._displayBoundsStart.plane)).next((t=>({...t,handle:e}))).next(this._resizeDragRenderPlaneToFactors()).next(...this._preserveAspectRatio.createDragEventPipelineStep()).next(this._resizeDragUpdateGeometry()).next((t=>{const e={graphic:this.graphic,xScale:t.factor1,yScale:t.factor2};switch(t.action){case"start":case"update":this.emit("graphic-scale",e);break;case"end":this.inputState=null,this.emit("graphic-scale-stop",e)}return t})),a.next((()=>{null!=this.inputState&&this.emit("graphic-scale-stop",{graphic:this.graphic,xScale:1,yScale:1}),this._cancel()})))}))}_resizeDragRenderPlaneToFactors(){return t=>{const e=this._displayBoundsStart,i=t.handle.direction,a=this._displayBoundsMargin,s=this._displayBoundsMarginStart,o=y(P.get(),e.origin);f(o,o,e.basis1,-i[0]),f(o,o,e.basis2,-i[1]);const r=S(P.get(),t.renderEnd,o),n=S(P.get(),t.renderStart,o),p=L(t.handle),l=N(e),h=N(this._displayBounds)/l,c=(t,e)=>{if(0===t)return 1;let i=T(e),o=.5*t*b(e,r)/i;const l=o<0?-1:1;if(p){o+=(i-.5*t*b(e,n)/i)*l*h}const c=i<1.5*s?1:Zt;return i=Math.max(i-s,Zt),l>0&&(o-=a),l*Math.max(l*(o/i),c)};return{...t,factor1:c(i[0],e.basis1),factor2:c(i[1],e.basis2)}}}_resizeDragUpdateGeometry(){return t=>{const e=y(x(),this._mapBoundsStart.origin);f(e,e,this._mapBoundsStart.basis1,-t.handle.direction[0]),f(e,e,this._mapBoundsStart.basis2,-t.handle.direction[1]);const i=m(v(),this._mapBoundsStart.basis1[0],this._mapBoundsStart.basis1[1]);g(i,i);const a=[];for(const r of this._editGeometryOperations.data.components)a.push(...r.vertices);const s="start"===t.action?ft.NEW_STEP:ft.ACCUMULATE_STEPS,o=this._editGeometryOperations.scaleVertices(a,e,i,t.factor1,t.factor2,s,St.REPLACE);return O(this._mapBoundsStart,this._mapBounds),xt(o,this._mapBounds),this.graphic.geometry=this._editGeometryOperations.data.geometry,t}}_onRotateGrab({action:t,screenPoint:e}){if("start"!==t||!e)return;const i=V(this._displayBounds,this.view.renderCoordsHelper,H.HEADING,j()),a=this._calculatePickRay(e);R(i,a,P.get())&&(this._updateOperationStartProperties(),this.inputState={type:"rotate",rotatePlane:i})}_createRotateDragPipeline(t){return mt(t,((t,e,i)=>{const a=this.inputState;null!=a&&(e.next((t=>("start"===t.action&&this.emit("graphic-rotate-start",{graphic:this.graphic,angle:0}),t))).next(it(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdateGeometry()).next((t=>{const e={graphic:this.graphic,angle:s(t.rotateAngle)};switch(t.action){case"start":case"update":this.emit("graphic-rotate",e);break;case"end":this.inputState=null,this.emit("graphic-rotate-stop",e)}return t})),i.next((()=>{null!=this.inputState&&this.emit("graphic-rotate-stop",{graphic:this.graphic,angle:0}),this._cancel()})))}))}_rotateDragRenderPlaneToRotate(t){return e=>{const i=G(t.rotatePlane),a=tt(e.renderStart,e.renderEnd,this._displayBounds.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdateGeometry(){return t=>{const e=y(x(),this._mapBoundsStart.origin),i=[];for(const o of this._editGeometryOperations.data.components)i.push(...o.vertices);const a="start"===t.action?ft.NEW_STEP:ft.ACCUMULATE_STEPS,s=this._editGeometryOperations.rotateVertices(i,e,t.rotateAngle,a,St.REPLACE);return O(this._mapBoundsStart,this._mapBounds),xt(s,this._mapBounds),this.graphic.geometry=this._editGeometryOperations.data.geometry,t}}_calculatePickRay(t){const e=D(),i=p(t);return dt(this.view.state.camera,i,e),M(e.direction,e.direction),e}_updateManipulators(){if(!this.visible)return;const t=F(this._displayBounds,z.get());q(this._rotateManipulator,t,this._displayBounds,this.view.renderCoordsHelper),this._updateZMoveHandle(this._moveZManipulator,t),this._resizeManipulators.forEach(((e,i)=>{W(e,this._resizeHandles[i],t,this._displayBounds)}))}_updateZMoveHandle(t,e){const i=this._displayBounds,a={basis:i.basis1,direction:-1,position:S(P.get(),i.origin,i.basis1),edge:2},s=z.get();d(s,e,a.edge*Math.PI/2),s[12]=0,s[13]=0,s[14]=0,t.modelTransform=s,t.renderLocation=a.position}_cancel(){const t=this._editGeometryOperations.lastOperation;null!=t&&(this._editGeometryOperations.undo(),this.graphic.geometry=this._editGeometryOperations.data.geometry,Et(t,this._mapBounds),this._updateDisplayBounds(),this.inputState=null)}get canUndo(){return this._editGeometryOperations.canUndo}undo(){if(null!=this.inputState)this.view.activeTool=null;else if(this.canUndo){const t=this._editGeometryOperations.undo();this.graphic.geometry=this._editGeometryOperations.data.geometry,Et(t,this._mapBounds),this._updateDisplayBounds()}}get canRedo(){return this._editGeometryOperations.canRedo}redo(){if(this.canRedo){const t=this._editGeometryOperations.redo();this.graphic.geometry=this._editGeometryOperations.data.geometry,xt(t,this._mapBounds),this._updateDisplayBounds()}}get test(){return{resizeManipulators:this._resizeManipulators,rotateManipulator:this._rotateManipulator,moveZManipulator:this._moveZManipulator,tooltip:this._tooltip}}};t([c({constructOnly:!0,nonNullable:!0})],Pt.prototype,"view",void 0),t([c({constructOnly:!0,nonNullable:!0})],Pt.prototype,"graphic",void 0),t([c({constructOnly:!0,nonNullable:!0})],Pt.prototype,"enableZ",void 0),t([c()],Pt.prototype,"enableRotation",void 0),t([c()],Pt.prototype,"enableScaling",void 0),t([c({constructOnly:!0,type:At})],Pt.prototype,"tooltipOptions",void 0),t([c()],Pt.prototype,"preserveAspectRatio",null),t([c()],Pt.prototype,"grabbing",void 0),t([c()],Pt.prototype,"inputState",void 0),t([c({readOnly:!0})],Pt.prototype,"type",void 0),t([c()],Pt.prototype,"_moveUnit",null),Pt=t([u("esri.views.3d.interactive.editingTools.graphicTransform3D.ExtentTransformTool")],Pt);const zt="draped-elevation-changes",It=10,Ut=80,Zt=1e-6;export{Zt as EPSILON,Pt as ExtentTransformTool};
5
+ import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../Color.js";import i from"../../../../../core/Evented.js";import a from"../../../../../core/Handles.js";import{makeHandle as s}from"../../../../../core/handleUtils.js";import{rad2deg as o}from"../../../../../core/mathUtils.js";import{createLength as r}from"../../../../../core/quantityUtils.js";import{watch as n,initial as p}from"../../../../../core/reactiveUtils.js";import{screenPointObjectToArray as l}from"../../../../../core/screenUtils.js";import{lengthUnitFromSpatialReference as h,getMetersPerUnitForSR as c}from"../../../../../core/unitUtils.js";import{property as u}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as d}from"../../../../../core/accessorSupport/decorators/subclass.js";import{q as m}from"../../../../../chunks/mat4.js";import{s as _,a as g,f as v}from"../../../../../chunks/vec2.js";import{a as y}from"../../../../../chunks/vec2f64.js";import{c as f,A as S,b as M,n as T,l as b,e as x}from"../../../../../chunks/vec3.js";import{c as E,a as A}from"../../../../../chunks/vec3f64.js";import{containsXY as B}from"../../../../../geometry/support/aaBoundingRect.js";import{a as O,c as R}from"../../../../../chunks/boundedPlane.js";import{intersectRay as j,create as G,normal as D}from"../../../../../geometry/support/plane.js";import{create as w}from"../../../../../geometry/support/ray.js";import{sv2d as P,sv3d as z,sm4d as I}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as U}from"../../../../../support/elevationInfoUtils.js";import{createShiftManipulator as Z,OffsetMode as C,IsShiftEdgeOnScreenFlag as k,createResizeManipulator as X,resizeNormal as Y,resizeOutlineOnly as L,isDiagonalResizeHandle as N,calculateDiagonalResizeHandleScale as V,createRotatePlane as H,RotationAxis as F,calculateBoundedPlaneTranslateRotate as q,updateRotateHeadingHandle as W,updateResizeHandle as J}from"../../../analysis/Slice/sliceToolUtils.js";import{getRotateHeadingTexture as K}from"../../../analysis/Slice/images/Factory.js";import{Manipulator3D as Q}from"../../Manipulator3D.js";import{createRotateManipulator as $,getGraphicAttachmentOrigin as tt,calculateInputRotationTransform as et}from"../../manipulatorUtils.js";import{screenToZConstrained as it,screenToRenderPlane as at}from"../dragEventPipeline3D.js";import{ManipulatorType as st}from"../ManipulatorType.js";import{canMoveZ as ot}from"../manipulatorUtils.js";import{createVisualElements as rt}from"../visualElementUtils.js";import{ManipulationType as nt}from"../manipulations/MoveManipulation.js";import{MoveXYGraphicManipulation as pt}from"../manipulations/MoveXYGraphicManipulation.js";import{PreserveAspectRatio as lt}from"./PreserveAspectRatio.js";import{OutlineVisualElement as ht}from"../../visualElements/OutlineVisualElement.js";import{evaluateElevationAlignmentAtPoint as ct}from"../../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as ut}from"../../../layers/graphics/ElevationContext.js";import{GraphicState as dt}from"../../../layers/graphics/GraphicState.js";import{fromScreen as mt}from"../../../support/geometryUtils/ray.js";import{createManipulatorDragEventPipeline as _t,addMapDelta as gt,addScreenDelta as vt}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as yt}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as ft}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as St}from"../../../../interactive/editGeometry/interfaces.js";import{AccumulationType as Mt}from"../../../../interactive/editGeometry/operations/UpdateVertices.js";import{mapPlaneAutoHorizontalSizeByElevationMode as Tt,calculateOrientedBounds as bt,mapPlaneToRenderPlane as xt,apply as Et,unapply as At}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";import Bt from"../../../../interactive/sketch/SketchTooltipOptions.js";import{ExtentRotateTooltipInfo as Ot,ExtentScaleTooltipInfo as Rt}from"../../../../interactive/tooltip/ExtentTooltipInfos.js";import{Tooltip as jt}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as Gt,TranslateGraphicZTooltipInfo as Dt}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as wt}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistance as Pt}from"../../../../support/euclideanLengthMeasurementUtils.js";let zt=class extends(i.EventedMixin(yt)){constructor(t){super(t),this.enableZ=!0,this.enableRotation=!0,this.enableScaling=!0,this.tooltipOptions=new Bt,this._preserveAspectRatio=new lt,this.grabbing=!1,this.inputState=null,this.type="transform-3d",this._handles=new a,this._attachmentOrigin=null,this._outlineVisualElement=null,this._mapBounds=O(),this._mapBoundsStart=O(),this._zmax=0,this._sizeStart=null,this._displayBounds=O(),this._displayBoundsStart=O(),this._displayBoundsMarginStart=0,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._moveXYTooltipInfo=null,this._moveZTooltipInfo=null,this._rotateTooltipInfo=null,this._scaleTooltipInfo=null,this._startAngle=0,this._endAngle=0,this._startScale=y(),this._endScale=y()}initialize(){const{view:t,graphic:i,manipulators:a,_handles:o}=this,r=this._graphicState=new dt({graphic:i}),l=i.geometry;this._editGeometryOperations=ft.fromGeometry(l,t.state.viewingMode),this._graphicMoveManipulation=new pt({tool:this,view:t,graphicState:r}),this._moveZManipulator=Z(t,C.CENTER_ON_CALLOUT),this._moveZManipulator.state|=k,o.add([this._createMoveXYGraphicDragPipeline(),n((()=>this.enableZ),(()=>this._updateManipulatorAvailability(this._moveZManipulator,st.TRANSLATE_Z))),this._createMoveZDragPipeline()]),a.add(this._moveZManipulator),this._resizeManipulators=this._resizeHandles.map((e=>{const i=X(t,e);return o.add([n((()=>this.enableScaling),(()=>this._updateManipulatorAvailability(i,st.SCALE))),i.events.on("grab-changed",(t=>this._onResizeGrab(t))),this._createResizeDragPipeline(i,e)]),i})),a.addMany(this._resizeManipulators);const h=!this.view._stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this._rotateManipulatorTexture=K(t.toolViewManager.textures,{accentColor:new e([255,127,0,.5]),contrastColor:new e([255,255,255,1]),preMultiplyAlpha:h}),this._rotateManipulator=$(t,{texture:this._rotateManipulatorTexture.texture}),o.add([n((()=>this.enableRotation),(()=>this._updateManipulatorAvailability(this._rotateManipulator,st.ROTATE))),this._rotateManipulator.events.on("grab-changed",(t=>{this._onRotateGrab(t)})),this._createRotateDragPipeline(this._rotateManipulator)]),a.add(this._rotateManipulator),this._calculateMapBounds(),this._updateDisplayBounds();const c=rt({view:t,graphic:i,forEachManipulator:t=>this._forEachManipulator(t),onManipulatorsChanged:()=>s()});null!=c&&(this._outlineVisualElement=c.visualElement instanceof ht?c.visualElement:null),null!=this._outlineVisualElement&&o.add(this._outlineVisualElement.events.on("attachment-origin-changed",(()=>this._updateDisplayBounds()))),o.add(c),o.add([r.on("changed",(()=>this._onGeometryChanged())),n((()=>r.displaying),(()=>this._updateAllManipulatorAvailability())),n((()=>r.isDraped),(()=>this._graphicDrapedChanged()),p),t.trackGraphicState(r)]);const u=t.pointsOfInterest;o.add(n((()=>u?.centerOnSurfaceFrequent.location),(()=>this._updateDisplayBounds())));const d=t=>{o.add(t.events.on("grab-changed",(()=>{this.grabbing=t.grabbing,this._updateAllManipulatorAvailability()})))};this._forEachManipulator(d);const m=(t,e)=>{o.add(t.events.on("immediate-click",(t=>{e===st.TRANSLATE_XY&&this.emit("immediate-click",{...t,graphic:i}),t.stopPropagation()})))};this._forEachManipulator(m),this._onGeometryChanged(),this._updateAllManipulatorAvailability(),this._initializeTooltip(),this.finishToolCreation()}destroy(){this._mapBounds=null,this._displayBounds=null,this._rotateManipulatorTexture.release(),this._handles.destroy(),this._graphicMoveManipulation.destroy(),this._editGeometryOperations.destroy(),this._tooltip.destroy(),this._set("view",null),this._set("graphic",null)}_initializeTooltip(){const{_handles:t,view:e}=this,i=this._tooltip=new jt({view:e}),a=()=>{i.info=this._getUpdatedTooltipInfo()};t.add([this.on("graphic-translate-start",a),this.on("graphic-translate",a),this.on("graphic-translate-stop",(()=>{this._moveXYTooltipInfo=null,this._moveZTooltipInfo=null,this._tooltip.clear()})),this.on("graphic-rotate-start",(t=>{this._startAngle=t.angle,a()})),this.on("graphic-rotate",(t=>{this._endAngle=t.angle,a()})),this.on("graphic-rotate-stop",(()=>{this._startAngle=0,this._endAngle=0,a()})),this.on("graphic-scale-start",(t=>{_(this._startScale,t.xScale,t.yScale),_(this._endScale,t.xScale,t.yScale),a()})),this.on("graphic-scale",(t=>{_(this._endScale,t.xScale,t.yScale),a()})),this.on("graphic-scale-stop",(()=>{_(this._startScale,0,0),_(this._endScale,0,0),a()}))]),this._forEachManipulator((e=>{t.add([e.events.on("focus-changed",a),e.events.on("grab-changed",a),e.events.on("drag",(t=>{"cancel"===t.action?this._tooltip.clear():a()}))])}))}_getUpdatedTooltipInfo(){return this.tooltipOptions.enabled?this._graphicMoveManipulation.grabbing||this._graphicMoveManipulation.dragging?this._computeMoveXYTooltipInfo():this._moveZManipulator.focused?this._computeMoveZTooltipInfo():this._rotateManipulator.focused?this._computeRotateTooltipInfo():this._resizeManipulators.some((t=>t.focused))?this._computeScaleTooltipInfo():null:null}_computeMoveXYTooltipInfo(){return this._moveXYTooltipInfo??(this._moveXYTooltipInfo=new Gt({tooltipOptions:this.tooltipOptions}))}_computeMoveZTooltipInfo(){const t=this._moveZTooltipInfo??(this._moveZTooltipInfo=new Dt({tooltipOptions:this.tooltipOptions})),e=this._moveUnit;if(this._moveZManipulator.dragging){const e=this._mapBoundsStart.origin,i=this._mapBounds.origin,a=Pt(e,i,this.view.spatialReference);if(null==a)return null;t.distance=a}else t.distance=r(0,e);return t}_computeRotateTooltipInfo(){const t=this._rotateTooltipInfo??(this._rotateTooltipInfo=new Ot({tooltipOptions:this.tooltipOptions}));return t.angle=this._startAngle-this._endAngle,t}_computeScaleTooltipInfo(){const t=this.graphic.geometry;if(null==t)return null;const e=this._scaleTooltipInfo??(this._scaleTooltipInfo=new Rt({tooltipOptions:this.tooltipOptions})),i=Tt(this._mapBounds,this._zmax,t.spatialReference,this._graphicState.isDraped);return null==i?null:(e.xSize=i[0],e.ySize=i[1],null!=this._sizeStart&&this._resizeManipulators.some((t=>t.dragging))?(e.xScale=i[0].value/this._sizeStart[0].value,e.yScale=i[1].value/this._sizeStart[1].value):(e.xScale=1,e.yScale=1),e)}_graphicDrapedChanged(){this._handles.remove(It),this._updateDisplayBounds(),this._graphicState.isDraped&&this._handles.add(this.view.elevationProvider.on("elevation-change",(t=>{null!=this._attachmentOrigin&&B(t.extent,this._attachmentOrigin.x,this._attachmentOrigin.y)&&this._updateDisplayBounds()})),It)}_updateAllManipulatorAvailability(){this._forEachManipulator(((t,e)=>this._updateManipulatorAvailability(t,e)))}_updateManipulatorAvailability(t,e){const i=this.grabbing&&!t.grabbing;if(t.interactive=!i,t instanceof Q){const a=this._graphicState.displaying,s=this.enableZ&&ot(this.graphic);switch(e){case st.ROTATE:t.available=a&&this.enableRotation;break;case st.SCALE:t.available=a&&(this.enableScaling||this.enableRotation||s),t.interactive=!i&&this.enableScaling,t.state=this.enableScaling?Y:L;break;case st.TRANSLATE_Z:t.available=a&&s;break;default:t.available=a}}}_forEachManipulator(t){this._graphicMoveManipulation.forEachManipulator(t),this._resizeManipulators.forEach((e=>t(e,st.SCALE))),t(this._rotateManipulator,st.ROTATE),t(this._moveZManipulator,st.TRANSLATE_Z)}get preserveAspectRatio(){return this._preserveAspectRatio.enabled}set preserveAspectRatio(t){this._preserveAspectRatio.enabled=t,this._set("preserveAspectRatio",t)}get _moveUnit(){return h(this.view.spatialReference)??"meters"}reset(){}_onGeometryChanged(){this._updateDisplayBounds()}_calculateMapBounds(){const t=this.graphic.geometry,e=this._editGeometryOperations.data,i=e.components[0].edges[0],a=g(P.get(),i.leftVertex.pos,i.rightVertex.pos);v(a,a);const s=tt(this.view,this.graphic)??t.extent?.center;let o=s?Zt*this.view.pixelSizeAt(s):0;const r=this.view.spatialReference,n=t.spatialReference;r.equals(n)||(o*=c(r)/c(n)),bt(a,e,o,this._mapBounds),this._updateZMax()}_updateZMax(){const t=this._editGeometryOperations.data;if(!t.geometry.hasZ)return void(this._zmax=0);const e=t.coordinateHelper;let i=Number.NEGATIVE_INFINITY;for(const a of t.components)for(const t of a.vertices){const a=e.getZ(t.pos)??0;i=Math.max(a,i)}this._zmax=i}_updateDisplayBounds(){const{geometry:t}=this.graphic;if(null==t)return;const{extent:e}=t;if(!e)return;const i=null==this._outlineVisualElement||this._graphicState.isDraped||null==this._outlineVisualElement.attachmentOrigin?tt(this.view,this.graphic):this._outlineVisualElement.attachmentOrigin;this._attachmentOrigin=i??e.center;const a=null!=i?i.z:ct(this._mapBounds.origin,this.view.elevationProvider,ut.fromElevationInfo(U(this.graphic)),this.view.renderCoordsHelper),s=R(this._mapBounds);s.origin[2]=a??0,xt(s,this.view.renderCoordsHelper,t.spatialReference,this._displayBoundsMargin,this._displayBounds),this._updateManipulators()}get _displayBoundsMargin(){const t=this.view.pointsOfInterest,e=t?t.centerOnSurfaceFrequent.location:this._editGeometryOperations.data.geometry.extent?.center;return e?Ut*this.view.pixelSizeAt(e):0}_createMoveXYGraphicDragPipeline(){return this._graphicMoveManipulation.createDragPipeline(((t,e,i)=>this._applyGraphicMoveSteps(e,i,nt.XY)))}_createMoveZDragPipeline(){const t=this.view,e=this._editGeometryOperations.data.spatialReference;return _t(this._moveZManipulator,((i,a,s)=>{const o=A(i.renderLocation),r=a.next(it(t,o,e)).next(vt());this._applyGraphicMoveSteps(r,s,nt.Z)}))}_applyGraphicMoveSteps(t,e,i){const a=t.next((t=>("start"===t.action&&(this.inputState={type:"move"},this._updateOperationStartProperties(),this.emit("graphic-translate-start",{graphic:this.graphic,dxScreen:t.screenDeltaX,dyScreen:t.screenDeltaY})),t))).next(gt()).next(this._moveDragUpdateGeometry()).next((t=>{const e={graphic:this.graphic,dxScreen:t.screenDeltaX,dyScreen:t.screenDeltaY};switch(t.action){case"start":case"update":(t.mapEnd.x-t.mapStart.x||t.mapEnd.y-t.mapStart.y||(t.mapEnd.z??0)-(t.mapStart.z??0))&&this.emit("graphic-translate",e);break;case"end":this.inputState=null,this.emit("graphic-translate-stop",e)}return t})).next((t=>this._updateMoveTooltip(t,i)));return e.next((()=>{null!=this.inputState&&this.emit("graphic-translate-stop",{graphic:this.graphic,dxScreen:0,dyScreen:0}),this._cancel()})),a}_updateOperationStartProperties(){R(this._displayBounds,this._displayBoundsStart),R(this._mapBounds,this._mapBoundsStart),null!=this.graphic.geometry?this._sizeStart=Tt(this._mapBoundsStart,this._zmax,this.graphic.geometry.spatialReference,this._graphicState.isDraped):this._sizeStart=null}_moveDragUpdateGeometry(){return t=>{if(null==this.inputState||"move"!==this.inputState.type)return t;const e=[];for(const s of this._editGeometryOperations.data.components)e.push(...s.vertices);const i="start"===t.action?St.NEW_STEP:St.ACCUMULATE_STEPS,a=this._editGeometryOperations.moveVertices(e,t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i);return Et(a,this._mapBounds),this.graphic.geometry=this._editGeometryOperations.data.geometry,t}}_updateMoveTooltip(t,e){if(e===nt.XY||e===nt.XY_AXIS){const e=wt(t.mapStart,t.mapEnd,this._graphicState.isDraped?"on-the-ground":"absolute-height");null!=e&&null!=this._moveXYTooltipInfo&&(this._moveXYTooltipInfo.distance=e)}return t}_onResizeGrab({action:t,screenPoint:e}){if("start"!==t||!e)return;const i=this._calculatePickRay(e);j(this._displayBounds.plane,i,z.get())&&(this._updateOperationStartProperties(),this._displayBoundsMarginStart=this._displayBoundsMargin,this.inputState={type:"resize"})}_createResizeDragPipeline(t,e){return _t(t,((t,i,a)=>{null!=this.inputState&&(i.next((t=>("start"===t.action&&this.emit("graphic-scale-start",{graphic:this.graphic,xScale:1,yScale:1}),t))).next(at(this.view,this._displayBoundsStart.plane)).next((t=>({...t,handle:e}))).next(this._resizeDragRenderPlaneToFactors()).next(...this._preserveAspectRatio.createDragEventPipelineStep()).next(this._resizeDragUpdateGeometry()).next((t=>{const e={graphic:this.graphic,xScale:t.factor1,yScale:t.factor2};switch(t.action){case"start":case"update":this.emit("graphic-scale",e);break;case"end":this.inputState=null,this.emit("graphic-scale-stop",e)}return t})),a.next((()=>{null!=this.inputState&&this.emit("graphic-scale-stop",{graphic:this.graphic,xScale:1,yScale:1}),this._cancel()})))}))}_resizeDragRenderPlaneToFactors(){return t=>{const e=this._displayBoundsStart,i=t.handle.direction,a=this._displayBoundsMargin,s=this._displayBoundsMarginStart,o=f(z.get(),e.origin);S(o,o,e.basis1,-i[0]),S(o,o,e.basis2,-i[1]);const r=M(z.get(),t.renderEnd,o),n=M(z.get(),t.renderStart,o),p=N(t.handle),l=V(e),h=V(this._displayBounds)/l,c=(t,e)=>{if(0===t)return 1;let i=b(e),o=.5*t*x(e,r)/i;const l=o<0?-1:1;if(p){o+=(i-.5*t*x(e,n)/i)*l*h}const c=i<1.5*s?1:Ct;return i=Math.max(i-s,Ct),l>0&&(o-=a),l*Math.max(l*(o/i),c)};return{...t,factor1:c(i[0],e.basis1),factor2:c(i[1],e.basis2)}}}_resizeDragUpdateGeometry(){return t=>{const e=f(E(),this._mapBoundsStart.origin);S(e,e,this._mapBoundsStart.basis1,-t.handle.direction[0]),S(e,e,this._mapBoundsStart.basis2,-t.handle.direction[1]);const i=_(y(),this._mapBoundsStart.basis1[0],this._mapBoundsStart.basis1[1]);v(i,i);const a=[];for(const r of this._editGeometryOperations.data.components)a.push(...r.vertices);const s="start"===t.action?St.NEW_STEP:St.ACCUMULATE_STEPS,o=this._editGeometryOperations.scaleVertices(a,e,i,t.factor1,t.factor2,s,Mt.REPLACE);return R(this._mapBoundsStart,this._mapBounds),Et(o,this._mapBounds),this.graphic.geometry=this._editGeometryOperations.data.geometry,t}}_onRotateGrab({action:t,screenPoint:e}){if("start"!==t||!e)return;const i=H(this._displayBounds,this.view.renderCoordsHelper,F.HEADING,G()),a=this._calculatePickRay(e);j(i,a,z.get())&&(this._updateOperationStartProperties(),this.inputState={type:"rotate",rotatePlane:i})}_createRotateDragPipeline(t){return _t(t,((t,e,i)=>{const a=this.inputState;null!=a&&(e.next((t=>("start"===t.action&&this.emit("graphic-rotate-start",{graphic:this.graphic,angle:0}),t))).next(at(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdateGeometry()).next((t=>{const e={graphic:this.graphic,angle:o(t.rotateAngle)};switch(t.action){case"start":case"update":this.emit("graphic-rotate",e);break;case"end":this.inputState=null,this.emit("graphic-rotate-stop",e)}return t})),i.next((()=>{null!=this.inputState&&this.emit("graphic-rotate-stop",{graphic:this.graphic,angle:0}),this._cancel()})))}))}_rotateDragRenderPlaneToRotate(t){return e=>{const i=D(t.rotatePlane),a=et(e.renderStart,e.renderEnd,this._displayBounds.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdateGeometry(){return t=>{const e=f(E(),this._mapBoundsStart.origin),i=[];for(const o of this._editGeometryOperations.data.components)i.push(...o.vertices);const a="start"===t.action?St.NEW_STEP:St.ACCUMULATE_STEPS,s=this._editGeometryOperations.rotateVertices(i,e,t.rotateAngle,a,Mt.REPLACE);return R(this._mapBoundsStart,this._mapBounds),Et(s,this._mapBounds),this.graphic.geometry=this._editGeometryOperations.data.geometry,t}}_calculatePickRay(t){const e=w(),i=l(t);return mt(this.view.state.camera,i,e),T(e.direction,e.direction),e}_updateManipulators(){if(!this.visible)return;const t=q(this._displayBounds,I.get());W(this._rotateManipulator,t,this._displayBounds,this.view.renderCoordsHelper),this._updateZMoveHandle(this._moveZManipulator,t),this._resizeManipulators.forEach(((e,i)=>{J(e,this._resizeHandles[i],t,this._displayBounds)}))}_updateZMoveHandle(t,e){const i=this._displayBounds,a={basis:i.basis1,direction:-1,position:M(z.get(),i.origin,i.basis1),edge:2},s=I.get();m(s,e,a.edge*Math.PI/2),s[12]=0,s[13]=0,s[14]=0,t.modelTransform=s,t.renderLocation=a.position}_cancel(){const t=this._editGeometryOperations.lastOperation;null!=t&&(this._editGeometryOperations.undo(),this.graphic.geometry=this._editGeometryOperations.data.geometry,At(t,this._mapBounds),this._updateDisplayBounds(),this.inputState=null)}get canUndo(){return this._editGeometryOperations.canUndo}undo(){if(null!=this.inputState)this.view.activeTool=null;else if(this.canUndo){const t=this._editGeometryOperations.undo();this.graphic.geometry=this._editGeometryOperations.data.geometry,At(t,this._mapBounds),this._updateDisplayBounds()}}get canRedo(){return this._editGeometryOperations.canRedo}redo(){if(this.canRedo){const t=this._editGeometryOperations.redo();this.graphic.geometry=this._editGeometryOperations.data.geometry,Et(t,this._mapBounds),this._updateDisplayBounds()}}get test(){return{resizeManipulators:this._resizeManipulators,rotateManipulator:this._rotateManipulator,moveZManipulator:this._moveZManipulator,tooltip:this._tooltip}}};t([u({constructOnly:!0,nonNullable:!0})],zt.prototype,"view",void 0),t([u({constructOnly:!0,nonNullable:!0})],zt.prototype,"graphic",void 0),t([u({constructOnly:!0,nonNullable:!0})],zt.prototype,"enableZ",void 0),t([u()],zt.prototype,"enableRotation",void 0),t([u()],zt.prototype,"enableScaling",void 0),t([u({constructOnly:!0,type:Bt})],zt.prototype,"tooltipOptions",void 0),t([u()],zt.prototype,"preserveAspectRatio",null),t([u()],zt.prototype,"grabbing",void 0),t([u()],zt.prototype,"inputState",void 0),t([u({readOnly:!0})],zt.prototype,"type",void 0),t([u()],zt.prototype,"_moveUnit",null),zt=t([d("esri.views.3d.interactive.editingTools.graphicTransform3D.ExtentTransformTool")],zt);const It="draped-elevation-changes",Ut=10,Zt=80,Ct=1e-6;export{Ct as EPSILON,zt as ExtentTransformTool};