@arcgis/core 5.2.0-next.50 → 5.2.0-next.52

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 (58) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{de50a19944617cd426b8.js → 0ffd0190adfed8e5937a.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{877c848beaf9a939862c.js → 290fbc6d32c799841ccc.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{851bcc75acac4a2f199b.js → 2d6d2d4df05bba9fa4a6.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{304a22c580ce103480cb.js → 2fbb00a29faeaa02912b.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{9d0a9d465ec3a8ba1ed2.js → 5d6d07ecebf881ad913f.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{0037a878499d8a512772.js → 61d3fcb419d6bf7e355e.js} +38 -19
  8. package/assets/esri/core/workers/chunks/{cdb331b58e22f8c1c988.js → 77f19d204a4673b1e676.js} +2 -2
  9. package/assets/esri/core/workers/chunks/{1bc45872d22d61dbd7d1.js → 7e2bf6dd26c3cf0b49b0.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{baac90da0703891d59c4.js → 847ce06b14a921cd16f0.js} +1 -1
  11. package/assets/esri/core/workers/chunks/a1fcef22b6151a7f7917.js +1 -0
  12. package/assets/esri/core/workers/chunks/{0ea374f7b16745b9bbc7.js → a239f1e82dde4f7ada32.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{47af3525396f890f2a6b.js → c38992b250731137cb1a.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{5ec8b02e097cf6718462.js → ce719d3aec8b52bfe160.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{b0b37c67a14a4dfb6538.js → cef7f4237539574f0730.js} +1 -1
  16. package/chunks/CutFillMinMaxDepth.glsl.js +1 -1
  17. package/chunks/CutFillReduction.glsl.js +5 -14
  18. package/chunks/CutFillTotalDepth.glsl.js +1 -1
  19. package/chunks/GlobalIllumination.glsl.js +41 -30
  20. package/chunks/GlobalIlluminationBlur.glsl.js +19 -11
  21. package/chunks/GlobalIlluminationUpscale.glsl.js +10 -10
  22. package/chunks/GlowBlur.glsl.js +1 -1
  23. package/chunks/GlowComposite.glsl.js +1 -1
  24. package/chunks/Stars.glsl.js +7 -12
  25. package/config.js +1 -1
  26. package/core/types.d.ts +5 -1
  27. package/kernel.js +1 -1
  28. package/package.json +3 -3
  29. package/rest/networks/support/TraverseAssociationsParameters.d.ts +26 -4
  30. package/support/revision.js +1 -1
  31. package/third-party-notices.txt +0 -66
  32. package/views/3d/analysis/LineOfSight/LineOfSightAuthoringUtils.js +1 -1
  33. package/views/3d/analysis/LineOfSight/LineOfSightPlacementController.js +1 -1
  34. package/views/3d/analysis/LineOfSight/LineOfSightRootPlugin.js +1 -1
  35. package/views/3d/analysis/LineOfSight/LineOfSightTargetPlugin.js +1 -1
  36. package/views/3d/analysis/LineOfSight/LineOfSightTool2.js +1 -1
  37. package/views/3d/analysis/LineOfSight/types.d.ts +28 -0
  38. package/views/3d/analysis/LineOfSightAnalysisView3D.d.ts +7 -7
  39. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  40. package/views/3d/interactive/editingTools/manipulations/Manipulation.js +1 -1
  41. package/views/3d/interactive/editingTools/manipulations/MoveManipulation.js +1 -1
  42. package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
  43. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  44. package/views/3d/interactive/editingTools/transform/ExtentTransformTool.js +1 -1
  45. package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
  46. package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
  47. package/views/3d/support/hitTest.js +1 -1
  48. package/views/3d/webgl-engine/core/FBOCacheFormats.js +1 -1
  49. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  50. package/views/3d/webgl-engine/lib/CutFillComputation.js +1 -1
  51. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  52. package/views/3d/webgl-engine/shaders/CutFillReductionTechniqueConfiguration.js +1 -1
  53. package/views/SceneView.d.ts +24 -12
  54. package/views/SceneView.js +1 -1
  55. package/widgets/LineOfSight/LineOfSightViewModel.js +1 -1
  56. package/widgets/support/AnalysisViewModelMixin.js +1 -1
  57. package/assets/esri/core/workers/chunks/5ce168ae45ab7e7a71d1.js +0 -1
  58. /package/assets/esri/core/workers/chunks/{cdb331b58e22f8c1c988.js.LICENSE.txt → 77f19d204a4673b1e676.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as i}from"../../../../../core/arrayUtils.js";import{EventEmitter as n}from"../../../../../core/Evented.js";import a from"../../../../../core/Handles.js";import{handlesGroup as o,makeHandle as s,destroyHandle as r}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as l,removeMaybe as p}from"../../../../../core/maybe.js";import{watch as d,initial as h,on as u,syncAndInitial as c,when as m,sync as f}from"../../../../../core/reactiveUtils.js";import{property as g,subclass as _}from"../../../../../core/accessorSupport/decorators.js";import{IDENTITY as v}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{length as M,subtract as b,lerp as x,set as y,add as O,scale as j}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as E,create as I}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as S}from"../../../../../core/support/UpdatingHandles.js";import H from"../../../../../geometry/Point.js";import w from"../../../../../geometry/Polyline.js";import{projectPoint as V}from"../../../../../geometry/projectionUtils.js";import T from"../../../../../geometry/SpatialReference.js";import{makeDehydratedPoint as D}from"../../../../../layers/graphics/dehydratedPoint.js";import{getZForElevationMode as A}from"../../../../../support/elevationInfoUtils.js";import{isVolumetricSymbol as G}from"../../../../../symbols/support/utils.js";import{Manipulator3D as P}from"../../Manipulator3D.js";import{createManipulatorMaterial as k,createManipulatorOutlineMaterial as C,placeAtObject as U}from"../../manipulatorUtils.js";import{RenderObject as R}from"../../RenderObject.js";import{SegmentLabels3D as L}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as z}from"../../SnappingVisualizer3D.js";import{screenToMapXYAtLocation as F,screenToRenderPlaneFromEvent as B,convertToMapCoordinates as Z}from"../dragEventPipeline3D.js";import{orientation as W}from"../geometryUtils.js";import{canMoveZOperations as N}from"../manipulatorUtils.js";import{Settings as q}from"../settings.js";import{createVisualElements as X}from"../visualElementUtils.js";import{discRadiusSmall as Y}from"../manipulations/config.js";import{MoveManipulation as K}from"../manipulations/MoveManipulation.js";import{MoveXYObjectManipulation as J}from"../manipulations/MoveXYObjectManipulation.js";import{getMapPointAtEdgeOffsetManipulatorElevation as Q,createEdgeOffsetIntersectionPlane as $,createEdgeOffsetOperation as ee,edgeOffsetRotationMatrix as te,screenEdgeLengthSquared as ie,getDistanceInGeometrySR as ne}from"./edgeOffsetUtils.js";import{createTooltipInfos as ae,connectTooltipToManipulatedObject as oe,getUpdatedTranslateObjectTooltipInfo as se,getUpdatedEdgeOffsetTooltipInfo as re}from"./reshapeTooltipUtils3D.js";import{OutlineVisualElement as le}from"../../visualElements/OutlineVisualElement.js";import{createElevationUpdateHandle as pe}from"../../../support/elevationUpdateUtils.js";import{createExtrudedTriangle as de,createSphereGeometry as he}from"../../../webgl-engine/lib/GeometryUtil.js";import{mouseButtons as ue}from"../../../../input/mouseButtons.js";import{sceneSnappingAtLocation as ce,addMapDelta as me,createManipulatorDragEventPipeline as fe,dragAtLocation as ge,addScreenDelta as _e}from"../../../../interactive/dragEventPipeline.js";import{tooltipKeys as ve}from"../../../../interactive/keybindings.js";import{SnappingContext as Me}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as be}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as xe,enterInputModeIfAvailable as ye}from"../../../../interactive/tooltip/tooltipCommonUtils.js";import{GeometryWorkerHandle as Oe}from"../../../../support/GeometryWorkerHandle.js";const je=Symbol(),Ee=Symbol();let Ie=class extends t{get _operations(){return this.object.operations}constructor(e){super(e),this._selectedIndex=0,this._manipulatorHandles=new a,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=0,this._pendingEdgeOffsetInfo=null,this._updatingHandles=new S,this._recreatingManipulators=!1,this._settings=new q({getTheme:()=>this.view.effectiveTheme}),this.events=new n,this.activeTooltipInfo=null,this._measurementWorker=new Oe({preloadGeodetic:!0}),this._vertexLaserLineVisualElement=null,this._tooltipCallbacks={onBeforeReshape:()=>this.tool.endDrag(),onReshapeStart:()=>this._updateEventState(2),onReshape:()=>this.events.emit("reshape",{type:"reshape",object:this.object}),onReshapeStop:()=>this._updateEventState(0,{forceEnd:!0}),onMoveStart:()=>this._updateEventState(1),onMove:()=>this.events.emit("move",{type:"move",object:this.object,dx:0,dy:0}),onMoveStop:()=>this._updateEventState(0,{forceEnd:!0})}}initialize(){const{view:e}=this,t=this._settings.manipulators,i=t.vertex;this.tooltipInfos=ae(this._sketchOptions,e),this._vertexManipulatorMaterial=k(i.color.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorOutlineMaterial=C(i.outlineColor.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=C(i.hoverOutlineColor.toUnitRGBA(),i.renderOccluded);const n=t.edge;this._edgeManipulatorMaterial=k(n.color.toUnitRGBA(),n.renderOccluded),this._edgeManipulatorOutlineMaterial=C(n.outlineColor.toUnitRGBA(),n.renderOccluded);const a=t.edgeOffset;this._edgeOffsetManipulatorMaterial=k(a.color.toUnitRGBA(),a.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=k(a.hoverColor.toUnitRGBA(),a.renderOccluded,!1);const o=t.selected;this._selectedManipulatorMaterial=k(o.color.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorOutlineMaterial=C(o.outlineColor.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=C(o.hoverOutlineColor.toUnitRGBA(),o.renderOccluded),this.tooltip=xe(()=>({view:e,options:this._sketchOptions.tooltips})),this.addHandles([d(()=>{const e=this._settings.manipulators;return{vertexSettings:e.vertex,edgeSettings:e.edge,edgeOffsetSettings:e.edgeOffset,selectedSettings:e.selected}},({vertexSettings:e,edgeSettings:t,edgeOffsetSettings:i,selectedSettings:n})=>{e.applyColor(this._vertexManipulatorMaterial),e.applyOutline(this._vertexManipulatorOutlineMaterial),e.applyHoverOutline(this._vertexManipulatorHoverOutlineMaterial),t.applyColor(this._edgeManipulatorMaterial),t.applyOutline(this._edgeManipulatorOutlineMaterial),i.applyColor(this._edgeOffsetManipulatorMaterial),i.applyHover(this._edgeOffsetManipulatorHoverMaterial),n.applyColor(this._selectedManipulatorMaterial),n.applyOutline(this._selectedManipulatorOutlineMaterial),n.applyHoverOutline(this._selectedManipulatorHoverOutlineMaterial)}),d(()=>this.object.visible,e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e,Te(t)&&(t.edgeManipulator.available=e)}),d(()=>this._numGrabbing+this._numDragging===0,e=>this._toggleAutoHideManipulators(e)),d(()=>({labels:this._segmentLabels,enabled:this._sketchOptions.labels.enabled,edgeOffsetEnabled:this.enableEdgeOffset}),({labels:e,enabled:t,edgeOffsetEnabled:i})=>{null!=e&&(e.visible=t,e.edgeDistance=i?"far":"default")},h),oe(this.tooltip,this.object,()=>this._tooltipsContext,this._updatingHandles),d(()=>this.tooltip.mode,(e,t)=>{"input"===t&&"input"!==e&&this._resetTooltip()}),u(()=>this._operations,"vertex-update",e=>this._updateManipulatorPositions(e.vertices),{onListenerAdd:()=>this._recreateManipulators()}),u(()=>this._operations?.data,"change",e=>{"undo"!==e.operation&&"redo"!==e.operation||this._recreateManipulators()})])}destroy(){this._removeManipulators(),this._updatingHandles.destroy(),this._segmentLabels=l(this._segmentLabels),this.tooltip=l(this.tooltip),this._measurementWorker.destroy()}get updating(){return this._updatingHandles.updating||!!this._segmentLabels?.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get object(){return this.tool.object}get enableZShape(){return this.tool.enableZShape}get enableDeleteVertices(){return this.tool.enableDeleteVertices}get enableZVertex(){return this.tool.enableZVertex}get autoHideManipulators(){return this.tool.autoHideManipulators}get enableMoveObject(){return this.tool.enableMoveObject}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get _sketchOptions(){return this.tool.sketchOptions}get _accentColor(){return this.view.effectiveTheme.accentColor}enterInputModeIfAvailable(e){return"key-down"===e.type&&e.key===ve.enterInputMode&&("reshape-edge-offset"===this.activeTooltipInfo?.type?this._enterInputModeDuringEdgeOffset(e):!!ye(e,this.tooltip)&&(this.tool.endDrag(),!0))}removeSelectedVertices(){const e=this._manipulatorInfos.filter(e=>e.manipulator.selected&&"vertex"===e.type);return this._removeVertices(e),e.length}onManipulatorSelectionChanged(){this.events.emit("manipulators-changed")}clearSelection(){let e=!1;for(const t of this._manipulatorInfos)if(t.manipulator.selected){e=!0;break}e&&(this._clearSelection(),this._updateMoveManipulationPosition(),this.events.emit("manipulators-changed"))}selectManipulator(e){if(null==this._manipulatorInfos.find(t=>t.manipulator===e)||!e.selectable)return!1;let t=e.selected;for(const i of this._manipulatorInfos)if(i.manipulator!==e&&i.manipulator.selected){t=!1;break}return t||(this._clearSelection(),e.selected=!0,this._updateMoveManipulationPosition(),this.events.emit("manipulators-changed")),!0}_removeManipulators(){this._manipulatorHandles.removeAll(),this._moveManipulation=l(this._moveManipulation),this._objectMoveManipulation=l(this._objectMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(e){if(null==this._operations)return;const t=this.object.elevationInfo;for(const{vertices:i,segments:n,index:a}of this._operations.data.parts){const o=e?.byPartIndex.get(a);for(const e of i){const i=o?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of n)"line"===e.type&&this._createVertexOrEdgeManipulator(e,t)}this._createObjectMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}recordUndo(e){this._operations?.recordUndo(e,!0)}get canRedo(){return this._operations?.canRedo??!1}get canUndo(){return this._operations?.canUndo??!1}redo(){return this._operations?.redo()}undo(){return this.events.emit("undo"),this._operations?.undo()}_recreateManipulators(){if(!this._recreatingManipulators){if(this._recreatingManipulators=!0,this._removeManipulators(),this._resetTooltip(),this._operations&&this._segmentLabels?.context?.editGeometryOperations===this._operations||(this._segmentLabels=l(this._segmentLabels)),this._createManipulators(),!this._segmentLabels&&this._operations){const e=this._sketchOptions.labels;this._segmentLabels=new L({context:{view:this.view,editGeometryOperations:this._operations,elevationInfo:this.object.elevationInfo,labelOptions:e},visible:e.enabled})}this._recreatingManipulators=!1}}_perObjectManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const n=[],a=this._manipulatorInfos.some(e=>"vertex"===e.type&&e.manipulator.selected),o=1===e&&a;for(const s of this._manipulatorInfos)"vertex"===s.type&&(s.manipulator.grabbing||o&&!s.manipulator.selected||n.push(s),i++);this._moveVertices(n,t);if(n.length===i){if(this._updateEventState(1),this.destroyed)return t;this.events.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,object:this.object})}else{if(this._updateEventState(2),this.destroyed)return t;this.events.emit("reshape",{type:"reshape",object:this.object})}return t}_toggleAutoHideManipulators(e){this.autoHideManipulators&&(e?this.removeHandles(je):this.tool.manipulators.forEach(({manipulator:e})=>{const t=e.disableDisplay?.();t&&this.addHandles(t,je)}))}_isMultiVertexSelection(){return this._manipulatorInfos.reduce((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e,0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(2),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:n}=e;if(!t&&!i&&!n)return;const a=[];for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected&&!o.manipulator.grabbing||o===e.info)&&a.push(o);this._moveVertices(a,e,1),this.events.emit("reshape",{type:"reshape",object:this.object})}_updateEventState(e,t={}){if(e===this._reshapeEventState)return!1;switch(e){case 0:if(!t.forceEnd&&(0!==this._numGrabbing||0!==this._numDragging))return!1;switch(this._reshapeEventState){case 1:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object})}break;case 1:switch(this._reshapeEventState){case 0:this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object}),this.destroyed||this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object})}break;case 2:switch(this._reshapeEventState){case 0:this.events.emit("reshape",{type:"reshape-start",object:this.object});break;case 1:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object}),this.destroyed||this.events.emit("reshape",{type:"reshape-start",object:this.object})}}if(this.destroyed)return!1;const i=this._reshapeEventState!==e;return this._reshapeEventState=e,i}_createObjectMoveManipulation(){const{tool:e,view:t,object:i,_operations:n}=this;if(n){if(this._objectMoveManipulation=new J({tool:e,view:t,object:i}),this.enableMoveObject){let e=null;this._manipulatorHandles.add(this._objectMoveManipulation.createDragPipeline((t,i,a)=>{i.next(e=>this._trackNumDragging(e)).next(t=>("start"===t.action&&(e=n.createUndoGroup()),t)).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(t=>{"end"===t.action&&(this._resetTooltip(),e=p(e))}),a.next(()=>this._onDragCancel(!0,()=>e=p(e)))})),this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1)))}else this._objectMoveManipulation.forEachManipulator(e=>{e.grabbable=!1,e.cursor=null});this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(e.events.on("immediate-click",e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()})))}}_createMoveManipulation(e){const{object:t,tool:i,view:n,_operations:a}=this;if(!a)return;this._moveManipulation=new K({tool:i,view:n,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&N(t.operations,t.elevationInfo),snapToScene:!1,radius:K.radiusForSymbol(t.graphic?.symbol)}),this._moveManipulation.forEachManipulator(e=>this.addHandles([e.events.on("immediate-click",t=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some(e=>e.manipulator.selected)||this.events.emit("immediate-click",{...t,object:this.object}),t.stopPropagation()}),this._watchAndUpdateGrabState(e,!1)]));const o=e=>t=>{this.addHandles([t.events.on("focus-changed",({action:t})=>{"focus"===t?this._updateTranslateTooltip(e):this._resetTooltip()})])};this._moveManipulation.xyManipulation.forEachManipulator(o(0)),this._moveManipulation.xyAxisManipulation.forEachManipulator(o(1)),this._moveManipulation.zManipulation.forEachManipulator(o(2)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=a.data.spatialReference;this.addHandles([this._moveManipulation.createDragPipeline((n,o,s,r,l)=>{const{snappingStep:p,cancelSnapping:d}=be({predicate:e=>!!e.info,snappingManager:i.snappingManager,snappingContext:new Me({editGeometryOperations:a,elevationInfo:e,pointer:l,excludeFeature:t.graphic,visualizer:new z}),updatingHandles:this._updatingHandles,useZ:!1});return r=r.next(e=>(this._onDragCancel(),e)).next(d),{steps:s=s.next(e=>this._trackNumDragging(e)).next(e=>{const t=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.manipulatorType&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e}).next(ce(this.view,e,t.graphic??void 0)).next(...p).next(me()).next(e=>this._perObjectManipulatorDragAction(1,e)).next(e=>(this._updateTranslateTooltip(n,e),e)),cancel:r}},e,s,t.graphic),d(()=>t.visible,()=>this._updateMoveManipulationPosition(),h),t.on("committed",()=>{this._recreatingManipulators||this._updateMoveManipulationPosition()}),d(()=>t.isDraped,e=>{this._updateMoveManipulationPosition(),this.removeHandles(Ee),e&&this.addHandles(pe({view:this.view,geometry:t.graphic?.geometry,elevationInfo:t.elevationInfo,onElevationChanges:()=>this._updateMoveManipulationPosition()}),Ee)},h)])}_createVisualElements(){const{object:e,view:t}=this,i=X({view:t,object:e,forEachManipulator:e=>{if(!this.destroyed&&!this._recreatingManipulators){this._objectMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,1)}},onManipulatorsChanged:e=>this.events.on("manipulators-changed",e)});null!=i&&(this._outlineVisualElement=i.visualElement instanceof le?i.visualElement:null);const n=this._outlineVisualElement;if(null!=n){const t=()=>{e.isDraped||this._updateMoveManipulationPosition()};this._manipulatorHandles.add(u(()=>n.events,"attachment-origin-changed",t,{onListenerAdd:t}))}this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=this.object.elevationInfo){const i=this.view,n=this._operations;if(e.part.vertices.length<=2||!n)return null;const a=n.data.spatialReference,s=this._settings.manipulators.edgeOffset,r=s.size/2,l=r+s.collisionPadding,p=r/l,d=p/2,h=p*Math.sqrt(3)/2,{height:u,offset:c}=s,m=this._edgeOffsetManipulatorMaterial;if(!this._edgeOffsetManipulatorGeometryInside){const e=de(m,h,d,d,u,c);this._edgeOffsetManipulatorGeometryInside=e}if(!this._edgeOffsetManipulatorGeometryOutside){const e=de(m,-h,d,d,u,-c);this._edgeOffsetManipulatorGeometryOutside=e}const f=[new R(this._edgeOffsetManipulatorGeometryInside.instantiate(),1),new R(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2),new R(this._edgeOffsetManipulatorGeometryOutside.instantiate(),1),new R(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2)],g=new P({view:i,renderObjects:f,elevationInfo:"on-the-ground"!==t.mode||G(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:l,available:this.object.visible,collisionType:{type:"disc",direction:E(0,0,1)},collisionPriority:1,metadata:{deleting:!1},location:Ve(a)}),_=new P({view:i,worldSized:!0,worldOriented:!1,available:this.object.visible,collisionPriority:-10,cursor:this.enableMoveObject?"move":"default",metadata:{deleting:!1},location:Ve(a)}),v={manipulator:g,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:_,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(v,s.minSquaredEdgeLength);const M=()=>this._updateEdgeOffsetManipulator(v);M(),v.locationUpdateHandle=o([e.leftVertex,e.rightVertex].map(e=>{const t=this._getManipulatorInfoFromHandle(e);return t?.manipulator.events.on("location-update",M)}));const b=e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()};return this._manipulatorHandles.add([v.locationUpdateHandle,this._watchAndUpdateGrabState(g,!0),this._watchAndUpdateGrabState(_,!0),fe(g,this._createEdgeOffsetPipeline(v,t,n)),fe(_,this._createEdgePipeline(v,t,n)),_.events.on("immediate-click",b),g.events.on("immediate-click",b),g.events.on("focus-changed",()=>this._resetTooltip()),g.events.on("grab-changed",({screenPoint:e,action:t})=>{v.grabMapPoint="start"===t?Q(e,this.view,this.object,v):null})],g),this._manipulatorInfos.push(v),this.manipulators.addMany([g,_]),this.events.emit("manipulators-changed"),v}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,n=e.edgeManipulator,a=()=>{e.visibilityHandle=p(e.visibilityHandle);const a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),r=this._getManipulatorInfoFromHandle(e.handle.rightVertex),l=null!=a&&null!=r&&ie(a.manipulator.renderLocation,r.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!n.focused||l)&&(i.grabbable=!l,n.grabbable=!l,e.visibilityHandle=o([i.disableDisplay(),s(()=>{i.grabbable=!0,n.grabbable=this.enableMoveObject})]))};this._manipulatorHandles.add([i.events.on("focus-changed",a),n.events.on("focus-changed",a),s(()=>{p(e.visibilityHandle),n.metadata.deleting=!0,this.manipulators.remove(n)})],i),a()}_updateEdgeOffsetManipulator(e){if(!this._operations)return;this._updateManipulatorPosition(e);const{coordinateHelper:t}=this._operations.data,i=$(this.view,e.manipulator.elevationAlignedLocation,ee(t,e.handle,e.manipulator.elevationInfo)),n=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==n||null==a)return;const o=n.manipulator.renderLocation,s=a.manipulator.renderLocation,r=null!=i?te(i,o,s):v;e.manipulator.modelTransform=r,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=r;const l=M(b(Ae,o,s))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-l,0,0],[l,0,0]]]}}_createEdgePipeline(e,t,i){return(n,a,o,s)=>{if("touch"===s){this._createEdgeOffsetPipeline(e,t,i)(n,a,o)}else if(this.enableMoveObject){const e=this.object.graphic,s=i.data.spatialReference,{elevationAlignedLocation:r}=n;a.next(e=>this._trackNumDragging(e)).next(ge(this.view,r)).next(F(this.view,r,t,s,e)).next(_e()).next(me()).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(e=>{"end"===e.action&&this._resetTooltip()}),o.next(()=>this._onDragCancel(!n.metadata.deleting))}}}_createEdgeOffsetPipeline(e,t,i){return(n,a,o)=>{const s=this._pendingEdgeOffsetInfo;if(s?.manipulatorInfo===e&&"drag"!==s.mode)return void o.execute({action:"cancel"});this._clearSelection();const{initializeStep:r,cleanup:l}=this._initializeEdgeOffset(e,t,i,o),p=this._applyEdgeOffsetStep(e);a.next(e=>this._trackNumDragging(e)).next(ge(this.view,n.elevationAlignedLocation)).next(r).next(B(this.view)).next(Z(this.view,i.data.spatialReference)).next(me()).next(Se()).next(e=>this._pendingEdgeOffsetInfo?e:p(e)).next(e=>{"end"!==e.action||this._pendingEdgeOffsetInfo||l()}),o.next(()=>{this._exitEdgeOffsetInputMode(),n.metadata.deleting||(l(),this._onDragCancel())})}}_initializeEdgeOffset(e,t,i,n){const{view:a,object:s}=this,r=ee(i.data.coordinateHelper,e.handle,t),l=i.createUndoGroup(),d=$(a,e.manipulator.elevationAlignedLocation,r);let h;this._splitEdgesBeforeEdgeOffset(e,r),this._selectEdgeOffsetArrow(e,r);const u=()=>{this._cleanEdgeOffsetCollapsedEdges(e,i),h=p(h)},c=this.events.on("undo",u);return h=o([this._initializeEdgeOffsetVisualElement(e,s,t,i),l,c,this._connectEdgeOffsetTooltip(e,r,i,()=>{n.execute({action:"cancel"})})]),{initializeStep:e=>null==r||null==d?(u(),null):{...e,operation:r,plane:d},cleanup:u}}_initializeEdgeOffsetVisualElement(e,t,i,n){const a=()=>new w({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:n.data.spatialReference}),s=new le({view:this.view,isDraped:t.isDraped,geometry:a(),elevationInfo:i,width:this._settings.visualElements.lineObjects.outline.width,attached:!1,isDecoration:!0}),l=o([d(()=>({color:this._accentColor,draped:t.isDraped}),({color:e,draped:t})=>{s.color=e.toUnitRGBA(),s.isDraped=t},c),t.on("committed",()=>{s.geometry=a()}),r(s)]);return s.attached=!0,l}_applyEdgeOffsetStep(e){return t=>(this.destroyed||null==t.operation||!this._operations||(this._updateEventState(2),null==t.signedDistance?this._resetTooltip():((t.mapDeltaX||t.mapDeltaY||t.mapDeltaZ)&&(this._offsetEdge(e,t.operation,t.signedDistance),this.events.emit("reshape",{type:"reshape",object:this.object})),this._updateEdgeOffsetTooltip(t))),t)}_cleanEdgeOffsetCollapsedEdges(e,t){const i=e.handle.leftVertex.leftSegment?.leftVertex,n=e.handle.leftVertex,a=e.handle.rightVertex.rightSegment?.rightVertex,o=e.handle.rightVertex,s=t.data.coordinateHelper,r=this.view.pixelSizeAt(s.vectorToDehydratedPoint(n.pos),s.spatialReference),l=[];if(i&&s.distance(i.pos,n.pos)<Ge){const e=this._getManipulatorInfoFromHandle(n);null!=e&&l.push(e)}if(s.distance(n.pos,o.pos)<r||a&&s.distance(a.pos,o.pos)<Ge){const e=this._getManipulatorInfoFromHandle(o);null!=e&&l.push(e)}l.length&&this._removeVertices(l)}_enterInputModeDuringEdgeOffset(e){const t=this._findActiveEdgeOffsetManipulatorInfo();return!!t&&(!!ye(e,this.tooltip)&&(t.manipulator.dragging?(this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"drag"},!0):(this._clearSelection(),this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"hover"},this._connectEdgeOffsetTooltipOnHover(t),!0)))}_exitEdgeOffsetInputMode(){this.tooltip&&(this._pendingEdgeOffsetInfo=null,this._resetTooltip(),this.tooltip.exitInputMode())}_findActiveEdgeOffsetManipulatorInfo(){return this._manipulatorInfos.filter(Te).find(({manipulator:e})=>e.hovering||e.grabbing||e.dragging)}_connectEdgeOffsetTooltipOnHover(e){const{_operations:t,object:i}=this;if(!t)return;const{elevationInfo:n}=i,a=ee(t.data.coordinateHelper,e.handle,n);this._selectEdgeOffsetArrow(e,a),this.addHandles([this._initializeEdgeOffsetVisualElement(e,i,n,t),this._connectEdgeOffsetTooltip(e,a,t,()=>{this.removeHandles(a),this._exitEdgeOffsetInputMode()})],a)}_splitEdgesBeforeEdgeOffset(e,t){if(t.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftSegment);null!=t&&this._splitEdgeManipulator(t,1)}if(t.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightSegment);null!=t&&this._splitEdgeManipulator(t,0)}}_selectEdgeOffsetArrow(e,t){const i=e.grabMapPoint??Q(this.view.inputManager?.latestPointerInfo?.location,this.view,this.object,e);i&&t.selectArrowFromStartPoint(i)}_connectEdgeOffsetTooltip(e,t,i,n){const a=()=>this.tooltipInfos.edgeOffset.distance.actual,s=a=>{n(),queueMicrotask(()=>{this.view.focus();const n=i.createUndoGroup();this._tooltipCallbacks.onReshapeStart?.(),this._splitEdgesBeforeEdgeOffset(e,t),this._offsetEdge(e,t,ne(a,e.manipulator.location,t,i)),this._tooltipCallbacks.onReshape?.(),this._tooltipCallbacks.onReshapeStop?.(),this._cleanEdgeOffsetCollapsedEdges(e,i),n.remove()})},r=()=>{const e=a();null!=e?s(e):n()};return o([m(()=>this.tooltip&&!this.tooltip.focused,()=>r(),f),this.tooltip.on("discard",n),this.tooltip.on("commit",e=>{"commit-and-exit"===e.type&&r()})])}_createVertexOrEdgeManipulator(e,t=this.object.elevationInfo,i=!1){const n=this.view,a=this._operations,s=this._settings;if(!a)return null;const r=a.data.type,l=a.data.spatialReference;if("line"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(null==this._vertexManipulatorGeometry||null==this._vertexManipulatorOutlineGeometry){const{size:e,outlineSize:t}=He(s.manipulators.vertex);this._vertexManipulatorGeometry=he(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=he(this._vertexManipulatorOutlineMaterial,t,16,16)}if(null==this._edgeManipulatorGeometry||null==this._edgeManipulatorOutlineGeometry){const{size:e,outlineSize:t}=He(s.manipulators.edge);this._edgeManipulatorGeometry=he(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=he(this._edgeManipulatorOutlineMaterial,t,16,16)}const d="point"===r||"mesh"===r?[]:[new R(this._vertexManipulatorGeometry.instantiate(),4|Pe),new R(this._vertexManipulatorOutlineGeometry.instantiate(),5|Pe),new R(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|Pe),new R(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),8),new R(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),9),new R(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),10)];this.enableMidpoints&&d.push(new R(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),6|ke),new R(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|ke),new R(this._edgeManipulatorGeometry.instantiate(),5|ke),new R(this._edgeManipulatorOutlineGeometry.instantiate(),5|ke));const h=()=>new P({view:n,renderObjects:d,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:this.object.visible,metadata:{deleting:!1},location:Ve(l)});let u=null;"vertex"===e.type&&(u=this.object.createReshapeManipulator?.({vertex:e,defaultCreate:h,elevationInfo:t,selected:i})??null),u??=h(),u.selected=i,this._setTypeSpecificManipulatorSettings(u,e,t);const c="vertex"===e.type?{manipulator:u,handle:e,type:"vertex",selectedIndex:0}:{manipulator:u,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0};if(this._manipulatorInfos.push(c),this.manipulators.add(u),this._updateManipulatorPosition(c),"edge"===c.type){const e=[];for(const t of[c.handle.leftVertex,c.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);null!=i&&e.push(i.manipulator.events.on("location-update",()=>this._updateManipulatorPosition(c)))}c.locationUpdateHandle=o(e),this._manipulatorHandles.add(c.locationUpdateHandle,u)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(u,!0),u);const m=fe(u,(e,i,o,s)=>{let r=null;const{snappingStep:d,cancelSnapping:h}=be({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new Me({editGeometryOperations:a,elevationInfo:t,pointer:s,excludeFeature:this.object.graphic,visualizer:new z}),updatingHandles:this._updatingHandles,useZ:this.tool.snapToScene});o.next(t=>(this._onDragCancel(!e.metadata.deleting,()=>r=p(r)),t)).next(h);const{elevationAlignedLocation:u}=e,m=this.object.graphic??void 0,f=this.tool.snapToScene?this._screenToSceneMapForVertexDrag(t,a,m):F(n,u,t,l,m);i.next(e=>this._trackNumDragging(e)).next(e=>{if("start"===e.action&&a&&(r=a.createUndoGroup()),"edge"===c.type){const t=this._splitEdgeManipulator(c);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:c,snapOrigin:c.handle.pos}}).next(ge(n,u)).next(f).next(ce(n,t,m)).next(...d).next(me()).next(e=>{this._perVertexManipulatorDragAction(e),"end"===e.action&&(r=p(r)),this._resetTooltip()})});return this._manipulatorHandles.add([m,u.events.on("immediate-click",e=>this._manipulatorClickCallback(e,c)),u.events.on("select-changed",()=>{c.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition(),this._resetTooltip()}),u.events.on("focus-changed",()=>{this._resetTooltip()})],u),this.events.emit("manipulators-changed"),c}_screenToSceneMapForVertexDrag(e,t,i){const{view:n}=this,{coordinateHelper:a,spatialReference:o}=t.data;let s=null;return t=>{if("start"===t.action&&(s=a.vectorToPoint(t.snapOrigin)),null==s)return null;const r=n.toMap(t.screenEnd,{exclude:i,excludeLabels:!0});return null==r?null:(r.z=A(r,n,e),V(r,r,o)?{...t,mapStart:s,mapEnd:r}:null)}}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_onDragCancel(e=!0,t){switch(this._numDragging--,e&&this.undo(),this.tool.snappingManager?.doneSnapping(),this._resetTooltip(),this._reshapeEventState){case 0:break;case 1:this.events.emit("move",{type:"move",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape",object:this.object})}t?.(),this.destroyed||this._updateEventState(0)}_setTypeSpecificManipulatorSettings(e,t,i){const n=this._settings;switch(t.type){case"vertex":{e.selectable=!0,e.cursor="move",e.collisionPriority=2,e.elevationInfo=i;const t=this._operations?.data.type;if(e.interactive=null!=t&&"point"!==t&&"mesh"!==t,null==this.object.createReshapeManipulator){const{size:t,collisionPadding:i}=n.manipulators.vertex;e.radius=t/2+i,e.state=Pe}break}case"line":{e.state=ke,e.selectable=!1,e.cursor="copy",e.collisionPriority=2;const{size:t,collisionPadding:a}=n.manipulators.edge;e.radius=t/2+a,e.elevationInfo="on-the-ground"!==i.mode||G(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:i;break}}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",i=>{this._onGrabStateChanged(e,t,i.action,i.pointerType)})}_onGrabStateChanged(e,t,i,n="mouse"){if(!this._recreatingManipulators){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(0),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==n||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach(e=>{const{manipulator:t}=e,i=this._operations?.data.type;t.interactive=t.grabbing||!this._numGrabbing&&null!=i&&"point"!==i&&"mesh"!==i,Te(e)&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)}),this._objectMoveManipulation.forEachManipulator(e=>{e.interactive=e.grabbing||!this._numGrabbing}))}}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1);this._pendingEdgeOffsetInfo=null}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.events.emit("manipulators-changed"))}_removeManipulator(e){null!=e&&(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),i(this._manipulatorInfos,e),this.events.emit("manipulators-changed"),this._resetTooltip())}_getManipulatorInfoFromHandle(e){return this._manipulatorInfos.find(t=>t.handle===e)}_updateManipulatorPositions(e){for(const t of e)this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(t))}_updateManipulatorPosition(e){const t=this._operations;if(null!=e&&t)if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,De),e.manipulator.grabbing&&null!=this._vertexLaserLineVisualElement&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),n=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==i||null==n)return;const a=i.manipulator,o=n.manipulator;if("on-the-ground"===e.manipulator.elevationInfo?.mode){const i=a.location,n=o.location,s=.5,r=i.x+s*(n.x-i.x),l=i.y+s*(n.y-i.y),p=i.hasZ&&n.hasZ?0:void 0;e.manipulator.location=D(r,l,p,t.data.spatialReference)}else x(Ae,a.renderLocation,o.renderLocation,.5),e.manipulator.renderLocation=Ae}}_splitEdgeManipulator(e,t=.5){const i=this._operations,n=i.splitSegment(e.handle,t).createdVertex;e.locationUpdateHandle=p(e.locationUpdateHandle);const a=this.object.elevationInfo;let o;this.enableEdgeOffset?(this._removeManipulator(e),o=this._createVertexOrEdgeManipulator(n)):(o=e,o.handle=n,o.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,a)),"line"===n.leftSegment?.type&&this._createVertexOrEdgeManipulator(n.leftSegment),"line"===n.rightSegment?.type&&this._createVertexOrEdgeManipulator(n.rightSegment),this._updateManipulatorPosition(o),this.enableEdgeOffset||this._resetTooltip(),this._updateSelection(e.manipulator);const s=this._updateEventState(2),r=i.data.coordinateHelper.vectorToArray(o.handle.pos),l=i.data.parts.indexOf(n.part);return this.events.emit("vertex-add",{type:"vertex-add",object:this.object,vertices:[{coordinates:r,componentIndex:l,vertexIndex:n.index}],added:r}),s&&this._updateEventState(0),o}_updateMoveManipulationPosition(){const e=y(Ae,0,0,0);let t=0,i=!1,n=null,a=null;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.selected?(t++,O(e,e,r.manipulator.renderLocation),null==n||r.selectedIndex>n.selectedIndex?(a=n,n=r):(null==a||r.selectedIndex>a.selectedIndex)&&(a=r)):i=!0);const o=this.object,s=this._operations?.data.geometry;if(0===t){const e=o.visible&&this.enableMoveObject;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&N(this._operations,o.elevationInfo),this._moveManipulation.angle=W(s),this._moveManipulation.radius=K.radiusForSymbol(o.graphic?.symbol)}else{const e=o.visible;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&N(this._operations,this.object.elevationInfo),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(null!=n){const e=n.handle.pos,t=null!=a?a.handle.pos:n.handle.leftSegment?.leftVertex?n.handle.leftSegment.leftVertex.pos:null,o=null==a&&n.handle.rightSegment?.rightVertex?n.handle.rightSegment.rightVertex.pos:null;t&&o?this._moveManipulation.xyAxisManipulation.available=!1:t?i=we(t,e):o&&(i=we(e,o))}const s=n?.handle,r=s?o.getReshapeMoveConfig?.({vertex:s,numSelected:t})??null:null;switch(r?.xyAxisMode){case"all":this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e;break;case"hidden":this._moveManipulation.xyAxisManipulation.available=!1,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=!1}this._moveManipulation.angle=r?.angle??i,this._moveManipulation.radius=Y}0!==t&&i?(j(e,e,1/t),De.spatialReference=this._operations.data.spatialReference,De.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,De),this._moveManipulation.elevationAlignedLocation=De):null==this._outlineVisualElement||this.object.isDraped||null==this._outlineVisualElement.attachmentOrigin?U(this._moveManipulation,this.object):this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin}_removeVertices(e){const t=new Array,i=this._operations;if(!i)return;const n=e.filter(e=>"vertex"===e.type&&i.canRemoveVertex(e.handle.part));if(n.length>0){const e=this._createBeforeVertexRemoveEvent(n);if(this.events.emit("before-vertex-remove",e),e.defaultPrevented)return}for(const a of n){const e=a.handle.part;if(i.canRemoveVertex(e)){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftSegment)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightSegment));const n=i.removeVertices([a.handle]),o=n.removedVertices?.[0].createdSegment;o&&"line"===o.type?this._createVertexOrEdgeManipulator(o):this.enableEdgeOffset&&e.vertices.length<=2&&this._removeManipulator(this._getManipulatorInfoFromHandle(e.segments[0]))}}if(t.length>0){const e=t.map(e=>{const t=i.data.parts.indexOf(e.part);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:e.index}}),n=this._updateEventState(2);if(this.destroyed)return;if(this.events.emit("vertex-remove",{type:"vertex-remove",object:this.object,removed:e.map(e=>e.coordinates),vertices:e}),this.destroyed)return;if(n&&(this._updateEventState(0),this.destroyed))return;this._updateMoveManipulationPosition()}}_createBeforeVertexRemoveEvent(e){const t=this._operations,i=e.map(e=>{const i=t.data.parts.indexOf(e.handle.part);return{coordinates:t.data.coordinateHelper.vectorToArray(e.handle.pos),componentIndex:i,vertexIndex:e.handle.index}});let n=!1;return{type:"before-vertex-remove",object:this.object,removed:i.map(e=>e.coordinates),vertices:i,get defaultPrevented(){return n},preventDefault(){n=!0}}}_moveVertices(e,t,i=("start"===t.action?0:1)){const n=this._operations;if(n){e.length>0&&n.moveVertices(e.map(e=>e.handle),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i);for(const t of e)this._updateManipulatorPosition(t)}}_offsetEdge(e,t,i){if(!this._operations)return;const n=t.clone();n.distance=i,this._operations.updateVertices([e.handle.leftVertex,e.handle.rightVertex],n),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.rightVertex))}_manipulatorClickCallback(e,t){e.shiftKey||this._clearSelection(),"vertex"===t.type&&(t.manipulator.selected=!t.manipulator.selected,this.enableDeleteVertices&&e.button===ue.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===ue.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateTranslateTooltip(e,t){null!=this._defaultTooltipInfo?this._resetTooltip():this._updateTranslateObjectTooltip(e,t)}_updateTranslateObjectTooltip(e,t){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=se(e,t,this._tooltipsContext,this._updatingHandles))}_updateEdgeOffsetTooltip(e){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=re(this.object,e,this._tooltipsContext,this._updatingHandles))}_resetTooltip(){const e=this.activeTooltipInfo;if(this._pendingEdgeOffsetInfo&&"reshape-edge-offset"===e?.type)return;let t=null;t=this._pendingEdgeOffsetInfo||null!=this._findActiveEdgeOffsetManipulatorInfo()?re(this.object,null,this._tooltipsContext,this._updatingHandles):this._defaultTooltipInfo,t!==e&&(null!=e&&null!=t&&"input"===this.tooltip.mode||(this.activeTooltipInfo=t))}get _defaultTooltipInfo(){const e=this._operations?.data.type;switch(e){case"multipoint":case"polyline":case"polygon":return this._selectedVertexManipulatorInfo?this.tooltipInfos.selectedVertex:null;case"point":case"mesh":return this.tooltipInfos.movePoint;default:return null}}get _selectedVertexManipulatorInfo(){const e=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.length?e[0]:null}get _tooltipsContext(){const{tooltipInfos:e,activeTooltipInfo:t}=this;return{sketchOptions:this._sketchOptions,tooltipInfos:e,activeTooltipInfo:t,selectedVertexManipulatorInfo:this._selectedVertexManipulatorInfo,callbacks:this._tooltipCallbacks,measurementWorker:this._measurementWorker}}get test(){}};function Se(){return e=>{const{operation:t,mapEnd:i}=e;return null==t||null==i?e:{...e,signedDistance:t.signedDistanceToPoint(i)}}}function He(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}function we(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function Ve(e){return new H({x:0,y:0,z:0,spatialReference:e})}function Te(e){return"edge"===e.type&&"edgeManipulator"in e}e([g()],Ie.prototype,"_numGrabbing",void 0),e([g()],Ie.prototype,"_numDragging",void 0),e([g()],Ie.prototype,"_pendingEdgeOffsetInfo",void 0),e([g()],Ie.prototype,"_operations",null),e([g()],Ie.prototype,"_segmentLabels",void 0),e([g({constructOnly:!0})],Ie.prototype,"tool",void 0),e([g()],Ie.prototype,"tooltip",void 0),e([g()],Ie.prototype,"activeTooltipInfo",void 0),e([g({readOnly:!0})],Ie.prototype,"updating",null),e([g()],Ie.prototype,"manipulators",null),e([g()],Ie.prototype,"view",null),e([g()],Ie.prototype,"object",null),e([g()],Ie.prototype,"enableZShape",null),e([g()],Ie.prototype,"enableDeleteVertices",null),e([g()],Ie.prototype,"enableZVertex",null),e([g()],Ie.prototype,"autoHideManipulators",null),e([g()],Ie.prototype,"enableMoveObject",null),e([g()],Ie.prototype,"enableMidpoints",null),e([g()],Ie.prototype,"enableEdgeOffset",null),e([g()],Ie.prototype,"_sketchOptions",null),e([g()],Ie.prototype,"_accentColor",null),e([g()],Ie.prototype,"_tooltipsContext",null),Ie=e([_("esri.views.3d.interactive.editingTools.reshape.ReshapeOperation")],Ie);const De=D(0,0,void 0,T.WGS84),Ae=I(),Ge=1e-6,Pe=16,ke=32;export{Ie as ReshapeOperation};
2
+ import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as i}from"../../../../../core/arrayUtils.js";import{EventEmitter as n}from"../../../../../core/Evented.js";import a from"../../../../../core/Handles.js";import{makeHandle as o,handlesGroup as s,destroyHandle as r}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as l,removeMaybe as p}from"../../../../../core/maybe.js";import{watch as h,initial as d,on as u,syncAndInitial as c,when as m,sync as f}from"../../../../../core/reactiveUtils.js";import{property as g,subclass as _}from"../../../../../core/accessorSupport/decorators.js";import{IDENTITY as v}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{length as M,subtract as b,lerp as x,set as y,add as O,scale as E}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as j,create as I}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as S}from"../../../../../core/support/UpdatingHandles.js";import H from"../../../../../geometry/Point.js";import w from"../../../../../geometry/Polyline.js";import{projectPoint as V}from"../../../../../geometry/projectionUtils.js";import D from"../../../../../geometry/SpatialReference.js";import{makeDehydratedPoint as T}from"../../../../../layers/graphics/dehydratedPoint.js";import{getZForElevationMode as A}from"../../../../../support/elevationInfoUtils.js";import{isVolumetricSymbol as G}from"../../../../../symbols/support/utils.js";import{Manipulator3D as C}from"../../Manipulator3D.js";import{createManipulatorMaterial as R,createManipulatorOutlineMaterial as P,placeAtObject as k}from"../../manipulatorUtils.js";import{RenderObject as U}from"../../RenderObject.js";import{SegmentLabels3D as L}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as z}from"../../SnappingVisualizer3D.js";import{screenToMapXYAtLocation as F,screenToRenderPlaneFromEvent as B,convertToMapCoordinates as Z}from"../dragEventPipeline3D.js";import{orientation as W}from"../geometryUtils.js";import{canMoveZOperations as N}from"../manipulatorUtils.js";import{Settings as q}from"../settings.js";import{createVisualElements as X}from"../visualElementUtils.js";import{discRadiusSmall as Y}from"../manipulations/config.js";import{MoveManipulation as K}from"../manipulations/MoveManipulation.js";import{MoveXYObjectManipulation as J}from"../manipulations/MoveXYObjectManipulation.js";import{getMapPointAtEdgeOffsetManipulatorElevation as Q,createEdgeOffsetIntersectionPlane as $,createEdgeOffsetOperation as ee,edgeOffsetRotationMatrix as te,screenEdgeLengthSquared as ie,getDistanceInGeometrySR as ne}from"./edgeOffsetUtils.js";import{createTooltipInfos as ae,connectTooltipToManipulatedObject as oe,getUpdatedTranslateObjectTooltipInfo as se,getUpdatedEdgeOffsetTooltipInfo as re}from"./reshapeTooltipUtils3D.js";import{OutlineVisualElement as le}from"../../visualElements/OutlineVisualElement.js";import{createElevationUpdateHandle as pe}from"../../../support/elevationUpdateUtils.js";import{createExtrudedTriangle as he,createSphereGeometry as de}from"../../../webgl-engine/lib/GeometryUtil.js";import{mouseButtons as ue}from"../../../../input/mouseButtons.js";import{sceneSnappingAtLocation as ce,addMapDelta as me,createManipulatorDragEventPipeline as fe,dragAtLocation as ge,addScreenDelta as _e}from"../../../../interactive/dragEventPipeline.js";import{tooltipKeys as ve}from"../../../../interactive/keybindings.js";import{SnappingContext as Me}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as be}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as xe,enterInputModeIfAvailable as ye}from"../../../../interactive/tooltip/tooltipCommonUtils.js";import{GeometryWorkerHandle as Oe}from"../../../../support/GeometryWorkerHandle.js";const Ee=Symbol(),je=Symbol(),Ie=Symbol(),Se=Symbol();let He=class extends t{get _movingManipulatorsHidden(){return this.hasHandles(Se)}get _operations(){return this.object.operations}constructor(e){super(e),this._selectedIndex=0,this._manipulatorHandles=new a,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=0,this._pendingEdgeOffsetInfo=null,this._updatingHandles=new S,this._recreatingManipulators=!1,this._settings=new q({getTheme:()=>this.view.effectiveTheme}),this.events=new n,this.activeTooltipInfo=null,this._measurementWorker=new Oe({preloadGeodetic:!0}),this._vertexLaserLineVisualElement=null,this._tooltipCallbacks={onBeforeReshape:()=>this.tool.endDrag(),onReshapeStart:()=>this._updateEventState(2),onReshape:()=>this.events.emit("reshape",{type:"reshape",object:this.object}),onReshapeStop:()=>this._updateEventState(0,{forceEnd:!0}),onMoveStart:()=>this._updateEventState(1),onMove:()=>this.events.emit("move",{type:"move",object:this.object,dx:0,dy:0}),onMoveStop:()=>this._updateEventState(0,{forceEnd:!0})}}initialize(){const{view:e}=this,t=this._settings.manipulators,i=t.vertex;this.tooltipInfos=ae(this._sketchOptions,e),this._vertexManipulatorMaterial=R(i.color.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorOutlineMaterial=P(i.outlineColor.toUnitRGBA(),i.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=P(i.hoverOutlineColor.toUnitRGBA(),i.renderOccluded);const n=t.edge;this._edgeManipulatorMaterial=R(n.color.toUnitRGBA(),n.renderOccluded),this._edgeManipulatorOutlineMaterial=P(n.outlineColor.toUnitRGBA(),n.renderOccluded);const a=t.edgeOffset;this._edgeOffsetManipulatorMaterial=R(a.color.toUnitRGBA(),a.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=R(a.hoverColor.toUnitRGBA(),a.renderOccluded,!1);const o=t.selected;this._selectedManipulatorMaterial=R(o.color.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorOutlineMaterial=P(o.outlineColor.toUnitRGBA(),o.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=P(o.hoverOutlineColor.toUnitRGBA(),o.renderOccluded),this.tooltip=xe(()=>({view:e,options:this._sketchOptions.tooltips})),this.addHandles([h(()=>{const e=this._settings.manipulators;return{vertexSettings:e.vertex,edgeSettings:e.edge,edgeOffsetSettings:e.edgeOffset,selectedSettings:e.selected}},({vertexSettings:e,edgeSettings:t,edgeOffsetSettings:i,selectedSettings:n})=>{e.applyColor(this._vertexManipulatorMaterial),e.applyOutline(this._vertexManipulatorOutlineMaterial),e.applyHoverOutline(this._vertexManipulatorHoverOutlineMaterial),t.applyColor(this._edgeManipulatorMaterial),t.applyOutline(this._edgeManipulatorOutlineMaterial),i.applyColor(this._edgeOffsetManipulatorMaterial),i.applyHover(this._edgeOffsetManipulatorHoverMaterial),n.applyColor(this._selectedManipulatorMaterial),n.applyOutline(this._selectedManipulatorOutlineMaterial),n.applyHoverOutline(this._selectedManipulatorHoverOutlineMaterial)}),h(()=>this.object.visible,e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e,Ae(t)&&(t.edgeManipulator.available=e)}),h(()=>this._numGrabbing+this._numDragging===0,e=>this._toggleAutoHideManipulators(e)),h(()=>({labels:this._segmentLabels,enabled:this._sketchOptions.labels.enabled,edgeOffsetEnabled:this.enableEdgeOffset}),({labels:e,enabled:t,edgeOffsetEnabled:i})=>{null!=e&&(e.visible=t,e.edgeDistance=i?"far":"default")},d),oe(this.tooltip,this.object,()=>this._tooltipsContext,this._updatingHandles),h(()=>this.tooltip.mode,(e,t)=>{"input"===t&&"input"!==e&&this._resetTooltip()}),u(()=>this._operations,"vertex-update",e=>this._updateManipulatorPositions(e.vertices),{onListenerAdd:()=>this._recreateManipulators()}),u(()=>this._operations?.data,"change",e=>{"undo"!==e.operation&&"redo"!==e.operation||this._recreateManipulators()})])}destroy(){this._removeManipulators(),this._updatingHandles.destroy(),this._segmentLabels=l(this._segmentLabels),this.tooltip=l(this.tooltip),this._measurementWorker.destroy()}get updating(){return this._updatingHandles.updating||!!this._segmentLabels?.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get object(){return this.tool.object}get enableZShape(){return this.tool.enableZShape}get enableDeleteVertices(){return this.tool.enableDeleteVertices}get enableZVertex(){return this.tool.enableZVertex}get autoHideManipulators(){return this.tool.autoHideManipulators}get enableMoveObject(){return this.tool.enableMoveObject}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get _sketchOptions(){return this.tool.sketchOptions}get _accentColor(){return this.view.effectiveTheme.accentColor}enterInputModeIfAvailable(e){return"key-down"===e.type&&e.key===ve.enterInputMode&&("reshape-edge-offset"===this.activeTooltipInfo?.type?this._enterInputModeDuringEdgeOffset(e):!!ye(e,this.tooltip)&&(this.tool.endDrag(),!0))}removeSelectedVertices(){const e=this._manipulatorInfos.filter(e=>e.manipulator.selected&&"vertex"===e.type);return this._removeVertices(e),e.length}onManipulatorSelectionChanged(){this.events.emit("manipulators-changed")}clearSelection(){let e=!1;for(const t of this._manipulatorInfos)if(t.manipulator.selected){e=!0;break}e&&(this._clearSelection(),this._updateMoveManipulationPosition(),this.events.emit("manipulators-changed"))}selectManipulator(e){if(null==this._manipulatorInfos.find(t=>t.manipulator===e)||!e.selectable)return!1;let t=e.selected;for(const i of this._manipulatorInfos)if(i.manipulator!==e&&i.manipulator.selected){t=!1;break}return t||(this._clearSelection(),e.selected=!0,this._updateMoveManipulationPosition(),this.events.emit("manipulators-changed")),!0}_removeManipulators(){this._manipulatorHandles.removeAll(),this.removeHandles(je),this.removeHandles(Se),this._moveManipulation=l(this._moveManipulation),this._objectMoveManipulation=l(this._objectMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(e){if(null==this._operations)return;const t=this.object.elevationInfo;for(const{vertices:i,segments:n,index:a}of this._operations.data.parts){const o=e?.byPartIndex.get(a);for(const e of i){const i=o?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of n)"line"===e.type&&this._createVertexOrEdgeManipulator(e,t)}this._createObjectMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}recordUndo(e){this._operations?.recordUndo(e,!0)}get canRedo(){return this._operations?.canRedo??!1}get canUndo(){return this._operations?.canUndo??!1}redo(){return this._operations?.redo()}undo(){return this.events.emit("undo"),this._operations?.undo()}_recreateManipulators(){if(!this._recreatingManipulators){if(this._recreatingManipulators=!0,this._removeManipulators(),this._resetTooltip(),this._operations&&this._segmentLabels?.context?.editGeometryOperations===this._operations||(this._segmentLabels=l(this._segmentLabels)),this._createManipulators(),!this._segmentLabels&&this._operations){const e=this._sketchOptions.labels;this._segmentLabels=new L({context:{view:this.view,editGeometryOperations:this._operations,elevationInfo:this.object.elevationInfo,labelOptions:e},visible:e.enabled})}this._recreatingManipulators=!1}}_perObjectManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const n=[],a=1===e&&this._someVerticesSelected;for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.grabbing||a&&!o.manipulator.selected||n.push(o),i++);if(n.length===i){if(a||this._hideReshapeControls(),this._moveVertices(n,t),this._updateEventState(1),this.destroyed)return t;this.events.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,object:this.object})}else{if(this._moveVertices(n,t),this._updateEventState(2),this.destroyed)return t;this.events.emit("reshape",{type:"reshape",object:this.object})}return t}_hideReshapeControls(){this._movingManipulatorsHidden||this.addHandles([this._hideReshapeManipulators(),this._moveManipulation.hideManipulatorsExceptGrabbedGroup(),o(()=>this._forEachVertex(e=>this._updateManipulatorPosition(e)))],Se)}_showReshapeControls(){this.removeHandles(Se)}_shouldHideReshapeControlsOnGrab(e){return this._objectMoveManipulation.hasManipulator(e)||this._moveManipulation.hasManipulator(e)&&!this._someVerticesSelected}get _canShowReshapeControls(){return!this._objectMoveManipulation.grabbing&&(!this._moveManipulation.grabbing||this._someVerticesSelected)}_hideManipulatorsForEdgeOffset(e){const t=this._manipulatorInfos.filter(Ae).find(t=>t.manipulator===e||t.edgeManipulator===e);null!=t&&(this.removeHandles(je),this.addHandles([this._moveManipulation.hideManipulators(),this._hideReshapeManipulators(t)],je))}_hideReshapeManipulators(e){return s(this._manipulatorInfos.flatMap(t=>t===e?null:[t.manipulator.disableDisplay(),Ae(t)?t.edgeManipulator.disableDisplay():null]))}_toggleAutoHideManipulators(e){this.autoHideManipulators&&(e?this.removeHandles(Ee):this.tool.manipulators.forEach(({manipulator:e})=>{const t=e.disableDisplay?.();t&&this.addHandles(t,Ee)}))}_isMultiVertexSelection(){return this._manipulatorInfos.reduce((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e,0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(2),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:n}=e;if(!t&&!i&&!n)return;const a=[];this._forEachVertex(t=>{const{selected:i,grabbing:n}=t.manipulator;(i&&!n||t===e.info)&&a.push(t)}),this._moveVertices(a,e,1),this.events.emit("reshape",{type:"reshape",object:this.object})}_updateEventState(e,t={}){if(e===this._reshapeEventState)return!1;switch(e){case 0:if(!t.forceEnd&&(0!==this._numGrabbing||0!==this._numDragging))return!1;switch(this._reshapeEventState){case 1:this._showReshapeControls(),this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object})}break;case 1:switch(this._reshapeEventState){case 0:this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape-stop",object:this.object}),this.destroyed||this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object})}break;case 2:switch(this._reshapeEventState){case 0:this.events.emit("reshape",{type:"reshape-start",object:this.object});break;case 1:this._showReshapeControls(),this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object}),this.destroyed||this.events.emit("reshape",{type:"reshape-start",object:this.object})}}if(this.destroyed)return!1;const i=this._reshapeEventState!==e;return this._reshapeEventState=e,i}_createObjectMoveManipulation(){const{tool:e,view:t,object:i,_operations:n}=this;if(n){if(this._objectMoveManipulation=new J({tool:e,view:t,object:i}),this.enableMoveObject){let e=null;this._manipulatorHandles.add(this._objectMoveManipulation.createDragPipeline((t,i,a)=>{i.next(e=>this._trackNumDragging(e)).next(t=>("start"===t.action&&(e=n.createUndoGroup()),t)).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(t=>{"end"===t.action&&(this._showReshapeControls(),this._resetTooltip(),e=p(e))}),a.next(()=>this._onDragCancel(!0,()=>e=p(e)))})),this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1)))}else this._objectMoveManipulation.forEachManipulator(e=>{e.grabbable=!1,e.cursor=null});this._objectMoveManipulation.forEachManipulator(e=>this._manipulatorHandles.add(e.events.on("immediate-click",e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()})))}}_createMoveManipulation(e){const{object:t,tool:i,view:n,_operations:a}=this;if(!a)return;this._moveManipulation=new K({tool:i,view:n,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&N(t.operations,t.elevationInfo),snapToScene:!1,radius:K.radiusForSymbol(t.graphic?.symbol)}),this._moveManipulation.forEachManipulator(e=>this.addHandles([e.events.on("immediate-click",t=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some(e=>e.manipulator.selected)||this.events.emit("immediate-click",{...t,object:this.object}),t.stopPropagation()}),this._watchAndUpdateGrabState(e,!1)]));const o=e=>t=>{this.addHandles([t.events.on("focus-changed",({action:t})=>{"focus"===t?this._updateTranslateTooltip(e):this._resetTooltip()})])};this._moveManipulation.xyManipulation.forEachManipulator(o(0)),this._moveManipulation.xyAxisManipulation.forEachManipulator(o(1)),this._moveManipulation.zManipulation.forEachManipulator(o(2)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=a.data.spatialReference;this.addHandles([this._moveManipulation.createDragPipeline((n,o,s,r,l)=>{const{snappingStep:p,cancelSnapping:h}=be({predicate:e=>!!e.info,snappingManager:i.snappingManager,snappingContext:new Me({editGeometryOperations:a,elevationInfo:e,pointer:l,excludeFeature:t.graphic,visualizer:new z}),updatingHandles:this._updatingHandles,useZ:!1});return r=r.next(e=>(this._onDragCancel(),e)).next(h),{steps:s=s.next(e=>this._trackNumDragging(e)).next(e=>{const t=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.manipulatorType&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e}).next(ce(this.view,e,t.graphic??void 0)).next(...p).next(me()).next(e=>this._perObjectManipulatorDragAction(1,e)).next(e=>("end"===e.action&&this._showReshapeControls(),this._updateTranslateTooltip(n,e),e)),cancel:r}},e,s,t.graphic),h(()=>t.visible,()=>this._updateMoveManipulationPosition(),d),t.on("committed",()=>{this._recreatingManipulators||this._updateMoveManipulationPosition()}),h(()=>t.isDraped,e=>{this._updateMoveManipulationPosition(),this.removeHandles(Ie),e&&this.addHandles(pe({view:this.view,geometry:t.graphic?.geometry,elevationInfo:t.elevationInfo,onElevationChanges:()=>this._updateMoveManipulationPosition()}),Ie)},d)])}_createVisualElements(){const{object:e,view:t}=this,i=X({view:t,object:e,forEachManipulator:e=>{if(!this.destroyed&&!this._recreatingManipulators){this._objectMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,1)}},onManipulatorsChanged:e=>this.events.on("manipulators-changed",e)});null!=i&&(this._outlineVisualElement=i.visualElement instanceof le?i.visualElement:null);const n=this._outlineVisualElement;if(null!=n){const t=()=>{e.isDraped||this._updateMoveManipulationPosition()};this._manipulatorHandles.add(u(()=>n.events,"attachment-origin-changed",t,{onListenerAdd:t}))}this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=this.object.elevationInfo){const i=this.view,n=this._operations;if(e.part.vertices.length<=2||!n)return null;const a=n.data.spatialReference,o=this._settings.manipulators.edgeOffset,r=o.size/2,l=r+o.collisionPadding,p=r/l,h=p/2,d=p*Math.sqrt(3)/2,{height:u,offset:c}=o,m=this._edgeOffsetManipulatorMaterial;if(!this._edgeOffsetManipulatorGeometryInside){const e=he(m,d,h,h,u,c);this._edgeOffsetManipulatorGeometryInside=e}if(!this._edgeOffsetManipulatorGeometryOutside){const e=he(m,-d,h,h,u,-c);this._edgeOffsetManipulatorGeometryOutside=e}const f=[new U(this._edgeOffsetManipulatorGeometryInside.instantiate(),1),new U(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2),new U(this._edgeOffsetManipulatorGeometryOutside.instantiate(),1),new U(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),2)],g=new C({view:i,renderObjects:f,elevationInfo:"on-the-ground"!==t.mode||G(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:l,available:this.object.visible,collisionType:{type:"disc",direction:j(0,0,1)},collisionPriority:1,metadata:{deleting:!1},location:Te(a)}),_=new C({view:i,worldSized:!0,worldOriented:!1,available:this.object.visible,collisionPriority:-10,cursor:this.enableMoveObject?"move":"default",metadata:{deleting:!1},location:Te(a)}),v={manipulator:g,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:_,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(v,o.minSquaredEdgeLength);const M=()=>this._updateEdgeOffsetManipulator(v);M(),v.locationUpdateHandle=s([e.leftVertex,e.rightVertex].map(e=>{const t=this._getManipulatorInfoFromHandle(e);return t?.manipulator.events.on("location-update",M)}));const b=e=>{this._manipulatorInfos.some(e=>e.manipulator.selected)?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()};return this._manipulatorHandles.add([v.locationUpdateHandle,this._watchAndUpdateGrabState(g,!0),this._watchAndUpdateGrabState(_,!0),fe(g,this._createEdgeOffsetPipeline(v,t,n)),fe(_,this._createEdgePipeline(v,t,n)),_.events.on("immediate-click",b),g.events.on("immediate-click",b),g.events.on("focus-changed",()=>this._resetTooltip()),g.events.on("grab-changed",({screenPoint:e,action:t})=>{v.grabMapPoint="start"===t?Q(e,this.view,this.object,v):null})],g),this._manipulatorInfos.push(v),this.manipulators.addMany([g,_]),this.events.emit("manipulators-changed"),v}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,n=e.edgeManipulator,a=()=>{e.visibilityHandle=p(e.visibilityHandle);const a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),r=this._getManipulatorInfoFromHandle(e.handle.rightVertex),l=null!=a&&null!=r&&ie(a.manipulator.renderLocation,r.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!n.focused||l)&&(i.grabbable=!l,n.grabbable=!l,e.visibilityHandle=s([i.disableDisplay(),o(()=>{i.grabbable=!0,n.grabbable=this.enableMoveObject})]))};this._manipulatorHandles.add([i.events.on("focus-changed",a),n.events.on("focus-changed",a),o(()=>{p(e.visibilityHandle),n.metadata.deleting=!0,this.manipulators.remove(n)})],i),a()}_updateEdgeOffsetManipulator(e){if(!this._operations)return;this._updateManipulatorPosition(e);const{coordinateHelper:t}=this._operations.data,i=$(this.view,e.manipulator.elevationAlignedLocation,ee(t,e.handle,e.manipulator.elevationInfo)),n=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==n||null==a)return;const o=n.manipulator.renderLocation,s=a.manipulator.renderLocation,r=null!=i?te(i,o,s):v;e.manipulator.modelTransform=r,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=r;const l=M(b(Ce,o,s))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-l,0,0],[l,0,0]]]}}_createEdgePipeline(e,t,i){return(n,a,o,s)=>{if("touch"===s){this._createEdgeOffsetPipeline(e,t,i)(n,a,o)}else if(this.enableMoveObject){const e=this.object.graphic,s=i.data.spatialReference,{elevationAlignedLocation:r}=n;a.next(e=>this._trackNumDragging(e)).next(ge(this.view,r)).next(F(this.view,r,t,s,e)).next(_e()).next(me()).next(e=>this._perObjectManipulatorDragAction(0,e)).next(e=>(this._updateTranslateObjectTooltip(0,e),e)).next(e=>{"end"===e.action&&(this._showReshapeControls(),this._resetTooltip())}),o.next(()=>this._onDragCancel(!n.metadata.deleting))}}}_createEdgeOffsetPipeline(e,t,i){return(n,a,o)=>{const s=this._pendingEdgeOffsetInfo;if(s?.manipulatorInfo===e&&"drag"!==s.mode)return void o.execute({action:"cancel"});this._clearSelection();const{initializeStep:r,cleanup:l}=this._initializeEdgeOffset(e,t,i,o),p=this._applyEdgeOffsetStep(e);a.next(e=>this._trackNumDragging(e)).next(ge(this.view,n.elevationAlignedLocation)).next(r).next(B(this.view)).next(Z(this.view,i.data.spatialReference)).next(me()).next(we()).next(e=>this._pendingEdgeOffsetInfo?e:p(e)).next(e=>{"end"!==e.action||this._pendingEdgeOffsetInfo||l()}),o.next(()=>{this._exitEdgeOffsetInputMode(),n.metadata.deleting||(l(),this._onDragCancel())})}}_initializeEdgeOffset(e,t,i,n){const{view:a,object:o}=this,r=ee(i.data.coordinateHelper,e.handle,t),l=i.createUndoGroup(),h=$(a,e.manipulator.elevationAlignedLocation,r);let d;this._splitEdgesBeforeEdgeOffset(e,r),this._selectEdgeOffsetArrow(e,r);const u=()=>{this._cleanEdgeOffsetCollapsedEdges(e,i),d=p(d)},c=this.events.on("undo",u);return d=s([this._initializeEdgeOffsetVisualElement(e,o,t,i),l,c,this._connectEdgeOffsetTooltip(e,r,i,()=>{n.execute({action:"cancel"})})]),{initializeStep:e=>null==r||null==h?(u(),null):{...e,operation:r,plane:h},cleanup:u}}_initializeEdgeOffsetVisualElement(e,t,i,n){const a=()=>new w({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:n.data.spatialReference}),o=new le({view:this.view,isDraped:t.isDraped,geometry:a(),elevationInfo:i,width:this._settings.visualElements.lineObjects.outline.width,attached:!1,isDecoration:!0}),l=s([h(()=>({color:this._accentColor,draped:t.isDraped}),({color:e,draped:t})=>{o.color=e.toUnitRGBA(),o.isDraped=t},c),t.on("committed",()=>{o.geometry=a()}),r(o)]);return o.attached=!0,l}_applyEdgeOffsetStep(e){return t=>(this.destroyed||null==t.operation||!this._operations||(this._updateEventState(2),null==t.signedDistance?this._resetTooltip():((t.mapDeltaX||t.mapDeltaY||t.mapDeltaZ)&&(this._offsetEdge(e,t.operation,t.signedDistance),this.events.emit("reshape",{type:"reshape",object:this.object})),this._updateEdgeOffsetTooltip(t))),t)}_cleanEdgeOffsetCollapsedEdges(e,t){const i=e.handle.leftVertex.leftSegment?.leftVertex,n=e.handle.leftVertex,a=e.handle.rightVertex.rightSegment?.rightVertex,o=e.handle.rightVertex,s=t.data.coordinateHelper,r=this.view.pixelSizeAt(s.vectorToDehydratedPoint(n.pos),s.spatialReference),l=[];if(i&&s.distance(i.pos,n.pos)<Re){const e=this._getManipulatorInfoFromHandle(n);null!=e&&l.push(e)}if(s.distance(n.pos,o.pos)<r||a&&s.distance(a.pos,o.pos)<Re){const e=this._getManipulatorInfoFromHandle(o);null!=e&&l.push(e)}l.length&&this._removeVertices(l)}_enterInputModeDuringEdgeOffset(e){const t=this._findActiveEdgeOffsetManipulatorInfo();return!!t&&(!!ye(e,this.tooltip)&&(t.manipulator.dragging?(this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"drag"},!0):(this._clearSelection(),this._pendingEdgeOffsetInfo={manipulatorInfo:t,mode:"hover"},this._connectEdgeOffsetTooltipOnHover(t),!0)))}_exitEdgeOffsetInputMode(){this.tooltip&&(this._pendingEdgeOffsetInfo=null,this._resetTooltip(),this.tooltip.exitInputMode())}_findActiveEdgeOffsetManipulatorInfo(){return this._manipulatorInfos.filter(Ae).find(({manipulator:e})=>e.hovering||e.grabbing||e.dragging)}_connectEdgeOffsetTooltipOnHover(e){const{_operations:t,object:i}=this;if(!t)return;const{elevationInfo:n}=i,a=ee(t.data.coordinateHelper,e.handle,n);this._selectEdgeOffsetArrow(e,a),this.addHandles([this._initializeEdgeOffsetVisualElement(e,i,n,t),this._connectEdgeOffsetTooltip(e,a,t,()=>{this.removeHandles(a),this._exitEdgeOffsetInputMode()})],a)}_splitEdgesBeforeEdgeOffset(e,t){if(t.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftSegment);null!=t&&this._splitEdgeManipulator(t,1)}if(t.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightSegment);null!=t&&this._splitEdgeManipulator(t,0)}}_selectEdgeOffsetArrow(e,t){const i=e.grabMapPoint??Q(this.view.inputManager?.latestPointerInfo?.location,this.view,this.object,e);i&&t.selectArrowFromStartPoint(i)}_connectEdgeOffsetTooltip(e,t,i,n){const a=()=>this.tooltipInfos.edgeOffset.distance.actual,o=a=>{n(),queueMicrotask(()=>{this.view.focus();const n=i.createUndoGroup();this._tooltipCallbacks.onReshapeStart?.(),this._splitEdgesBeforeEdgeOffset(e,t),this._offsetEdge(e,t,ne(a,e.manipulator.location,t,i)),this._tooltipCallbacks.onReshape?.(),this._tooltipCallbacks.onReshapeStop?.(),this._cleanEdgeOffsetCollapsedEdges(e,i),n.remove()})},r=()=>{const e=a();null!=e?o(e):n()};return s([m(()=>this.tooltip&&!this.tooltip.focused,()=>r(),f),this.tooltip.on("discard",n),this.tooltip.on("commit",e=>{"commit-and-exit"===e.type&&r()})])}_createVertexOrEdgeManipulator(e,t=this.object.elevationInfo,i=!1){const n=this.view,a=this._operations,o=this._settings;if(!a)return null;const r=a.data.type,l=a.data.spatialReference;if("line"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(null==this._vertexManipulatorGeometry||null==this._vertexManipulatorOutlineGeometry){const{size:e,outlineSize:t}=Ve(o.manipulators.vertex);this._vertexManipulatorGeometry=de(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=de(this._vertexManipulatorOutlineMaterial,t,16,16)}if(null==this._edgeManipulatorGeometry||null==this._edgeManipulatorOutlineGeometry){const{size:e,outlineSize:t}=Ve(o.manipulators.edge);this._edgeManipulatorGeometry=de(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=de(this._edgeManipulatorOutlineMaterial,t,16,16)}const h="point"===r||"mesh"===r?[]:[new U(this._vertexManipulatorGeometry.instantiate(),4|Pe),new U(this._vertexManipulatorOutlineGeometry.instantiate(),5|Pe),new U(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|Pe),new U(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),8),new U(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),9),new U(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),10)];this.enableMidpoints&&h.push(new U(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),6|ke),new U(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),6|ke),new U(this._edgeManipulatorGeometry.instantiate(),5|ke),new U(this._edgeManipulatorOutlineGeometry.instantiate(),5|ke));const d=()=>new C({view:n,renderObjects:h,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:this.object.visible,metadata:{deleting:!1},location:Te(l)});let u=null;"vertex"===e.type&&(u=this.object.createReshapeManipulator?.({vertex:e,defaultCreate:d,elevationInfo:t,selected:i})??null),u??=d(),u.selected=i,this._setTypeSpecificManipulatorSettings(u,e,t);const c="vertex"===e.type?{manipulator:u,handle:e,type:"vertex",selectedIndex:0}:{manipulator:u,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0};if(this._manipulatorInfos.push(c),this.manipulators.add(u),this._updateManipulatorPosition(c),"edge"===c.type){const e=[];for(const t of[c.handle.leftVertex,c.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);null!=i&&e.push(i.manipulator.events.on("location-update",()=>this._updateManipulatorPosition(c)))}c.locationUpdateHandle=s(e),this._manipulatorHandles.add(c.locationUpdateHandle,u)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(u,!0),u);const m=fe(u,(e,i,o,s)=>{let r=null;const{snappingStep:h,cancelSnapping:d}=be({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new Me({editGeometryOperations:a,elevationInfo:t,pointer:s,excludeFeature:this.object.graphic,visualizer:new z}),updatingHandles:this._updatingHandles,useZ:this.tool.snapToScene});o.next(t=>(this._onDragCancel(!e.metadata.deleting,()=>r=p(r)),t)).next(d);const{elevationAlignedLocation:u}=e,m=this.object.graphic??void 0,f=this.tool.snapToScene?this._screenToSceneMapForVertexDrag(t,a,m):F(n,u,t,l,m);i.next(e=>this._trackNumDragging(e)).next(e=>{if("start"===e.action&&a&&(r=a.createUndoGroup()),"edge"===c.type){const t=this._splitEdgeManipulator(c);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:c,snapOrigin:c.handle.pos}}).next(ge(n,u)).next(f).next(ce(n,t,m)).next(...h).next(me()).next(e=>{this._perVertexManipulatorDragAction(e),"end"===e.action&&(r=p(r)),this._resetTooltip()})});return this._manipulatorHandles.add([m,u.events.on("immediate-click",e=>this._manipulatorClickCallback(e,c)),u.events.on("select-changed",()=>{c.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition(),this._resetTooltip()}),u.events.on("focus-changed",()=>{this._resetTooltip()})],u),this.events.emit("manipulators-changed"),c}_screenToSceneMapForVertexDrag(e,t,i){const{view:n}=this,{coordinateHelper:a,spatialReference:o}=t.data;let s=null;return t=>{if("start"===t.action&&(s=a.vectorToPoint(t.snapOrigin)),null==s)return null;const r=n.toMap(t.screenEnd,{exclude:i,excludeLabels:!0});return null==r?null:(r.z=A(r,n,e),V(r,r,o)?{...t,mapStart:s,mapEnd:r}:null)}}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_onDragCancel(e=!0,t){switch(this._numDragging--,e&&this.undo(),this.tool.snappingManager?.doneSnapping(),this._showReshapeControls(),this._resetTooltip(),this._reshapeEventState){case 0:break;case 1:this.events.emit("move",{type:"move",dx:0,dy:0,object:this.object});break;case 2:this.events.emit("reshape",{type:"reshape",object:this.object})}t?.(),this.destroyed||this._updateEventState(0)}_setTypeSpecificManipulatorSettings(e,t,i){const n=this._settings;switch(t.type){case"vertex":{e.selectable=!0,e.cursor="move",e.collisionPriority=2,e.elevationInfo=i;const t=this._operations?.data.type;if(e.interactive=null!=t&&"point"!==t&&"mesh"!==t,null==this.object.createReshapeManipulator){const{size:t,collisionPadding:i}=n.manipulators.vertex;e.radius=t/2+i,e.state=Pe}break}case"line":{e.state=ke,e.selectable=!1,e.cursor="copy",e.collisionPriority=2;const{size:t,collisionPadding:a}=n.manipulators.edge;e.radius=t/2+a,e.elevationInfo="on-the-ground"!==i.mode||G(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:i;break}}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",i=>{this._onGrabStateChanged(e,t,i.action,i.pointerType)})}_onGrabStateChanged(e,t,i,n="mouse"){if(!this._recreatingManipulators){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++,this._shouldHideReshapeControlsOnGrab(e)&&this._hideReshapeControls(),this._hideManipulatorsForEdgeOffset(e);else if(this._numGrabbing--,this.removeHandles(je),this._updateEventState(0),this._canShowReshapeControls&&this._showReshapeControls(),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==n||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach(e=>{const{manipulator:t}=e,i=this._operations?.data.type;t.interactive=t.grabbing||!this._numGrabbing&&null!=i&&"point"!==i&&"mesh"!==i,Ae(e)&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)}),this._objectMoveManipulation.forEachManipulator(e=>{e.interactive=e.grabbing||!this._numGrabbing}))}}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1);this._pendingEdgeOffsetInfo=null}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.events.emit("manipulators-changed"))}_removeManipulator(e){null!=e&&(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),i(this._manipulatorInfos,e),this.events.emit("manipulators-changed"),this._resetTooltip())}_getManipulatorInfoFromHandle(e){return this._manipulatorInfos.find(t=>t.handle===e)}_updateManipulatorPositions(e){if(!this._movingManipulatorsHidden)for(const t of e)this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(t))}_updateManipulatorPosition(e){const t=this._operations;if(null!=e&&t)if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,Ge),e.manipulator.grabbing&&null!=this._vertexLaserLineVisualElement&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),n=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==i||null==n)return;const a=i.manipulator,o=n.manipulator;if("on-the-ground"===e.manipulator.elevationInfo?.mode){const i=a.location,n=o.location,s=.5,r=i.x+s*(n.x-i.x),l=i.y+s*(n.y-i.y),p=i.hasZ&&n.hasZ?0:void 0;e.manipulator.location=T(r,l,p,t.data.spatialReference)}else x(Ce,a.renderLocation,o.renderLocation,.5),e.manipulator.renderLocation=Ce}}_splitEdgeManipulator(e,t=.5){const i=this._operations,n=i.splitSegment(e.handle,t).createdVertex;e.locationUpdateHandle=p(e.locationUpdateHandle);const a=this.object.elevationInfo;let o;this.enableEdgeOffset?(this._removeManipulator(e),o=this._createVertexOrEdgeManipulator(n)):(o=e,o.handle=n,o.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,a)),"line"===n.leftSegment?.type&&this._createVertexOrEdgeManipulator(n.leftSegment),"line"===n.rightSegment?.type&&this._createVertexOrEdgeManipulator(n.rightSegment),this._updateManipulatorPosition(o),this.enableEdgeOffset||this._resetTooltip(),this._updateSelection(e.manipulator);const s=this._updateEventState(2),r=i.data.coordinateHelper.vectorToArray(o.handle.pos),l=i.data.parts.indexOf(n.part);return this.events.emit("vertex-add",{type:"vertex-add",object:this.object,vertices:[{coordinates:r,componentIndex:l,vertexIndex:n.index}],added:r}),s&&this._updateEventState(0),o}_updateMoveManipulationPosition(){const e=y(Ce,0,0,0);let t=0,i=!1,n=null,a=null;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.selected?(t++,O(e,e,r.manipulator.renderLocation),null==n||r.selectedIndex>n.selectedIndex?(a=n,n=r):(null==a||r.selectedIndex>a.selectedIndex)&&(a=r)):i=!0);const o=this.object,s=this._operations?.data.geometry;if(0===t){const e=o.visible&&this.enableMoveObject;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&N(this._operations,o.elevationInfo),this._moveManipulation.angle=W(s),this._moveManipulation.radius=K.radiusForSymbol(o.graphic?.symbol)}else{const e=o.visible;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&N(this._operations,this.object.elevationInfo),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(null!=n){const e=n.handle.pos,t=null!=a?a.handle.pos:n.handle.leftSegment?.leftVertex?n.handle.leftSegment.leftVertex.pos:null,o=null==a&&n.handle.rightSegment?.rightVertex?n.handle.rightSegment.rightVertex.pos:null;t&&o?this._moveManipulation.xyAxisManipulation.available=!1:t?i=De(t,e):o&&(i=De(e,o))}const s=n?.handle,r=s?o.getReshapeMoveConfig?.({vertex:s,numSelected:t})??null:null;switch(r?.xyAxisMode){case"all":this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e;break;case"hidden":this._moveManipulation.xyAxisManipulation.available=!1,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=!1}this._moveManipulation.angle=r?.angle??i,this._moveManipulation.radius=Y}0!==t&&i?(E(e,e,1/t),Ge.spatialReference=this._operations.data.spatialReference,Ge.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,Ge),this._moveManipulation.elevationAlignedLocation=Ge):null==this._outlineVisualElement||this.object.isDraped||null==this._outlineVisualElement.attachmentOrigin?k(this._moveManipulation,this.object):this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin}_removeVertices(e){const t=new Array,i=this._operations;if(!i)return;const n=e.filter(e=>"vertex"===e.type&&i.canRemoveVertex(e.handle.part));if(n.length>0){const e=this._createBeforeVertexRemoveEvent(n);if(this.events.emit("before-vertex-remove",e),e.defaultPrevented)return}for(const a of n){const e=a.handle.part;if(i.canRemoveVertex(e)){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftSegment)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightSegment));const n=i.removeVertices([a.handle]),o=n.removedVertices?.[0].createdSegment;o&&"line"===o.type?this._createVertexOrEdgeManipulator(o):this.enableEdgeOffset&&e.vertices.length<=2&&this._removeManipulator(this._getManipulatorInfoFromHandle(e.segments[0]))}}if(t.length>0){const e=t.map(e=>{const t=i.data.parts.indexOf(e.part);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:e.index}}),n=this._updateEventState(2);if(this.destroyed)return;if(this.events.emit("vertex-remove",{type:"vertex-remove",object:this.object,removed:e.map(e=>e.coordinates),vertices:e}),this.destroyed)return;if(n&&(this._updateEventState(0),this.destroyed))return;this._updateMoveManipulationPosition()}}_createBeforeVertexRemoveEvent(e){const t=this._operations,i=e.map(e=>{const i=t.data.parts.indexOf(e.handle.part);return{coordinates:t.data.coordinateHelper.vectorToArray(e.handle.pos),componentIndex:i,vertexIndex:e.handle.index}});let n=!1;return{type:"before-vertex-remove",object:this.object,removed:i.map(e=>e.coordinates),vertices:i,get defaultPrevented(){return n},preventDefault(){n=!0}}}_moveVertices(e,t,i=("start"===t.action?0:1)){const n=this._operations;if(n&&(e.length>0&&n.moveVertices(e.map(e=>e.handle),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i),!this._movingManipulatorsHidden))for(const a of e)this._updateManipulatorPosition(a)}_offsetEdge(e,t,i){if(!this._operations)return;const n=t.clone();n.distance=i,this._operations.updateVertices([e.handle.leftVertex,e.handle.rightVertex],n),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.rightVertex))}_manipulatorClickCallback(e,t){e.shiftKey||this._clearSelection(),"vertex"===t.type&&(t.manipulator.selected=!t.manipulator.selected,this.enableDeleteVertices&&e.button===ue.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===ue.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateTranslateTooltip(e,t){null!=this._defaultTooltipInfo?this._resetTooltip():this._updateTranslateObjectTooltip(e,t)}_updateTranslateObjectTooltip(e,t){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=se(e,t,this._tooltipsContext,this._updatingHandles))}_updateEdgeOffsetTooltip(e){this._pendingEdgeOffsetInfo||(this.activeTooltipInfo=re(this.object,e,this._tooltipsContext,this._updatingHandles))}_resetTooltip(){const e=this.activeTooltipInfo;if(this._pendingEdgeOffsetInfo&&"reshape-edge-offset"===e?.type)return;let t=null;t=this._pendingEdgeOffsetInfo||null!=this._findActiveEdgeOffsetManipulatorInfo()?re(this.object,null,this._tooltipsContext,this._updatingHandles):this._defaultTooltipInfo,t!==e&&(null!=e&&null!=t&&"input"===this.tooltip.mode||(this.activeTooltipInfo=t))}get _defaultTooltipInfo(){const e=this._operations?.data.type;switch(e){case"multipoint":case"polyline":case"polygon":return this._selectedVertexManipulatorInfo?this.tooltipInfos.selectedVertex:null;case"point":case"mesh":return this.tooltipInfos.movePoint;default:return null}}get _selectedVertexManipulatorInfo(){const e=this._manipulatorInfos.filter(e=>"vertex"===e.type&&e.manipulator.selected);return 1===e.length?e[0]:null}get _someVerticesSelected(){return this._manipulatorInfos.some(e=>"vertex"===e.type&&e.manipulator.selected)}_forEachVertex(e){for(const t of this._manipulatorInfos)"vertex"===t.type&&e(t)}get _tooltipsContext(){const{tooltipInfos:e,activeTooltipInfo:t}=this;return{sketchOptions:this._sketchOptions,tooltipInfos:e,activeTooltipInfo:t,selectedVertexManipulatorInfo:this._selectedVertexManipulatorInfo,callbacks:this._tooltipCallbacks,measurementWorker:this._measurementWorker}}get test(){}};function we(){return e=>{const{operation:t,mapEnd:i}=e;return null==t||null==i?e:{...e,signedDistance:t.signedDistanceToPoint(i)}}}function Ve(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}function De(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function Te(e){return new H({x:0,y:0,z:0,spatialReference:e})}function Ae(e){return"edge"===e.type&&"edgeManipulator"in e}e([g()],He.prototype,"_numGrabbing",void 0),e([g()],He.prototype,"_numDragging",void 0),e([g()],He.prototype,"_pendingEdgeOffsetInfo",void 0),e([g()],He.prototype,"_operations",null),e([g()],He.prototype,"_segmentLabels",void 0),e([g({constructOnly:!0})],He.prototype,"tool",void 0),e([g()],He.prototype,"tooltip",void 0),e([g()],He.prototype,"activeTooltipInfo",void 0),e([g({readOnly:!0})],He.prototype,"updating",null),e([g()],He.prototype,"manipulators",null),e([g()],He.prototype,"view",null),e([g()],He.prototype,"object",null),e([g()],He.prototype,"enableZShape",null),e([g()],He.prototype,"enableDeleteVertices",null),e([g()],He.prototype,"enableZVertex",null),e([g()],He.prototype,"autoHideManipulators",null),e([g()],He.prototype,"enableMoveObject",null),e([g()],He.prototype,"enableMidpoints",null),e([g()],He.prototype,"enableEdgeOffset",null),e([g()],He.prototype,"_sketchOptions",null),e([g()],He.prototype,"_accentColor",null),e([g()],He.prototype,"_tooltipsContext",null),He=e([_("esri.views.3d.interactive.editingTools.reshape.ReshapeOperation")],He);const Ge=T(0,0,void 0,D.WGS84),Ce=I(),Re=1e-6,Pe=16,ke=32;export{He as ReshapeOperation};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{EventEmitter as e}from"../../../../../core/Evented.js";import{makeHandle as i}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{initial as a}from"../../../../../core/reactiveUtils.js";import{property as o,subclass as n}from"../../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as s}from"../../../../../core/support/UpdatingHandles.js";import{containsXY as r}from"../../../../../geometry/support/aaBoundingRect.js";import{sm4d as l}from"../../../../../geometry/support/vectorStacks.js";import{calculateBoundedPlaneTranslateRotate as p,resizeNormal as h,resizeOutlineOnly as d}from"../../../analysis/Slice/sliceToolUtils.js";import{Manipulator3D as c}from"../../Manipulator3D.js";import{manipulatedObjectGeometry as u}from"../manipulatedObjectUtils.js";import{canMoveZOperations as m}from"../manipulatorUtils.js";import{createVisualElements as b}from"../visualElementUtils.js";import{ExtentMove as v}from"./extentTransform/ExtentMove.js";import{ExtentRotate as _}from"./extentTransform/ExtentRotate.js";import{ExtentScale as g}from"./extentTransform/ExtentScale.js";import{TransformBounds as f}from"./extentTransform/extentUtils.js";import{PreserveAspectRatio as y}from"./extentTransform/PreserveAspectRatio.js";import{SnapRotation as j}from"./extentTransform/SnapRotation.js";import{OutlineVisualElement as M}from"../../visualElements/OutlineVisualElement.js";import{InteractiveToolBase as x}from"../../../../interactive/InteractiveToolBase.js";import R from"../../../../interactive/sketch/SketchOptions.js";import{makeTooltip as E}from"../../../../interactive/tooltip/tooltipCommonUtils.js";let S=class extends x{get updating(){return!this.destroying&&!this.destroyed&&(!!this.object.updating||this._extentMove.updating||this._extentScale.updating||this._updatingHandles.updating)}constructor(t){super(t),this.events=new e,this._updatingHandles=new s,this.enableZ=!0,this.enableScaling=!0,this.enableRotation=!0,this.sketchOptions=new R,this._preserveAspectRatio=new y,this._snapRotation=new j,this.grabbing=!1,this.inputState=null,this._attachmentOrigin=null,this.type="transform-3d",this._outlineVisualElement=null}initialize(){const{view:t,object:e}=this,o=this._bounds=new f(this,()=>this._updateManipulators());this._extentMove=new v(this,o),this._extentScale=new g(this,o,()=>this._preserveAspectRatio.createDragEventPipelineStep()),this._extentRotate=new _(this,o,()=>this._snapRotation.createDragEventPipelineStep()),this.addHandles([this._updatingHandles.add(()=>this.enableZ,()=>this._updateManipulatorAvailability(this._extentMove.moveZManipulator,0)),this._updatingHandles.add(()=>this.enableScaling,()=>this._extentScale.forEachManipulator(t=>this._updateManipulatorAvailability(t,2))),this._updatingHandles.add(()=>this.enableRotation,()=>this._updateManipulatorAvailability(this._extentRotate.rotateManipulator,3))]),this._updateManipulators(),this._updateAllManipulatorAvailability();const n=b({view:t,object:e,forEachManipulator:t=>this._forEachManipulator(t),onManipulatorsChanged:()=>i()});if(null!=n){const{visualElement:t}=n;t instanceof M&&(this._outlineVisualElement=t,this.addHandles(t.events.on("attachment-origin-changed",()=>this._bounds.updateDisplayBounds()))),this.addHandles(n)}this.addHandles([e.on("committed",()=>this._onGeometryChanged()),this._updatingHandles.add(()=>this.object.visible,()=>this._updateAllManipulatorAvailability()),this._updatingHandles.add(()=>this.object.isDraped,()=>this._graphicDrapedChanged(),a),this._updatingHandles.add(()=>t.pointsOfInterest?.centerOnSurfaceFrequent.location,()=>o.updateDisplayBounds())]);const s=t=>{this.addHandles(t.events.on("grab-changed",()=>{this.grabbing=t.grabbing,this._updateAllManipulatorAvailability()}))};this._forEachManipulator(s);const r=(t,i)=>{this.addHandles(t.events.on("immediate-click",t=>{1===i&&this.events.emit("immediate-click",{...t,object:e}),t.stopPropagation()}))};this._forEachManipulator(r),this._initializeTooltip(),this.finishToolCreation()}destroy(){this._extentMove.destroy(),this._extentScale.destroy(),this._extentRotate.destroy(),this.tooltip.destroy(),this._updatingHandles.destroy(),this._set("view",null),this._set("object",null)}_initializeTooltip(){const{view:t}=this;this.tooltip=E(()=>({view:t,options:this.sketchOptions.tooltips}));const e=()=>{this.tooltip.info=this._getUpdatedTooltipInfo()};this.addHandles([this._updatingHandles.add(()=>[this.sketchOptions.tooltips.effectiveEnabled,this.preserveAspectRatio],e)]),this._forEachManipulator(t=>{this.addHandles([t.events.on(["focus-changed","grab-changed"],e),t.events.on("drag",t=>{"cancel"===t.action?this.tooltip.clear():e()})])})}_getUpdatedTooltipInfo(){return this.sketchOptions.tooltips.effectiveEnabled?this._extentMove.getUpdatedTooltipInfo()??this._extentScale.getUpdatedTooltipInfo()??this._extentRotate.getUpdatedTooltipInfo():null}_onGeometryChanged(){this._bounds.updateDisplayBounds()}_graphicDrapedChanged(){this.removeHandles(O),this._bounds.updateDisplayBounds(),this.object.isDraped&&this.addHandles(this.view.elevationProvider.on("elevation-change",t=>{null!=this._attachmentOrigin&&r(t.extent,this._attachmentOrigin.x,this._attachmentOrigin.y)&&this._bounds.updateDisplayBounds()}),O)}_updateManipulators(){if(!this.visible)return;const t=this._bounds.displayBounds,e=p(t,l.get());this._extentMove.updateManipulators(e,t),this._extentScale.updateManipulators(e,t),this._extentRotate.updateManipulators(e,t)}_updateAllManipulatorAvailability(){this._forEachManipulator((t,e)=>this._updateManipulatorAvailability(t,e))}_updateManipulatorAvailability(t,e){const i=this.grabbing&&!t.grabbing;if(t.interactive=!i,t instanceof c){const a=this.object.visible,o=this.enableZ&&m(this.object.operations,this.object.elevationInfo);switch(e){case 3:t.available=a&&this.enableRotation;break;case 2:t.available=a&&(this.enableScaling||this.enableRotation||o),t.interactive=!i&&this.enableScaling,t.state=this.enableScaling?h:d;break;case 0:t.available=a&&o;break;default:t.available=a}}}_forEachManipulator(t){this._extentMove.forEachManipulator(t),this._extentScale.forEachManipulator(t),this._extentRotate.forEachManipulator(t)}get preserveAspectRatio(){return this._preserveAspectRatio.enabled}set preserveAspectRatio(t){this._preserveAspectRatio.enabled=t,this._set("preserveAspectRatio",t)}get snapRotation(){return this._snapRotation.enabled}set snapRotation(t){this._snapRotation.enabled=t,this._set("snapRotation",t)}get attachmentOrigin(){const t=this.object.isDraped?null:this._outlineVisualElement?.attachmentOrigin;return this._attachmentOrigin=t??this.object.origin??u(this.object)?.extent?.center,this._attachmentOrigin}reset(){}cancelDrag(){if(this.canUndo){const t=this.object.operations?.undo();t&&this._bounds.updateMapBoundsFromOperationInverse(t)}this.inputState=null}get canUndo(){return!!this.object.operations?.canUndo}undo(){if(null!=this.inputState)this.view.activeTool=null;else if(this.canUndo){const t=this.object.operations?.undo();t&&this._bounds.updateMapBoundsFromOperationInverse(t)}}get canRedo(){return!!this.object.operations?.canRedo}redo(){if(this.canRedo){const t=this.object.operations?.redo();t&&this._bounds.updateMapBoundsFromOperation(t)}}get test(){}};t([o()],S.prototype,"updating",null),t([o({constructOnly:!0,nonNullable:!0})],S.prototype,"view",void 0),t([o({constructOnly:!0,nonNullable:!0})],S.prototype,"object",void 0),t([o()],S.prototype,"enableZ",void 0),t([o()],S.prototype,"enableScaling",void 0),t([o()],S.prototype,"enableRotation",void 0),t([o({constructOnly:!0,type:R})],S.prototype,"sketchOptions",void 0),t([o()],S.prototype,"preserveAspectRatio",null),t([o()],S.prototype,"snapRotation",null),t([o()],S.prototype,"grabbing",void 0),t([o()],S.prototype,"inputState",void 0),t([o({readOnly:!0})],S.prototype,"type",void 0),t([o()],S.prototype,"tooltip",void 0),S=t([n("esri.views.3d.interactive.editingTools.transform.ExtentTransformTool")],S);const O="draped-elevation-changes";export{S as ExtentTransformTool};
2
+ import{__decorate as t}from"tslib";import{isSome as e}from"../../../../../core/arrayUtils.js";import{EventEmitter as i}from"../../../../../core/Evented.js";import{makeHandle as a}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{initial as o}from"../../../../../core/reactiveUtils.js";import{property as n,subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as r}from"../../../../../core/support/UpdatingHandles.js";import{containsXY as l}from"../../../../../geometry/support/aaBoundingRect.js";import{sm4d as p}from"../../../../../geometry/support/vectorStacks.js";import{calculateBoundedPlaneTranslateRotate as h,resizeNormal as d,resizeOutlineOnly as c}from"../../../analysis/Slice/sliceToolUtils.js";import{Manipulator3D as u}from"../../Manipulator3D.js";import{manipulatedObjectGeometry as m}from"../manipulatedObjectUtils.js";import{canMoveZOperations as _}from"../manipulatorUtils.js";import{createVisualElements as b}from"../visualElementUtils.js";import{ExtentMove as v}from"./extentTransform/ExtentMove.js";import{ExtentRotate as g}from"./extentTransform/ExtentRotate.js";import{ExtentScale as f}from"./extentTransform/ExtentScale.js";import{TransformBounds as y}from"./extentTransform/extentUtils.js";import{PreserveAspectRatio as M}from"./extentTransform/PreserveAspectRatio.js";import{SnapRotation as j}from"./extentTransform/SnapRotation.js";import{OutlineVisualElement as x}from"../../visualElements/OutlineVisualElement.js";import{InteractiveToolBase as R}from"../../../../interactive/InteractiveToolBase.js";import E from"../../../../interactive/sketch/SketchOptions.js";import{makeTooltip as S}from"../../../../interactive/tooltip/tooltipCommonUtils.js";let O=class extends R{get updating(){return!this.destroying&&!this.destroyed&&(!!this.object.updating||this._extentMove.updating||this._extentScale.updating||this._updatingHandles.updating)}constructor(t){super(t),this.events=new i,this._updatingHandles=new r,this.enableZ=!0,this.enableScaling=!0,this.enableRotation=!0,this.sketchOptions=new E,this._preserveAspectRatio=new M,this._snapRotation=new j,this.grabbing=!1,this.inputState=null,this._attachmentOrigin=null,this.type="transform-3d",this._outlineVisualElement=null}initialize(){const{view:t,object:e}=this,i=this._bounds=new y(this,()=>this._updateManipulators());this._extentMove=new v(this,i),this._extentScale=new f(this,i,()=>this._preserveAspectRatio.createDragEventPipelineStep()),this._extentRotate=new g(this,i,()=>this._snapRotation.createDragEventPipelineStep()),this.addHandles([this._updatingHandles.add(()=>this.enableZ,()=>this._updateManipulatorAvailability(this._extentMove.moveZManipulator,0)),this._updatingHandles.add(()=>this.enableScaling,()=>this._extentScale.forEachManipulator(t=>this._updateManipulatorAvailability(t,2))),this._updatingHandles.add(()=>this.enableRotation,()=>this._updateManipulatorAvailability(this._extentRotate.rotateManipulator,3))]),this._updateManipulators(),this._updateAllManipulatorAvailability();const n=b({view:t,object:e,forEachManipulator:t=>this._forEachManipulator(t),onManipulatorsChanged:()=>a()});if(null!=n){const{visualElement:t}=n;t instanceof x&&(this._outlineVisualElement=t,this.addHandles(t.events.on("attachment-origin-changed",()=>this._bounds.updateDisplayBounds()))),this.addHandles(n)}this.addHandles([e.on("committed",()=>this._onGeometryChanged()),this._updatingHandles.add(()=>this.object.visible,()=>this._updateAllManipulatorAvailability()),this._updatingHandles.add(()=>this.object.isDraped,()=>this._graphicDrapedChanged(),o),this._updatingHandles.add(()=>t.pointsOfInterest?.centerOnSurfaceFrequent.location,()=>i.updateDisplayBounds())]);const s=t=>{this.addHandles(t.events.on("grab-changed",()=>{this._updateAllManipulatorAvailability()}))};this._forEachManipulator(s);const r=(t,i)=>{this.addHandles(t.events.on("immediate-click",t=>{1===i&&this.events.emit("immediate-click",{...t,object:e}),t.stopPropagation()}))};this._forEachManipulator(r),this._initializeTooltip(),this.finishToolCreation()}destroy(){this._extentMove.destroy(),this._extentScale.destroy(),this._extentRotate.destroy(),this.tooltip.destroy(),this._updatingHandles.destroy(),this._set("view",null),this._set("object",null)}_initializeTooltip(){const{view:t}=this;this.tooltip=S(()=>({view:t,options:this.sketchOptions.tooltips}));const e=()=>{this.tooltip.info=this._getUpdatedTooltipInfo()};this.addHandles([this._updatingHandles.add(()=>[this.sketchOptions.tooltips.effectiveEnabled,this.preserveAspectRatio],e)]),this._forEachManipulator(t=>{this.addHandles([t.events.on(["focus-changed","grab-changed"],e),t.events.on("drag",t=>{"cancel"===t.action?this.tooltip.clear():e()})])})}_getUpdatedTooltipInfo(){return this.sketchOptions.tooltips.effectiveEnabled?this._extentMove.getUpdatedTooltipInfo()??this._extentScale.getUpdatedTooltipInfo()??this._extentRotate.getUpdatedTooltipInfo():null}_onGeometryChanged(){this._bounds.updateDisplayBounds()}_graphicDrapedChanged(){this.removeHandles(T),this._bounds.updateDisplayBounds(),this.object.isDraped&&this.addHandles(this.view.elevationProvider.on("elevation-change",t=>{null!=this._attachmentOrigin&&l(t.extent,this._attachmentOrigin.x,this._attachmentOrigin.y)&&this._bounds.updateDisplayBounds()}),T)}_updateManipulators(){if(!this.visible)return;const t=this._bounds.displayBounds,e=h(t,p.get());this._extentMove.updateManipulators(e,t),this._extentScale.updateManipulators(e,t),this._extentRotate.updateManipulators(e,t)}_updateAllManipulatorAvailability(){this.grabbing=null!=this._activeManipulatorType(),this._forEachManipulator((t,e)=>this._updateManipulatorAvailability(t,e)),this._updateManipulatorDisplay()}_updateManipulatorAvailability(t,e){const i=this.grabbing&&!t.grabbing;if(t.interactive=!i,t instanceof u){const a=this.object.visible,o=this.enableZ&&_(this.object.operations,this.object.elevationInfo);switch(e){case 3:t.available=a&&this.enableRotation;break;case 2:t.available=a&&(this.enableScaling||this.enableRotation||o),t.interactive=!i&&this.enableScaling,t.state=!this.enableScaling||this.grabbing&&2!==this._activeManipulatorType()?c:d;break;case 0:t.available=a&&o;break;default:t.available=a}}}_activeManipulatorType(){let t=null;return this._forEachManipulator(({grabbing:e},i)=>{null==t&&e&&(t=i)}),t}_updateManipulatorDisplay(){this.removeHandles(A);if(null==this._activeManipulatorType())return;const t=[];this._forEachManipulator((e,i)=>{e.grabbing||3!==i&&0!==i||t.push(e.disableDisplay?.())}),this.addHandles(t.filter(e),A)}_forEachManipulator(t){this._extentMove.forEachManipulator(t),this._extentScale.forEachManipulator(t),this._extentRotate.forEachManipulator(t)}get preserveAspectRatio(){return this._preserveAspectRatio.enabled}set preserveAspectRatio(t){this._preserveAspectRatio.enabled=t,this._set("preserveAspectRatio",t)}get snapRotation(){return this._snapRotation.enabled}set snapRotation(t){this._snapRotation.enabled=t,this._set("snapRotation",t)}get attachmentOrigin(){const t=this.object.isDraped?null:this._outlineVisualElement?.attachmentOrigin;return this._attachmentOrigin=t??this.object.origin??m(this.object)?.extent?.center,this._attachmentOrigin}reset(){}cancelDrag(){if(this.canUndo){const t=this.object.operations?.undo();t&&this._bounds.updateMapBoundsFromOperationInverse(t)}this.inputState=null}get canUndo(){return!!this.object.operations?.canUndo}undo(){if(null!=this.inputState)this.view.activeTool=null;else if(this.canUndo){const t=this.object.operations?.undo();t&&this._bounds.updateMapBoundsFromOperationInverse(t)}}get canRedo(){return!!this.object.operations?.canRedo}redo(){if(this.canRedo){const t=this.object.operations?.redo();t&&this._bounds.updateMapBoundsFromOperation(t)}}get test(){}};t([n()],O.prototype,"updating",null),t([n({constructOnly:!0,nonNullable:!0})],O.prototype,"view",void 0),t([n({constructOnly:!0,nonNullable:!0})],O.prototype,"object",void 0),t([n()],O.prototype,"enableZ",void 0),t([n()],O.prototype,"enableScaling",void 0),t([n()],O.prototype,"enableRotation",void 0),t([n({constructOnly:!0,type:E})],O.prototype,"sketchOptions",void 0),t([n()],O.prototype,"preserveAspectRatio",null),t([n()],O.prototype,"snapRotation",null),t([n()],O.prototype,"grabbing",void 0),t([n()],O.prototype,"inputState",void 0),t([n({readOnly:!0})],O.prototype,"type",void 0),t([n()],O.prototype,"tooltip",void 0),O=t([s("esri.views.3d.interactive.editingTools.transform.ExtentTransformTool")],O);const T="draped-elevation-changes",A=Symbol();export{O as ExtentTransformTool};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../../../core/Accessor.js";import{multiplyOpacityToUnitRGBA as a}from"../../../../../core/colorUtils.js";import{cyclicalPI as o}from"../../../../../core/Cyclical.js";import{EventEmitter as i}from"../../../../../core/Evented.js";import"../../../../../core/has.js";import{clamp as r,rad2deg as s}from"../../../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../../../core/maybe.js";import{watch as l,initial as c}from"../../../../../core/reactiveUtils.js";import{addFrameTask as d}from"../../../../../core/scheduling.js";import{createScreenPointArray as h}from"../../../../../core/screenUtils.js";import{property as u,subclass as p}from"../../../../../core/accessorSupport/decorators.js";import{fromRotation as g,fromScaling as m,multiply as f,scale as _,rotate as D}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as M}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as v,subtract as S,length as b,squaredDistance as y,cross as j,add as R}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as w,clone as A}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromPositionAndNormal as I,create as F,getNormal as k}from"../../../../../geometry/support/plane.js";import{wrap as E,distance2 as O}from"../../../../../geometry/support/ray.js";import{sm4d as P,sv3d as T}from"../../../../../geometry/support/vectorStacks.js";import{Manipulator3D as x}from"../../Manipulator3D.js";import{calculateInputRotationTransform as U}from"../../manipulatorUtils.js";import{RenderObject as L}from"../../RenderObject.js";import{screenToRenderPlane as C}from"../dragEventPipeline3D.js";import{ringIndicatorDelayMs as H,rotateIndicatorArrowPlacementPercentage as z,ringThickness as G,ringRadius as q,innerIndicatorRadius as B,outerIndicatorRadius as J,rotateIndicatorArrowTipRadius as K,rotateIndicatorArrowTipLength as N,scaleIndicatorOffset1 as Q,scaleIndicatorOffset2 as V,indicatorThickness as W,geometrySegments as X,rotateIndicatorArcLength as Y,scaleIndicatorArcLength as Z,rotateIndicatorDirectionBuffer as $,scaleIndicatorDirectionBuffer as tt,ringHeight as et,dragThresholdPx as at,ringResetAnimationSpeedFactor as ot}from"../manipulations/config.js";import{createExtrudedTriangle as it,transformInPlace as rt,createPathExtrusionGeometry as st}from"../../../webgl-engine/lib/GeometryUtil.js";import{ColorMaterial as nt}from"../../../webgl-engine/materials/ColorMaterial.js";import{createManipulatorDragEventPipeline as lt}from"../../../../interactive/dragEventPipeline.js";const ct={ScaleIn:32,ScaleOut:64,RotateLeft:128,RotateRight:256,Unlocked:1024,DelayedFocused:2048};let dt=class extends e{get angle(){return this.adapter.angle}get scale(){return this.adapter.scale}set location(t){this._ringManipulator.location=t}set elevationAlignedLocation(t){this._ringManipulator.elevationAlignedLocation=t}get grabbing(){return this._ringManipulator.grabbing}set interactive(t){this._ringManipulator.interactive=t}get updating(){return!!this._activeAnimation}constructor(t){super(t),this.mode=null,this._scaleRotateDragData=null,this._activeAnimation=null,this._ringIndicatorDelayMs=H,this.events=new i,this.getFocused=()=>this._ringManipulator.focused,this.getScale=()=>"scale"===this._scaleRotateDragData?.mode?this.adapter.scale:1}initialize(){this._createManipulator(),this._updateDragState(),this._updateManipulatorTransform(),this.addHandles([l(()=>{const{adapter:t}=this;return[t.angle,t.scale]},()=>this._updateManipulatorTransform())])}destroy(){this._activeAnimation?.frameTask.remove(),this._activeAnimation=null,this.tool.manipulators.remove(this._ringManipulator),this._ringManipulator=null}startAnimation(t){this.cancelActiveAnimation(),t.start();const e=d({update:({deltaTime:e})=>{t.update(e)&&this.cancelActiveAnimation()}});this._activeAnimation={...t,frameTask:e}}cancelActiveAnimation(){this._activeAnimation?.frameTask.remove(),this._activeAnimation=n(this._activeAnimation)}forEachManipulator(t){t(this._ringManipulator,4)}_createManipulator(){const t=this._createRingManipulator();this._ringManipulator=t,this.tool.manipulators.add(t);const e=this.tool.object,a=lt(t,(t,a,i)=>{this._scaleRotateDragData=null;const n=this.adapter.startInteraction(),l={mode:"none",origin:A(t.renderLocation),initialAngle:this.adapter.angle,angle:0,angleDir:0,scaleDir:0};this._scaleRotateDragData=l,this._updateDragState();const c=T.get();this.tool.view.renderCoordsHelper.worldUpAtPosition(t.renderLocation,c),a.next(C(this.tool.view,I(t.renderLocation,c,F()))).next(t=>{const a=k(t.plane),i=U(t.renderStart,t.renderEnd,l.origin,a),c=o.shortestSignedDiff(l.angle,i);l.angleDir=r(l.angleDir+c,-.3,$),l.angle=i;const d=ht(l,t),h=d-this.adapter.scale;if(l.scaleDir=r(l.scaleDir+h,-.2,tt),this._onScaleChanged(),"none"===l.mode){const a=this.mode||ut(t,t.plane,l.origin,this.tool.view.state.camera);if(null!=a){switch(a){case"rotate":this.tool.events.emit("rotate-start",{object:e,angle:0}),this.tool.events.emit("record-undo",{updates:[this.adapter.createUndoRecord()]});break;case"scale":this.tool.events.emit("scale-start",{object:e,xScale:1,yScale:1}),this.tool.events.emit("record-undo",{updates:[this.adapter.createUndoRecord()]})}l.mode=a}}switch(l.mode){case"rotate":n.state.angle=l.initialAngle+i;break;case"scale":n.state.scale=d,this._onScaleChanged()}switch(this._updateDragState(),this._updateManipulatorTransform(),t.action){case"start":case"update":switch(l.mode){case"rotate":this.tool.events.emit("rotate",{object:e,angle:s(l.angle)});break;case"scale":this.tool.events.emit("scale",{object:e,xScale:d,yScale:d})}break;case"end":switch(l.mode){case"rotate":this.tool.events.emit("rotate-stop",{object:e,angle:s(l.angle)});break;case"scale":this.tool.events.emit("scale-stop",{object:e,xScale:d,yScale:d})}}return"end"===t.action&&(this.startAnimation(gt(this,()=>this._onScaleChanged())),this._scaleRotateDragData=null,this._updateDragState(),n.done()),t}),i.next(()=>{if(n.cancel(),null!=this._scaleRotateDragData){switch(this._scaleRotateDragData.mode){case"none":break;case"rotate":this.tool.events.emit("rotate-stop",{object:e,angle:0});break;case"scale":this.tool.events.emit("scale-stop",{object:e,xScale:1,yScale:1})}this.startAnimation(gt(this,()=>this._onScaleChanged())),this._scaleRotateDragData=null,this._updateDragState()}})});this.addHandles([a,t.events.on("focus-changed",t=>{"focus"===t.action?this.startAnimation(mt(this,()=>this._updateDelayedFocusedState(),{delayMs:this._ringIndicatorDelayMs})):this._updateDelayedFocusedState()}),t.events.on("immediate-click",t=>{t.stopPropagation()}),l(()=>this.tool.object.visible,t=>this._ringManipulator.available=t,c)])}_onScaleChanged(){this.events.emit("scale-changed"),this._updateManipulatorTransform()}_updateDelayedFocusedState(){this._ringManipulator.updateStateEnabled(ct.DelayedFocused,this.getFocused())}_updateDragState(){if(this._ringManipulator.updateStateEnabled(ct.Unlocked,!(null!=this._scaleRotateDragData&&"none"!==this._scaleRotateDragData?.mode)),null!=this._scaleRotateDragData)switch(this._scaleRotateDragData.mode){case"rotate":this._ringManipulator.updateStateEnabled(ct.ScaleIn|ct.ScaleOut,!1),this._ringManipulator.updateStateEnabled(ct.RotateLeft,this._scaleRotateDragData.angleDir<0),this._ringManipulator.updateStateEnabled(ct.RotateRight,this._scaleRotateDragData.angleDir>=0);break;case"scale":this._ringManipulator.updateStateEnabled(ct.RotateLeft|ct.RotateRight,!1),this._ringManipulator.updateStateEnabled(ct.ScaleIn,this._scaleRotateDragData.scaleDir<0),this._ringManipulator.updateStateEnabled(ct.ScaleOut,this._scaleRotateDragData.scaleDir>=0)}else this._ringManipulator.updateStateEnabled(ct.ScaleIn|ct.ScaleOut|ct.RotateLeft|ct.RotateRight,!1)}_updateManipulatorTransform(){const t=g(P.get(),this.adapter.angle,w(0,0,1));if(null==t)return;const e=this.getScale(),a=m(P.get(),v(T.get(),e,e,e));this._ringManipulator.modelTransform=f(P.get(),a,t)}_createRingManipulator(){const t=(t,e,a)=>{const o=[],i=Math.ceil(X*(e-t)/(2*Math.PI));for(let r=0;r<i+1;r++){const s=t+r*(e-t)/i;o.push(w(a*Math.cos(s),a*Math.sin(s),0))}return o},e=e=>t(0,2*Math.PI,e),a=t=>[[-t/2,0],[t/2,0],[t/2,et/2],[-t/2,et/2]],o=this._createMaterial(1),i=(t,e,i=o)=>st(i,a(e),t,[],[],!1),r=e(q),s=i(r,G),n={left:new Array,right:new Array},l=[];for(let w=0;w<2;w++){const e=w*Math.PI-Math.PI/4,a=Math.PI/2-Y,r=e+a,s=e+Math.PI/2-a,c=t(r,s,B),d=i(c,W);l.push(c),l.push(t(r,s,J-G/2)),n.left.push(d),n.right.push(d.instantiate());for(let t=0;t<2;t++){const e=0===t,a=M();if(e){_(a,a,[1,-1,1]),D(a,a,-r,[0,0,1]);const t=Math.round(z*(c.length-1));a[12]=c[t][0],a[13]=c[t][1],a[14]=c[t][2]}else{D(a,a,s,[0,0,1]);const t=Math.round((1-z)*(c.length-1));a[12]=c[t][0],a[13]=c[t][1],a[14]=c[t][2]}const i=it(o,N,0,K,et);rt(i,a),(e?n.left:n.right).push(i)}}const c=[];for(let _=0;_<2;_++){const e=_*Math.PI-Math.PI/4,a=Math.PI/2-Z,o=e+a,r=e+Math.PI/2-a,s=t(o,r,J);c.push(i(s,W))}const d=this._createMaterial(.66),h=this._createMaterial(.5),u=this._createMaterial(.33),p=e(q+Q),g=e(q+V),m=i(p,W,d),f=i(g,W,u),v=e(q-Q),S=e(q-V),b=i(v,W,d),y=i(S,W,u);let j=[new L(s,ct.DelayedFocused),new L(s.instantiate({material:h}),0)];this.mode&&"scale"!==this.mode||(j=j.concat([...c.map(t=>new L(t,ct.DelayedFocused|ct.Unlocked)),new L(m,ct.DelayedFocused|ct.ScaleIn),new L(f,ct.DelayedFocused|ct.ScaleIn),new L(b,ct.DelayedFocused|ct.ScaleOut),new L(y,ct.DelayedFocused|ct.ScaleOut)])),this.mode&&"rotate"!==this.mode||(j=j.concat([...n.right.map(t=>new L(t.instantiate(),ct.DelayedFocused|ct.Unlocked)),...n.left.map(t=>new L(t,ct.DelayedFocused|ct.RotateLeft)),...n.right.map(t=>new L(t,ct.DelayedFocused|ct.RotateRight))]));const R=[r,...l];return new x({view:this.tool.view,renderObjects:j,autoScaleRenderObjects:!1,worldOriented:!0,radius:G,focusMultiplier:1,touchMultiplier:1.5,elevationInfo:this.tool.object.elevationInfo,collisionType:{type:"ribbon",paths:R,direction:w(0,0,1)}})}_createMaterial(t){const e=new nt({cullFace:2,renderOccluded:2,isDecoration:!0});return this.addHandles(l(()=>a(this.tool.view.effectiveTheme.accentColor,t),t=>e.setParameters({color:t}),c)),e}get test(){}};function ht(t,e){const a=S(T.get(),e.renderStart,t.origin),o=S(T.get(),e.renderEnd,t.origin),i=b(a),r=b(o);return 0===i?0:r/i}function ut(t,e,a,o){const{renderStart:i,renderEnd:r}=t,s=pt(i,o,T.get()),n=pt(r,o,T.get());if(y(s,n)<at*at)return null;const l=S(T.get(),i,a),c=j(T.get(),l,k(e)),d=i,h=R(T.get(),d,c),u=pt(a,o,T.get()),p=s,g=pt(h,o,T.get()),m=S(T.get(),g,p),f=S(T.get(),s,u),_=E(p,m),D=E(u,f);return O(_,n)<O(D,n)?"rotate":"scale"}function pt(t,e,a){return e.projectToScreen(t,ft),v(a,ft[0],ft[1],0)}function gt(t,e){let a=null,o=1;const i=()=>o;return{start:()=>{o=t.getScale(),a=t.getScale,t.getScale=i,e()},update:t=>(o+=((o+1)/2-o)*Math.min(t*ot,1),e(),Math.abs(o-1)<.01?1:0),destroy:()=>{a&&(t.getScale=a),e()}}}function mt(t,e,a){let o=0,i=null;const r=()=>!1;return{start:()=>{i=t.getFocused,t.getFocused=r,o=0,e()},update:t=>(o+=t,!i?.()||o>=a.delayMs?1:0),destroy:()=>{i&&(t.getFocused=i),e()}}}t([u({constructOnly:!0})],dt.prototype,"tool",void 0),t([u({constructOnly:!0})],dt.prototype,"adapter",void 0),t([u({constructOnly:!0})],dt.prototype,"sketchOptions",void 0),t([u()],dt.prototype,"mode",void 0),t([u()],dt.prototype,"_activeAnimation",void 0),t([u()],dt.prototype,"updating",null),dt=t([p("esri.views.3d.interactive.editingTools.transform.ScaleRotateTransform")],dt);const ft=h();export{dt as ScaleRotateTransform};
2
+ import{__decorate as t}from"tslib";import e from"../../../../../core/Accessor.js";import{multiplyOpacityToUnitRGBA as a}from"../../../../../core/colorUtils.js";import{cyclicalPI as i}from"../../../../../core/Cyclical.js";import{EventEmitter as o}from"../../../../../core/Evented.js";import"../../../../../core/has.js";import{clamp as r,rad2deg as s}from"../../../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../../../core/maybe.js";import{watch as l,initial as c}from"../../../../../core/reactiveUtils.js";import{addFrameTask as d}from"../../../../../core/scheduling.js";import{createScreenPointArray as h}from"../../../../../core/screenUtils.js";import{property as u,subclass as p}from"../../../../../core/accessorSupport/decorators.js";import{fromRotation as g,fromScaling as m,multiply as f,scale as _,rotate as D}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as M}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as v,subtract as S,length as b,squaredDistance as y,cross as j,add as R}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as w,clone as A}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromPositionAndNormal as I,create as F,getNormal as k}from"../../../../../geometry/support/plane.js";import{wrap as E,distance2 as O}from"../../../../../geometry/support/ray.js";import{sm4d as P,sv3d as T}from"../../../../../geometry/support/vectorStacks.js";import{Manipulator3D as x}from"../../Manipulator3D.js";import{calculateInputRotationTransform as U}from"../../manipulatorUtils.js";import{RenderObject as L}from"../../RenderObject.js";import{screenToRenderPlane as C}from"../dragEventPipeline3D.js";import{ringIndicatorDelayMs as H,rotateIndicatorArrowPlacementPercentage as z,ringThickness as G,ringRadius as q,innerIndicatorRadius as B,outerIndicatorRadius as J,rotateIndicatorArrowTipRadius as K,rotateIndicatorArrowTipLength as N,scaleIndicatorOffset1 as Q,scaleIndicatorOffset2 as V,indicatorThickness as W,geometrySegments as X,rotateIndicatorArcLength as Y,scaleIndicatorArcLength as Z,rotateIndicatorDirectionBuffer as $,scaleIndicatorDirectionBuffer as tt,ringHeight as et,dragThresholdPx as at,ringResetAnimationSpeedFactor as it}from"../manipulations/config.js";import{createExtrudedTriangle as ot,transformInPlace as rt,createPathExtrusionGeometry as st}from"../../../webgl-engine/lib/GeometryUtil.js";import{ColorMaterial as nt}from"../../../webgl-engine/materials/ColorMaterial.js";import{createManipulatorDragEventPipeline as lt}from"../../../../interactive/dragEventPipeline.js";const ct={ScaleIn:32,ScaleOut:64,RotateLeft:128,RotateRight:256,Unlocked:1024,DelayedFocused:2048};let dt=class extends e{get angle(){return this.adapter.angle}get scale(){return this.adapter.scale}set location(t){this._ringManipulator.location=t}set elevationAlignedLocation(t){this._ringManipulator.elevationAlignedLocation=t}get grabbing(){return this._ringManipulator.grabbing}set interactive(t){this._ringManipulator.interactive=t}get updating(){return!!this._activeAnimation}constructor(t){super(t),this.mode=null,this._scaleRotateDragData=null,this._activeAnimation=null,this._ringIndicatorDelayMs=H,this.events=new o,this.getFocused=()=>this._ringManipulator.focused,this.getScale=()=>"scale"===this._scaleRotateDragData?.mode?this.adapter.scale:1}initialize(){this._createManipulator(),this._updateDragState(),this._updateManipulatorTransform(),this.addHandles([l(()=>{const{adapter:t}=this;return[t.angle,t.scale]},()=>this._updateManipulatorTransform())])}destroy(){this._activeAnimation?.frameTask.remove(),this._activeAnimation=null,this.tool.manipulators.remove(this._ringManipulator),this._ringManipulator=null}startAnimation(t){this.cancelActiveAnimation(),t.start();const e=d({update:({deltaTime:e})=>{t.update(e)&&this.cancelActiveAnimation()}});this._activeAnimation={...t,frameTask:e}}cancelActiveAnimation(){this._activeAnimation?.frameTask.remove(),this._activeAnimation=n(this._activeAnimation)}forEachManipulator(t){t(this._ringManipulator,4)}disableDisplay(){return this._ringManipulator.disableDisplay()}_createManipulator(){const t=this._createRingManipulator();this._ringManipulator=t,this.tool.manipulators.add(t);const e=this.tool.object,a=lt(t,(t,a,o)=>{this._scaleRotateDragData=null;const n=this.adapter.startInteraction(),l={mode:"none",origin:A(t.renderLocation),initialAngle:this.adapter.angle,angle:0,angleDir:0,scaleDir:0};this._scaleRotateDragData=l,this._updateDragState();const c=T.get();this.tool.view.renderCoordsHelper.worldUpAtPosition(t.renderLocation,c),a.next(C(this.tool.view,I(t.renderLocation,c,F()))).next(t=>{const a=k(t.plane),o=U(t.renderStart,t.renderEnd,l.origin,a),c=i.shortestSignedDiff(l.angle,o);l.angleDir=r(l.angleDir+c,-.3,$),l.angle=o;const d=ht(l,t),h=d-this.adapter.scale;if(l.scaleDir=r(l.scaleDir+h,-.2,tt),this._onScaleChanged(),"none"===l.mode){const a=this.mode||ut(t,t.plane,l.origin,this.tool.view.state.camera);if(null!=a){switch(a){case"rotate":this.tool.events.emit("rotate-start",{object:e,angle:0}),this.tool.events.emit("record-undo",{updates:[this.adapter.createUndoRecord()]});break;case"scale":this.tool.events.emit("scale-start",{object:e,xScale:1,yScale:1}),this.tool.events.emit("record-undo",{updates:[this.adapter.createUndoRecord()]})}l.mode=a}}switch(l.mode){case"rotate":n.state.angle=l.initialAngle+o;break;case"scale":n.state.scale=d,this._onScaleChanged()}switch(this._updateDragState(),this._updateManipulatorTransform(),t.action){case"start":case"update":switch(l.mode){case"rotate":this.tool.events.emit("rotate",{object:e,angle:s(l.angle)});break;case"scale":this.tool.events.emit("scale",{object:e,xScale:d,yScale:d})}break;case"end":switch(l.mode){case"rotate":this.tool.events.emit("rotate-stop",{object:e,angle:s(l.angle)});break;case"scale":this.tool.events.emit("scale-stop",{object:e,xScale:d,yScale:d})}}return"end"===t.action&&(this.startAnimation(gt(this,()=>this._onScaleChanged())),this._scaleRotateDragData=null,this._updateDragState(),n.done()),t}),o.next(()=>{if(n.cancel(),null!=this._scaleRotateDragData){switch(this._scaleRotateDragData.mode){case"none":break;case"rotate":this.tool.events.emit("rotate-stop",{object:e,angle:0});break;case"scale":this.tool.events.emit("scale-stop",{object:e,xScale:1,yScale:1})}this.startAnimation(gt(this,()=>this._onScaleChanged())),this._scaleRotateDragData=null,this._updateDragState()}})});this.addHandles([a,t.events.on("focus-changed",t=>{"focus"===t.action?this.startAnimation(mt(this,()=>this._updateDelayedFocusedState(),{delayMs:this._ringIndicatorDelayMs})):this._updateDelayedFocusedState()}),t.events.on("immediate-click",t=>{t.stopPropagation()}),l(()=>this.tool.object.visible,t=>this._ringManipulator.available=t,c)])}_onScaleChanged(){this.events.emit("scale-changed"),this._updateManipulatorTransform()}_updateDelayedFocusedState(){this._ringManipulator.updateStateEnabled(ct.DelayedFocused,this.getFocused())}_updateDragState(){if(this._ringManipulator.updateStateEnabled(ct.Unlocked,!(null!=this._scaleRotateDragData&&"none"!==this._scaleRotateDragData?.mode)),null!=this._scaleRotateDragData)switch(this._scaleRotateDragData.mode){case"rotate":this._ringManipulator.updateStateEnabled(ct.ScaleIn|ct.ScaleOut,!1),this._ringManipulator.updateStateEnabled(ct.RotateLeft,this._scaleRotateDragData.angleDir<0),this._ringManipulator.updateStateEnabled(ct.RotateRight,this._scaleRotateDragData.angleDir>=0);break;case"scale":this._ringManipulator.updateStateEnabled(ct.RotateLeft|ct.RotateRight,!1),this._ringManipulator.updateStateEnabled(ct.ScaleIn,this._scaleRotateDragData.scaleDir<0),this._ringManipulator.updateStateEnabled(ct.ScaleOut,this._scaleRotateDragData.scaleDir>=0)}else this._ringManipulator.updateStateEnabled(ct.ScaleIn|ct.ScaleOut|ct.RotateLeft|ct.RotateRight,!1)}_updateManipulatorTransform(){const t=g(P.get(),this.adapter.angle,w(0,0,1));if(null==t)return;const e=this.getScale(),a=m(P.get(),v(T.get(),e,e,e));this._ringManipulator.modelTransform=f(P.get(),a,t)}_createRingManipulator(){const t=(t,e,a)=>{const i=[],o=Math.ceil(X*(e-t)/(2*Math.PI));for(let r=0;r<o+1;r++){const s=t+r*(e-t)/o;i.push(w(a*Math.cos(s),a*Math.sin(s),0))}return i},e=e=>t(0,2*Math.PI,e),a=t=>[[-t/2,0],[t/2,0],[t/2,et/2],[-t/2,et/2]],i=this._createMaterial(1),o=(t,e,o=i)=>st(o,a(e),t,[],[],!1),r=e(q),s=o(r,G),n={left:new Array,right:new Array},l=[];for(let w=0;w<2;w++){const e=w*Math.PI-Math.PI/4,a=Math.PI/2-Y,r=e+a,s=e+Math.PI/2-a,c=t(r,s,B),d=o(c,W);l.push(c),l.push(t(r,s,J-G/2)),n.left.push(d),n.right.push(d.instantiate());for(let t=0;t<2;t++){const e=0===t,a=M();if(e){_(a,a,[1,-1,1]),D(a,a,-r,[0,0,1]);const t=Math.round(z*(c.length-1));a[12]=c[t][0],a[13]=c[t][1],a[14]=c[t][2]}else{D(a,a,s,[0,0,1]);const t=Math.round((1-z)*(c.length-1));a[12]=c[t][0],a[13]=c[t][1],a[14]=c[t][2]}const o=ot(i,N,0,K,et);rt(o,a),(e?n.left:n.right).push(o)}}const c=[];for(let _=0;_<2;_++){const e=_*Math.PI-Math.PI/4,a=Math.PI/2-Z,i=e+a,r=e+Math.PI/2-a,s=t(i,r,J);c.push(o(s,W))}const d=this._createMaterial(.66),h=this._createMaterial(.5),u=this._createMaterial(.33),p=e(q+Q),g=e(q+V),m=o(p,W,d),f=o(g,W,u),v=e(q-Q),S=e(q-V),b=o(v,W,d),y=o(S,W,u);let j=[new L(s,ct.DelayedFocused),new L(s.instantiate({material:h}),0)];this.mode&&"scale"!==this.mode||(j=j.concat([...c.map(t=>new L(t,ct.DelayedFocused|ct.Unlocked)),new L(m,ct.DelayedFocused|ct.ScaleIn),new L(f,ct.DelayedFocused|ct.ScaleIn),new L(b,ct.DelayedFocused|ct.ScaleOut),new L(y,ct.DelayedFocused|ct.ScaleOut)])),this.mode&&"rotate"!==this.mode||(j=j.concat([...n.right.map(t=>new L(t.instantiate(),ct.DelayedFocused|ct.Unlocked)),...n.left.map(t=>new L(t,ct.DelayedFocused|ct.RotateLeft)),...n.right.map(t=>new L(t,ct.DelayedFocused|ct.RotateRight))]));const R=[r,...l];return new x({view:this.tool.view,renderObjects:j,autoScaleRenderObjects:!1,worldOriented:!0,radius:G,focusMultiplier:1,touchMultiplier:1.5,elevationInfo:this.tool.object.elevationInfo,collisionType:{type:"ribbon",paths:R,direction:w(0,0,1)}})}_createMaterial(t){const e=new nt({cullFace:2,renderOccluded:2,isDecoration:!0});return this.addHandles(l(()=>a(this.tool.view.effectiveTheme.accentColor,t),t=>e.setParameters({color:t}),c)),e}get test(){}};function ht(t,e){const a=S(T.get(),e.renderStart,t.origin),i=S(T.get(),e.renderEnd,t.origin),o=b(a),r=b(i);return 0===o?0:r/o}function ut(t,e,a,i){const{renderStart:o,renderEnd:r}=t,s=pt(o,i,T.get()),n=pt(r,i,T.get());if(y(s,n)<at*at)return null;const l=S(T.get(),o,a),c=j(T.get(),l,k(e)),d=o,h=R(T.get(),d,c),u=pt(a,i,T.get()),p=s,g=pt(h,i,T.get()),m=S(T.get(),g,p),f=S(T.get(),s,u),_=E(p,m),D=E(u,f);return O(_,n)<O(D,n)?"rotate":"scale"}function pt(t,e,a){return e.projectToScreen(t,ft),v(a,ft[0],ft[1],0)}function gt(t,e){let a=null,i=1;const o=()=>i;return{start:()=>{i=t.getScale(),a=t.getScale,t.getScale=o,e()},update:t=>(i+=((i+1)/2-i)*Math.min(t*it,1),e(),Math.abs(i-1)<.01?1:0),destroy:()=>{a&&(t.getScale=a),e()}}}function mt(t,e,a){let i=0,o=null;const r=()=>!1;return{start:()=>{o=t.getFocused,t.getFocused=r,i=0,e()},update:t=>(i+=t,!o?.()||i>=a.delayMs?1:0),destroy:()=>{o&&(t.getFocused=o),e()}}}t([u({constructOnly:!0})],dt.prototype,"tool",void 0),t([u({constructOnly:!0})],dt.prototype,"adapter",void 0),t([u({constructOnly:!0})],dt.prototype,"sketchOptions",void 0),t([u()],dt.prototype,"mode",void 0),t([u()],dt.prototype,"_activeAnimation",void 0),t([u()],dt.prototype,"updating",null),dt=t([p("esri.views.3d.interactive.editingTools.transform.ScaleRotateTransform")],dt);const ft=h();export{dt as ScaleRotateTransform};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{isSome as e}from"../../../../../core/arrayUtils.js";import{EventEmitter as o}from"../../../../../core/Evented.js";import{makeHandle as i}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{watch as n}from"../../../../../core/reactiveUtils.js";import{property as s,subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as l}from"../../../../../core/support/UpdatingHandles.js";import p from"../../../../../geometry/Point.js";import{Manipulator3D as c}from"../../Manipulator3D.js";import{placeAtObject as h}from"../../manipulatorUtils.js";import{SnappingVisualizer3D as m}from"../../SnappingVisualizer3D.js";import{manipulatedObjectGeometry as d}from"../manipulatedObjectUtils.js";import{canMoveZOperations as u}from"../manipulatorUtils.js";import{meshTransformFastUpdateHandles as v}from"../meshFastUpdateUtils.js";import{connectTooltipToManipulatedObject as _}from"../tooltipUtils3D.js";import{createVisualElements as f}from"../visualElementUtils.js";import{alignArrowsScaleThreshold as g}from"../manipulations/config.js";import{MoveManipulation as b}from"../manipulations/MoveManipulation.js";import{ScaleRotateMeshAdapter as j}from"./ScaleRotateMeshAdapter.js";import{ScaleRotateObjectSymbol3DAdapter as y}from"./ScaleRotateObjectSymbol3DAdapter.js";import{ScaleRotateTransform as S}from"./ScaleRotateTransform.js";import{sceneSnappingAtProjectedLocation as M}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as R}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as w}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import T from"../../../../interactive/sketch/SketchOptions.js";import{SnappingContext as O}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as A}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as x,enterInputModeIfAvailable as I}from"../../../../interactive/tooltip/tooltipCommonUtils.js";import{TransformMeshTooltipInfo as U}from"../../../../interactive/tooltip/infos/TransformMeshTooltipInfo.js";import{TransformPointTooltipInfo as k}from"../../../../interactive/tooltip/infos/TransformPointTooltipInfo.js";let E=class extends R{constructor(t){super(t),this.events=new o,this.enableZ=!0,this.enableRotation=!0,this.enableScaling=!0,this.sketchOptions=new T,this.type="transform-3d",this._updatingHandles=new l,this._scaleRotate=null}initialize(){const{events:t,object:o,view:a}=this;this.tooltip=x(()=>({view:a,options:this.sketchOptions.tooltips})),this._moveManipulation=new b({tool:this,view:a,snapToScene:this.snapToScene,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZ&&u(o.operations,o.elevationInfo),radius:b.radiusForSymbol(o.graphic?.symbol)}),this._moveManipulation.forEachManipulator(e=>this.addHandles(e.events.on("immediate-click",e=>{t.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()})));const s=o.elevationInfo;if(this._moveManipulation.elevationInfo=s,this.addHandles(v(o)),this._moveManipulation.createManipulatedObjectDragPipeline((t,e,i,n,r)=>{if(0===t){const{snappingStep:t,cancelSnapping:e}=A({snappingContext:new O({elevationInfo:s,pointer:r,editGeometryOperations:w.fromGeometry(new p({spatialReference:o.operations?.data.spatialReference}),a.state.viewingMode),visualizer:new m,excludeFeature:o.graphic}),snappingManager:this.snappingManager,updatingHandles:this._updatingHandles,useZ:!1});n=n.next(e),i=i.next(M(this.view,s)).next(...t)}return{steps:i,cancel:n}},o,e=>{const{action:o,object:i,dxScreen:a,dyScreen:n}=e,s={object:i,dxScreen:a,dyScreen:n};switch(o){case"start":this._emitRecordUndo(),t.emit("translate-start",s);break;case"update":t.emit("translate",s);break;case"end":t.emit("translate-stop",s)}}),this._moveManipulation.angle=null!=this._scaleRotate?this._scaleRotate.angle:0,this._scaleRotateAdapter=this._createScaleRotateAdapter(),this.addHandles(n(()=>this._scaleRotateAdapter.angle,()=>this._updateMoveAngle())),this.enableScaling||this.enableRotation){const t=this.enableScaling&&this.enableRotation?null:this.enableScaling?"scale":"rotate";this._scaleRotate=new S({tool:this,mode:t,adapter:this._scaleRotateAdapter,sketchOptions:this.sketchOptions}),this.addHandles(this._scaleRotate.events.on("scale-changed",()=>this._onScaleChanged()))}this.addHandles([f({view:this.view,object:o,forEachManipulator:t=>this._forEachManipulator(t),onManipulatorsChanged:()=>i()}),o.on("committed",()=>this._onGeometryChanged()),this._hideManipulatorsForObjectState(),n(()=>a.scale,()=>this._updateMoveAngle())].filter(e)),this._onGeometryChanged(),this._updateMoveAngle(),this._forEachManipulator(t=>{t instanceof c&&this.addHandles(t.events.on("grab-changed",()=>this._updateManipulatorsInteractive()))});const r=a?.type,{sketchOptions:l}=this;this._meshTooltipInfo=new U({viewType:r,sketchOptions:l}),this._pointTooltipInfo=new k({viewType:r,sketchOptions:l});const h={object:o,dxScreen:0,dyScreen:0},d={onBeforeUpdate:()=>this.endDrag(),onMoveStart:()=>{this._emitRecordUndo(),t.emit("translate-start",{...h})},onMove:()=>t.emit("translate",{...h}),onMoveStop:()=>t.emit("translate-stop",{...h}),onRotateStart:e=>{this._emitRecordUndo(),t.emit("rotate-start",{object:o,angle:e})},onRotate:e=>t.emit("rotate",{object:o,angle:e}),onRotateStop:e=>t.emit("rotate-stop",{object:o,angle:e}),onScaleStart:(e,i)=>{this._emitRecordUndo(),t.emit("scale-start",{object:o,xScale:e,yScale:i})},onScale:(e,i)=>t.emit("scale",{object:o,xScale:e,yScale:i}),onScaleStop:(e,i)=>t.emit("scale-stop",{object:o,xScale:e,yScale:i})};this.addHandles(_(this.tooltip,this.object,()=>({sketchOptions:this.sketchOptions,activeTooltipInfo:this.activeTooltipInfo,callbacks:d,scaleRotateTransform:this._scaleRotate}))),this.finishToolCreation()}destroy(){this.tooltip.destroy(),this._moveManipulation.destroy(),this._scaleRotate=a(this._scaleRotate),this._scaleRotateAdapter=a(this._scaleRotateAdapter),this._updatingHandles.destroy(),this._set("view",null),this._set("object",null)}onInputEvent(t){if(!this.destroyed&&!I(t,this.tooltip))return super.onInputEvent(t)}_updateManipulatorsInteractive(){null!=this._scaleRotate&&(this._scaleRotate.interactive=!this._moveManipulation.grabbing,this._moveManipulation.interactive=!this._scaleRotate.grabbing)}_createScaleRotateAdapter(){const t=d(this.object);return"mesh"===t?.type?new j({object:this.object,viewingMode:this.view.state.viewingMode}):new y({graphic:this.object.graphic,sizeFilter:t=>this._enforceNonZeroSize(t),findLayerView:()=>this.view.allLayerViews.find(t=>t.layer===this.object.graphic?.layer),sizeAxis:this.sketchOptions?.tooltips?.visualVariables?.size?.axis??null})}_forEachManipulator(t){this._moveManipulation?.forEachManipulator(t),this._scaleRotate?.forEachManipulator(t)}_hideManipulatorsForObjectState(){return n(()=>this.object.visible,t=>{this._forEachManipulator(e=>e.available=t),this._moveManipulation.zManipulation.available=t&&this.enableZ&&u(this.object.operations,this.object.elevationInfo)})}_emitRecordUndo(){this.events.emit("record-undo",{updates:[this.object.createUndoRecord()]})}set snapToScene(t){this._moveManipulation&&(this._moveManipulation.snapToScene=t),this._set("snapToScene",t)}get updating(){return this._updatingHandles.updating||!!this._scaleRotate?.updating}get activeTooltipInfo(){return"mesh"===d(this.object)?.type?this._meshTooltipInfo:this._pointTooltipInfo}set location(t){this._moveManipulation.location=t,this._scaleRotate&&(this._scaleRotate.location=t)}set elevationAlignedLocation(t){this._moveManipulation.elevationAlignedLocation=t,this._scaleRotate&&(this._scaleRotate.elevationAlignedLocation=t)}reset(){}onHide(){this._scaleRotate?.cancelActiveAnimation()}_onScaleChanged(){null!=this._scaleRotate&&(this._moveManipulation.displayScale=this._scaleRotate.getScale())}_updateMoveAngle(){const{view:t}=this,e=2===t.state.viewingMode||t.scale<g;this._moveManipulation.angle=e?this._scaleRotateAdapter.angle:0}_onGeometryChanged(){h(this,this.object)}_enforceNonZeroSize(t){return t||this.view.state.camera.computeRenderPixelSizeAt(this._moveManipulation.renderLocation)}get test(){}};t([s({constructOnly:!0,nonNullable:!0})],E.prototype,"view",void 0),t([s({constructOnly:!0,nonNullable:!0})],E.prototype,"object",void 0),t([s({constructOnly:!0,nonNullable:!0})],E.prototype,"enableZ",void 0),t([s()],E.prototype,"enableRotation",void 0),t([s()],E.prototype,"enableScaling",void 0),t([s({constructOnly:!0,type:T})],E.prototype,"sketchOptions",void 0),t([s({value:!1})],E.prototype,"snapToScene",null),t([s({constructOnly:!0})],E.prototype,"snappingManager",void 0),t([s({readOnly:!0})],E.prototype,"type",void 0),t([s({readOnly:!0})],E.prototype,"updating",null),t([s()],E.prototype,"activeTooltipInfo",null),E=t([r("esri.views.3d.interactive.editingTools.transform.TransformTool3D")],E);export{E as TransformTool3D};
2
+ import{__decorate as t}from"tslib";import{isSome as e}from"../../../../../core/arrayUtils.js";import{EventEmitter as i}from"../../../../../core/Evented.js";import{makeHandle as o}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{watch as n}from"../../../../../core/reactiveUtils.js";import{property as s,subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as l}from"../../../../../core/support/UpdatingHandles.js";import p from"../../../../../geometry/Point.js";import{Manipulator3D as c}from"../../Manipulator3D.js";import{placeAtObject as h}from"../../manipulatorUtils.js";import{SnappingVisualizer3D as d}from"../../SnappingVisualizer3D.js";import{manipulatedObjectGeometry as m}from"../manipulatedObjectUtils.js";import{canMoveZOperations as u}from"../manipulatorUtils.js";import{meshTransformFastUpdateHandles as v}from"../meshFastUpdateUtils.js";import{connectTooltipToManipulatedObject as _}from"../tooltipUtils3D.js";import{createVisualElements as g}from"../visualElementUtils.js";import{alignArrowsScaleThreshold as f}from"../manipulations/config.js";import{MoveManipulation as b}from"../manipulations/MoveManipulation.js";import{ScaleRotateMeshAdapter as j}from"./ScaleRotateMeshAdapter.js";import{ScaleRotateObjectSymbol3DAdapter as y}from"./ScaleRotateObjectSymbol3DAdapter.js";import{ScaleRotateTransform as S}from"./ScaleRotateTransform.js";import{sceneSnappingAtProjectedLocation as M}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as R}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as w}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import T from"../../../../interactive/sketch/SketchOptions.js";import{SnappingContext as O}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as A}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{makeTooltip as x,enterInputModeIfAvailable as U}from"../../../../interactive/tooltip/tooltipCommonUtils.js";import{TransformMeshTooltipInfo as k}from"../../../../interactive/tooltip/infos/TransformMeshTooltipInfo.js";import{TransformPointTooltipInfo as I}from"../../../../interactive/tooltip/infos/TransformPointTooltipInfo.js";let H=class extends R{constructor(t){super(t),this.events=new i,this.enableZ=!0,this.enableRotation=!0,this.enableScaling=!0,this.sketchOptions=new T,this.type="transform-3d",this._updatingHandles=new l,this._scaleRotate=null}initialize(){const{events:t,object:i,view:a}=this;this.tooltip=x(()=>({view:a,options:this.sketchOptions.tooltips})),this._moveManipulation=new b({tool:this,view:a,snapToScene:this.snapToScene,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZ&&u(i.operations,i.elevationInfo),radius:b.radiusForSymbol(i.graphic?.symbol)}),this._moveManipulation.forEachManipulator(e=>this.addHandles(e.events.on("immediate-click",e=>{t.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()})));const s=i.elevationInfo;if(this._moveManipulation.elevationInfo=s,this.addHandles(v(i)),this._moveManipulation.createManipulatedObjectDragPipeline((t,e,o,n,r)=>{if(0===t){const{snappingStep:t,cancelSnapping:e}=A({snappingContext:new O({elevationInfo:s,pointer:r,editGeometryOperations:w.fromGeometry(new p({spatialReference:i.operations?.data.spatialReference}),a.state.viewingMode),visualizer:new d,excludeFeature:i.graphic}),snappingManager:this.snappingManager,updatingHandles:this._updatingHandles,useZ:!1});n=n.next(e),o=o.next(M(this.view,s)).next(...t)}return{steps:o,cancel:n}},i,e=>{const{action:i,object:o,dxScreen:a,dyScreen:n}=e,s={object:o,dxScreen:a,dyScreen:n};switch(i){case"start":this._emitRecordUndo(),t.emit("translate-start",s);break;case"update":t.emit("translate",s);break;case"end":t.emit("translate-stop",s)}}),this._moveManipulation.angle=null!=this._scaleRotate?this._scaleRotate.angle:0,this._scaleRotateAdapter=this._createScaleRotateAdapter(),this.addHandles(n(()=>this._scaleRotateAdapter.angle,()=>this._updateMoveAngle())),this.enableScaling||this.enableRotation){const t=this.enableScaling&&this.enableRotation?null:this.enableScaling?"scale":"rotate";this._scaleRotate=new S({tool:this,mode:t,adapter:this._scaleRotateAdapter,sketchOptions:this.sketchOptions}),this.addHandles(this._scaleRotate.events.on("scale-changed",()=>this._onScaleChanged()))}this.addHandles([g({view:this.view,object:i,forEachManipulator:t=>this._forEachManipulator(t),onManipulatorsChanged:()=>o()}),i.on("committed",()=>this._onGeometryChanged()),this._hideManipulatorsForObjectState(),n(()=>a.scale,()=>this._updateMoveAngle())].filter(e)),this._onGeometryChanged(),this._updateMoveAngle(),this._forEachManipulator(t=>{t instanceof c&&this.addHandles(t.events.on("grab-changed",()=>this._updateManipulatorsForGrabState()))});const r=a?.type,{sketchOptions:l}=this;this._meshTooltipInfo=new k({viewType:r,sketchOptions:l}),this._pointTooltipInfo=new I({viewType:r,sketchOptions:l});const h={object:i,dxScreen:0,dyScreen:0},m={onBeforeUpdate:()=>this.endDrag(),onMoveStart:()=>{this._emitRecordUndo(),t.emit("translate-start",{...h})},onMove:()=>t.emit("translate",{...h}),onMoveStop:()=>t.emit("translate-stop",{...h}),onRotateStart:e=>{this._emitRecordUndo(),t.emit("rotate-start",{object:i,angle:e})},onRotate:e=>t.emit("rotate",{object:i,angle:e}),onRotateStop:e=>t.emit("rotate-stop",{object:i,angle:e}),onScaleStart:(e,o)=>{this._emitRecordUndo(),t.emit("scale-start",{object:i,xScale:e,yScale:o})},onScale:(e,o)=>t.emit("scale",{object:i,xScale:e,yScale:o}),onScaleStop:(e,o)=>t.emit("scale-stop",{object:i,xScale:e,yScale:o})};this.addHandles(_(this.tooltip,this.object,()=>({sketchOptions:this.sketchOptions,activeTooltipInfo:this.activeTooltipInfo,callbacks:m,scaleRotateTransform:this._scaleRotate}))),this.finishToolCreation()}destroy(){this.tooltip.destroy(),this._moveManipulation.destroy(),this._scaleRotate=a(this._scaleRotate),this._scaleRotateAdapter=a(this._scaleRotateAdapter),this._updatingHandles.destroy(),this._set("view",null),this._set("object",null)}onInputEvent(t){if(!this.destroyed&&!U(t,this.tooltip))return super.onInputEvent(t)}_updateManipulatorsForGrabState(){if(null==this._scaleRotate)return;this._scaleRotate.interactive=!this._moveManipulation.grabbing,this._moveManipulation.interactive=!this._scaleRotate.grabbing;let t=null;this._moveManipulation.grabbing?t=this._scaleRotate.disableDisplay():this._scaleRotate.grabbing&&(t=this._moveManipulation.hideManipulators()),this.removeHandles(E),t&&this.addHandles(t,E)}_createScaleRotateAdapter(){const t=m(this.object);return"mesh"===t?.type?new j({object:this.object,viewingMode:this.view.state.viewingMode}):new y({graphic:this.object.graphic,sizeFilter:t=>this._enforceNonZeroSize(t),findLayerView:()=>this.view.allLayerViews.find(t=>t.layer===this.object.graphic?.layer),sizeAxis:this.sketchOptions?.tooltips?.visualVariables?.size?.axis??null})}_forEachManipulator(t){this._moveManipulation?.forEachManipulator(t),this._scaleRotate?.forEachManipulator(t)}_hideManipulatorsForObjectState(){return n(()=>this.object.visible,t=>{this._forEachManipulator(e=>e.available=t),this._moveManipulation.zManipulation.available=t&&this.enableZ&&u(this.object.operations,this.object.elevationInfo)})}_emitRecordUndo(){this.events.emit("record-undo",{updates:[this.object.createUndoRecord()]})}set snapToScene(t){this._moveManipulation&&(this._moveManipulation.snapToScene=t),this._set("snapToScene",t)}get updating(){return this._updatingHandles.updating||!!this._scaleRotate?.updating}get activeTooltipInfo(){return"mesh"===m(this.object)?.type?this._meshTooltipInfo:this._pointTooltipInfo}set location(t){this._moveManipulation.location=t,this._scaleRotate&&(this._scaleRotate.location=t)}set elevationAlignedLocation(t){this._moveManipulation.elevationAlignedLocation=t,this._scaleRotate&&(this._scaleRotate.elevationAlignedLocation=t)}reset(){}onHide(){this._scaleRotate?.cancelActiveAnimation()}_onScaleChanged(){null!=this._scaleRotate&&(this._moveManipulation.displayScale=this._scaleRotate.getScale())}_updateMoveAngle(){const{view:t}=this,e=2===t.state.viewingMode||t.scale<f;this._moveManipulation.angle=e?this._scaleRotateAdapter.angle:0}_onGeometryChanged(){h(this,this.object)}_enforceNonZeroSize(t){return t||this.view.state.camera.computeRenderPixelSizeAt(this._moveManipulation.renderLocation)}get test(){}};t([s({constructOnly:!0,nonNullable:!0})],H.prototype,"view",void 0),t([s({constructOnly:!0,nonNullable:!0})],H.prototype,"object",void 0),t([s({constructOnly:!0,nonNullable:!0})],H.prototype,"enableZ",void 0),t([s()],H.prototype,"enableRotation",void 0),t([s()],H.prototype,"enableScaling",void 0),t([s({constructOnly:!0,type:T})],H.prototype,"sketchOptions",void 0),t([s({value:!1})],H.prototype,"snapToScene",null),t([s({constructOnly:!0})],H.prototype,"snappingManager",void 0),t([s({readOnly:!0})],H.prototype,"type",void 0),t([s({readOnly:!0})],H.prototype,"updating",null),t([s()],H.prototype,"activeTooltipInfo",null),H=t([r("esri.views.3d.interactive.editingTools.transform.TransformTool3D")],H);const E=Symbol();export{H as TransformTool3D};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../Graphic.js";import{isIterable as n}from"../../../core/iteratorUtils.js";import{screenPointObjectToArray as t,isScreenPolygon as i,isScreenRect as r,createScreenPointArray as s,createScreenPoint as o}from"../../../core/screenUtils.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import c from"../../../geometry/Point.js";import a from"../../../geometry/SpatialReference.js";import{projectVectorToVector as u}from"../../../geometry/projection/projectVectorToVector.js";import{fallbackObjectIDAttribute as d}from"../../../layers/LayerConstants.js";import{isIntegratedMeshLayer as p}from"../../../layers/support/layerUtils.js";import{debugFlags as f}from"./debugFlags.js";import{getElevationAtPoint as m}from"./ElevationProvider.js";import{getGraphicHitDedupeKey as g,resolveOrderedIntersectionHits as y}from"./intersectionHitUtils.js";import{Intersector as h}from"../webgl-engine/lib/Intersector.js";import{isValidIntersectorResultRay as w}from"../webgl-engine/lib/IntersectorResult.js";import{toHit as b,toOwner as x}from"../webgl-engine/lib/intersectorUtilsConversions.js";import{terrainId as E}from"../webgl-engine/lib/verticalOffsetUtils.js";async function S(e,n,t,o){const l=t?v(e,t):o;if(i(n))return U(e,n,l,t?.excludeLabels);if(r(n))return U(e,j(n),l,t?.excludeLabels);const c=n,a=s(c.x,c.y);l.requiresGroundFeedback=!0,l.enableDraped=!0;const u=new h(e.state.viewingMode);u.options.selectionMode=!0,u.options.store=2,u.options.excludeLabels=t?.excludeLabels??!1,e.sceneIntersectionHelper.intersectIntersectorScreen(a,u,l);const d=await V(e,u.results.all,l.graphics,{getDistance:e=>e.distanceInRenderSpace,getMapPoint:n=>R(e,n),stopAtSupportSurface:!0}),m=u.results.ground,g=x(m,e),y=null!=g&&"type"in g&&p(g)?g:null,b={screenPoint:c,results:d,ground:{mapPoint:R(e,m),distance:w(m)?m.distanceInRenderSpace:0,layer:y}};return f.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(b.intersector=u),b}async function U(e,n,i,r){i.enableDraped=!0;const s=new h(e.state.viewingMode);s.options.selectionMode=!0,s.options.store=2,s.options.excludeLabels=r??!1,await e.sceneIntersectionHelper.intersectIntersectorScreenPolygon(n.map(e=>t(e)),s,i);const l={screenPoint:o(0,0),results:await V(e,s.polygonResults.all,i.graphics,{getDistance:e=>e.distance,getMapPoint:()=>null}),ground:{mapPoint:null,distance:0,layer:null}};return f.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(l.intersector=s),l}function j(e){return[o(e.x,e.y),o(e.x+e.width,e.y),o(e.x+e.width,e.y+e.height),o(e.x,e.y+e.height)]}function I(e,n,i,r){const s=i?v(e,i):r,o=!(!s.graphics?.include&&!s.graphics?.exclude),l=!(!s.mediaElements?.include&&!s.mediaElements?.exclude),c=t(n);s.enableDraped=s.include&&!s.include.has(E)||s.exclude?.has(E);const a=e.sceneIntersectionHelper,u=new h(e.state.viewingMode);if(u.options.selectionMode=!0,u.options.store=o||l?2:0,u.options.excludeLabels=i?.excludeLabels??!1,a.intersectIntersectorScreen(c,u,s),o||l){for(const n of u.results.all){const t=b(n,e);if(null==t)return R(e,n);if(o&&("graphic"!==t.type||P(s.graphics,t.graphic)))return R(e,n);if(l&&("media"!==t.type||M(s.mediaElements,t.element)))return R(e,n)}return null}return R(e,u.results.min)}async function V(e,n,t,i){const r=y(e,i.stopAtSupportSurface?function*(){for(const t of n){yield t;const n=x(t,e);if(null!=n&&(n===e.map.ground||"type"in n&&p(n)))break}}():n,{getDedupeKey:e=>"graphic"===e.type?T(e.graphic):null,filterHit:e=>"graphic"!==e.type||P(t,e.graphic)}),s=new Array;for await(const{input:o,hit:l}of r){const e=i.getMapPoint(o),n=i.getDistance(o);if("media"===l.type){const t=e?l.element.toSource(e):null;s.push({...l,mapPoint:e,distance:n,sourcePoint:t})}else s.push({...l,mapPoint:e,distance:n})}return s}function R(e,n,t){return n.getIntersectionPoint(W)?(t=L(e,W,t),7===n.intersector&&e.basemapTerrain&&(t.z=m(e.basemapTerrain,t)??0),t):null}function T(e){const n=e.getObjectId()??e.attributes?.[d];return e.origin&&null!=n?`o-${e.origin.id}-${n}`:`u-${g(e)}`}function P(e,n){return M(e,T(n))}function M(e,n){return null==e||(null==e.include||e.include.has(n))&&(null==e.exclude||!e.exclude.has(n))}function L(e,n,t){let i=e.spatialReference||a.WGS84;return u(n,e.renderSpatialReference,W,i)?n=W:(i=a.WGS84,u(n,e.renderSpatialReference,W,i)&&(n=W)),t?(t.x=n[0],t.y=n[1],t.z=n[2],t.spatialReference=i):t=new c(n,i),t}function v(e,n){const t=D(e,n.include,0),i=D(e,n.exclude,1);return{include:t.layerViewUids,exclude:i.layerViewUids,graphics:{include:t.graphicUids,exclude:i.graphicUids},mediaElements:{include:t.mediaElements,exclude:i.mediaElements}}}function D(t,i,r,s=new H){if(!i)return s;if(i instanceof e)G(s,T(i)),0===r&&(null!=t.graphicsView&&i.layer===t?N(s,t.graphicsView.uid):i.layer&&C(s,t,i.layer.uid));else if("layer"in i&&"element"in i)O(s,i.element),0===r&&C(s,t,i.layer.uid);else if(n(i))for(const e of i)e===t.graphics&&null!=t.graphicsView?N(s,t.graphicsView.uid):e===t.map.ground?N(s,E):D(t,e,r,s);else"layer"in i&&_(s,t,i),"uid"in i&&C(s,t,i.uid);return s}class H{constructor(){this.layerViewUids=null,this.graphicUids=null,this.mediaElements=null}}function C(e,n,t){const i=n.allLayerViews.find(e=>e.layer.uid===t);i&&N(e,i.uid)}function N(e,n){e.layerViewUids??=new Map,e.layerViewUids.set(n,!0)}function _(e,n,t){const i=n.allLayerViews.find(e=>e.layer.uid===t.layer.uid);if(!i)return;e.layerViewUids??=new Map;const r=e.layerViewUids.get(i.uid);!0!==r&&(r?r.add(t.id):e.layerViewUids.set(i.uid,new Set([t.id])))}function G(e,n){e.graphicUids??=new Set,e.graphicUids.add(n)}function O(e,n){e.mediaElements??=new Set,e.mediaElements.add(n)}const W=l();export{L as computeMapPointFromVec3d,v as externalToInternalIntersectOptions,S as hitTest,R as intersectResultToMapPoint,P as testGraphicUidFilter,I as toMap};
2
+ import e from"../../../Graphic.js";import{isIterable as n}from"../../../core/iteratorUtils.js";import{screenPointObjectToArray as t,isScreenPolygon as i,isScreenRect as r,createScreenPointArray as s,createScreenPoint as o}from"../../../core/screenUtils.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import a from"../../../geometry/Point.js";import c from"../../../geometry/SpatialReference.js";import{projectVectorToVector as u}from"../../../geometry/projection/projectVectorToVector.js";import{Sphere as d,sphereCSO as p}from"../../../geometry/support/sphere.js";import{fallbackObjectIDAttribute as f}from"../../../layers/LayerConstants.js";import{isIntegratedMeshLayer as m}from"../../../layers/support/layerUtils.js";import{debugFlags as g}from"./debugFlags.js";import{getElevationAtPoint as y}from"./ElevationProvider.js";import{getGraphicHitDedupeKey as h,resolveOrderedIntersectionHits as w}from"./intersectionHitUtils.js";import{Intersector as b}from"../webgl-engine/lib/Intersector.js";import{isValidIntersectorResultRay as S}from"../webgl-engine/lib/IntersectorResult.js";import{toHit as x,toOwner as E}from"../webgl-engine/lib/intersectorUtilsConversions.js";import{terrainId as U}from"../webgl-engine/lib/verticalOffsetUtils.js";async function j(e,n,t,o){const l=t?C(e,t):o;if(i(n))return I(e,n,l,t?.excludeLabels);if(r(n))return I(e,T(n),l,t?.excludeLabels);const a=n,c=s(a.x,a.y);l.requiresGroundFeedback=!0,l.enableDraped=!0;const u=new b(e.state.viewingMode);u.options.selectionMode=!0,u.options.store=2,u.options.excludeLabels=t?.excludeLabels??!1,e.sceneIntersectionHelper.intersectIntersectorScreen(c,u,l);const d=await P(e,u.results.all,l.graphics,{getDistance:e=>e.distanceInRenderSpace,getMapPoint:n=>L(e,n),stopAtSupportSurface:!0}),p=u.results.ground,f=E(p,e),y=null!=f&&"type"in f&&m(f)?f:null,h={screenPoint:a,results:d,ground:{mapPoint:L(e,p),distance:S(p)?p.distanceInRenderSpace:0,layer:y}};return g.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(h.intersector=u),h}async function I(e,n,i,r){i.enableDraped=!0;const s=new b(e.state.viewingMode);s.options.selectionMode=!0,s.options.store=2,s.options.excludeLabels=r??!1,await e.sceneIntersectionHelper.intersectIntersectorScreenPolygon(n.map(e=>t(e)),s,i);const o={screenPoint:null,results:await P(e,R(e,s.polygonResults.all),i.graphics,{getDistance:e=>e.distance,getMapPoint:()=>null}),ground:{mapPoint:null,distance:0,layer:null}};return g.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(o.intersector=s),o}function*R(e,n){const t=V(e);if(null!=t)for(const i of n)i.distance<=t&&(yield i);else yield*n}function V(e){const n=e.basemapTerrain,t=e.state.camera;if(1!==e.state.viewingMode||!t.aboveGround||!n?.opaque)return null;z.radius=n.getLowerBoundRadius();return p.distanceToSilhouette(z,t.eye)*F}function T(e){return[o(e.x,e.y),o(e.x+e.width,e.y),o(e.x+e.width,e.y+e.height),o(e.x,e.y+e.height)]}function M(e,n,i,r){const s=i?C(e,i):r,o=!(!s.graphics?.include&&!s.graphics?.exclude),l=!(!s.mediaElements?.include&&!s.mediaElements?.exclude),a=t(n);s.enableDraped=s.include&&!s.include.has(U)||s.exclude?.has(U);const c=e.sceneIntersectionHelper,u=new b(e.state.viewingMode);if(u.options.selectionMode=!0,u.options.store=o||l?2:0,u.options.excludeLabels=i?.excludeLabels??!1,c.intersectIntersectorScreen(a,u,s),o||l){for(const n of u.results.all){const t=x(n,e);if(null==t)return L(e,n);if(o&&("graphic"!==t.type||D(s.graphics,t.graphic)))return L(e,n);if(l&&("media"!==t.type||G(s.mediaElements,t.element)))return L(e,n)}return null}return L(e,u.results.min)}async function P(e,n,t,i){const r=w(e,i.stopAtSupportSurface?function*(){for(const t of n){yield t;const n=E(t,e);if(null!=n&&(n===e.map.ground||"type"in n&&m(n)))break}}():n,{getDedupeKey:e=>"graphic"===e.type?v(e.graphic):null,filterHit:e=>"graphic"!==e.type||D(t,e.graphic)}),s=new Array;for await(const{input:o,hit:l}of r){const e=i.getMapPoint(o),n=i.getDistance(o);if("media"===l.type){const t=e?l.element.toSource(e):null;s.push({...l,mapPoint:e,distance:n,sourcePoint:t})}else s.push({...l,mapPoint:e,distance:n})}return s}function L(e,n,t){return n.getIntersectionPoint(q)?(t=H(e,q,t),7===n.intersector&&e.basemapTerrain&&(t.z=y(e.basemapTerrain,t)??0),t):null}function v(e){const n=e.getObjectId()??e.attributes?.[f];return e.origin&&null!=n?`o-${e.origin.id}-${n}`:`u-${h(e)}`}function D(e,n){return G(e,v(n))}function G(e,n){return null==e||(null==e.include||e.include.has(n))&&(null==e.exclude||!e.exclude.has(n))}function H(e,n,t){let i=e.spatialReference||c.WGS84;return u(n,e.renderSpatialReference,q,i)?n=q:(i=c.WGS84,u(n,e.renderSpatialReference,q,i)&&(n=q)),t?(t.x=n[0],t.y=n[1],t.z=n[2],t.spatialReference=i):t=new a(n,i),t}function C(e,n){const t=N(e,n.include,0),i=N(e,n.exclude,1);return{include:t.layerViewUids,exclude:i.layerViewUids,graphics:{include:t.graphicUids,exclude:i.graphicUids},mediaElements:{include:t.mediaElements,exclude:i.mediaElements}}}function N(t,i,r,s=new _){if(!i)return s;if(i instanceof e)$(s,v(i)),0===r&&(null!=t.graphicsView&&i.layer===t?W(s,t.graphicsView.uid):i.layer&&O(s,t,i.layer.uid));else if("layer"in i&&"element"in i)k(s,i.element),0===r&&O(s,t,i.layer.uid);else if(n(i))for(const e of i)e===t.graphics&&null!=t.graphicsView?W(s,t.graphicsView.uid):e===t.map.ground?(W(s,U),t.map.ground.integratedMeshGround&&O(s,t,t.map.ground.integratedMeshGround.uid)):N(t,e,r,s);else"layer"in i&&A(s,t,i),"uid"in i&&O(s,t,i.uid);return s}class _{constructor(){this.layerViewUids=null,this.graphicUids=null,this.mediaElements=null}}function O(e,n,t){const i=n.allLayerViews.find(e=>e.layer.uid===t);i&&W(e,i.uid)}function W(e,n){e.layerViewUids??=new Map,e.layerViewUids.set(n,!0)}function A(e,n,t){const i=n.allLayerViews.find(e=>e.layer.uid===t.layer.uid);if(!i)return;e.layerViewUids??=new Map;const r=e.layerViewUids.get(i.uid);!0!==r&&(r?r.add(t.id):e.layerViewUids.set(i.uid,new Set([t.id])))}function $(e,n){e.graphicUids??=new Set,e.graphicUids.add(n)}function k(e,n){e.mediaElements??=new Set,e.mediaElements.add(n)}const q=l(),z=new d,F=1.2;export{H as computeMapPointFromVec3d,C as externalToInternalIntersectOptions,j as hitTest,L as intersectResultToMapPoint,D as testGraphicUidFilter,M as toMap};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{SizedPixelFormat as e,PixelType as n,SizedDepthStencilFormat as r,SizedDepthFormat as a}from"../../../webgl/enums.js";import{TextureDescriptor as t}from"../../../webgl/TextureDescriptor.js";import{isSizedDepthFormat as o}from"../../../webgl/textureUtils.js";function s(e){switch(e){case 0:return"R8UNORM";case 1:return"R8UINT";case 2:return"RG8UNORM";case 3:return"RG8UINT";case 4:return"RGBA4UNORM";case 5:return"RGBA8UNORM";case 6:return"RGBA8UNORM_MIPMAP";case 7:return"R16FLOAT";case 8:return"RGBA16FLOAT";case 9:return"RGBA16FLOAT_MIPMAP";case 10:return"R32FLOAT";case 11:return"RG32FLOAT";case 12:return"RGBA32UINT";case 13:return"COUNT"}}function p(e){switch(e){case 13:return"DEPTH16";case 14:return"DEPTH24_STENCIL8"}}function i(e){return T(e)?p(e):s(e)}function T(e){return e>=13}const m=new t;m.pixelFormat=6403,m.internalFormat=e.R8,m.wrapMode=33071;const F=new t;F.pixelFormat=36244,F.internalFormat=e.R8UI,F.wrapMode=33071,F.samplingMode=9728;const c=new t;c.pixelFormat=33319,c.internalFormat=e.RG8,c.wrapMode=33071;const l=new t;l.pixelFormat=33320,l.internalFormat=e.RG8UI,l.wrapMode=33071,l.samplingMode=9728;const N=new t;N.internalFormat=e.RGBA4,N.dataType=n.UNSIGNED_SHORT_4_4_4_4,N.wrapMode=33071;const M=new t;M.wrapMode=33071;const R=new t;R.wrapMode=33071,R.samplingMode=9987,R.hasMipmap=!0,R.maxAnisotropy=8;const w=new t;w.pixelFormat=6403,w.dataType=n.HALF_FLOAT,w.internalFormat=e.R16F,w.samplingMode=9728;const _=new t;_.dataType=n.HALF_FLOAT,_.internalFormat=e.RGBA16F,_.wrapMode=33071;const u=new t;u.dataType=n.HALF_FLOAT,u.internalFormat=e.RGBA16F,u.wrapMode=33071,u.samplingMode=9987,u.hasMipmap=!0,u.maxAnisotropy=8;const A=new t;A.pixelFormat=6403,A.dataType=n.FLOAT,A.internalFormat=e.R32F,A.samplingMode=9728;const d=new t;d.pixelFormat=33319,d.dataType=n.FLOAT,d.internalFormat=e.RG32F,d.samplingMode=9728;const O=new t;O.pixelFormat=36249,O.dataType=n.UNSIGNED_INT,O.internalFormat=e.RGBA32UI,O.samplingMode=9728,O.wrapMode=33071;const E={0:m,1:F,2:c,3:l,4:N,5:M,6:R,7:w,8:_,9:u,10:A,11:d,12:O,13:null},I={[a.DEPTH_COMPONENT16]:n.UNSIGNED_SHORT,[a.DEPTH_COMPONENT24]:n.UNSIGNED_INT,[a.DEPTH_COMPONENT32F]:n.FLOAT,[r.DEPTH24_STENCIL8]:n.UNSIGNED_INT_24_8,[r.DEPTH32F_STENCIL8]:n.FLOAT_32_UNSIGNED_INT_24_8_REV},G={14:L(r.DEPTH24_STENCIL8),13:L(a.DEPTH_COMPONENT16)};function L(e){const n=new t;return n.pixelFormat=o(e)?6402:34041,n.dataType=I[e],n.samplingMode=9728,n.wrapMode=33071,n.internalFormat=e,n.hasMipmap=!1,n.isImmutable=!0,n}export{E as ColorFormats,G as DepthTextureFormats,i as formatString,T as isDepthFormat};
2
+ import{SizedPixelFormat as e,PixelType as n,SizedDepthStencilFormat as r,SizedDepthFormat as a}from"../../../webgl/enums.js";import{TextureDescriptor as t}from"../../../webgl/TextureDescriptor.js";import{isSizedDepthFormat as o}from"../../../webgl/textureUtils.js";function s(e){switch(e){case 0:return"R8UNORM";case 1:return"R8UINT";case 2:return"RG8UNORM";case 3:return"RG8UINT";case 4:return"RGBA4UNORM";case 5:return"RGBA8UNORM";case 6:return"RGBA8UNORM_MIPMAP";case 7:return"R16FLOAT";case 8:return"RGBA16FLOAT";case 9:return"RGBA16FLOAT_MIPMAP";case 10:return"R32FLOAT";case 11:return"RGBA32FLOAT";case 12:return"RGBA32UINT";case 13:return"COUNT"}}function p(e){switch(e){case 13:return"DEPTH16";case 14:return"DEPTH24_STENCIL8"}}function i(e){return T(e)?p(e):s(e)}function T(e){return e>=13}const m=new t;m.pixelFormat=6403,m.internalFormat=e.R8,m.wrapMode=33071;const F=new t;F.pixelFormat=36244,F.internalFormat=e.R8UI,F.wrapMode=33071,F.samplingMode=9728;const c=new t;c.pixelFormat=33319,c.internalFormat=e.RG8,c.wrapMode=33071;const l=new t;l.pixelFormat=33320,l.internalFormat=e.RG8UI,l.wrapMode=33071,l.samplingMode=9728;const N=new t;N.internalFormat=e.RGBA4,N.dataType=n.UNSIGNED_SHORT_4_4_4_4,N.wrapMode=33071;const M=new t;M.wrapMode=33071;const R=new t;R.wrapMode=33071,R.samplingMode=9987,R.hasMipmap=!0,R.maxAnisotropy=8;const A=new t;A.pixelFormat=6403,A.dataType=n.HALF_FLOAT,A.internalFormat=e.R16F,A.samplingMode=9728;const w=new t;w.dataType=n.HALF_FLOAT,w.internalFormat=e.RGBA16F,w.wrapMode=33071;const _=new t;_.dataType=n.HALF_FLOAT,_.internalFormat=e.RGBA16F,_.wrapMode=33071,_.samplingMode=9987,_.hasMipmap=!0,_.maxAnisotropy=8;const u=new t;u.pixelFormat=6403,u.dataType=n.FLOAT,u.internalFormat=e.R32F,u.samplingMode=9728;const d=new t;d.pixelFormat=6408,d.dataType=n.FLOAT,d.internalFormat=e.RGBA32F,d.samplingMode=9728;const O=new t;O.pixelFormat=36249,O.dataType=n.UNSIGNED_INT,O.internalFormat=e.RGBA32UI,O.samplingMode=9728,O.wrapMode=33071;const E={0:m,1:F,2:c,3:l,4:N,5:M,6:R,7:A,8:w,9:_,10:u,11:d,12:O,13:null},I={[a.DEPTH_COMPONENT16]:n.UNSIGNED_SHORT,[a.DEPTH_COMPONENT24]:n.UNSIGNED_INT,[a.DEPTH_COMPONENT32F]:n.FLOAT,[r.DEPTH24_STENCIL8]:n.UNSIGNED_INT_24_8,[r.DEPTH32F_STENCIL8]:n.FLOAT_32_UNSIGNED_INT_24_8_REV},G={14:L(r.DEPTH24_STENCIL8),13:L(a.DEPTH_COMPONENT16)};function L(e){const n=new t;return n.pixelFormat=o(e)?6402:34041,n.dataType=I[e],n.samplingMode=9728,n.wrapMode=33071,n.internalFormat=e,n.hasMipmap=!1,n.isImmutable=!0,n}export{E as ColorFormats,G as DepthTextureFormats,i as formatString,T as isDepthFormat};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{releaseMaybe as t}from"../../../../../core/maybe.js";import{watch as r,syncAndInitial as s}from"../../../../../core/reactiveUtils.js";import{property as a,subclass as i}from"../../../../../core/accessorSupport/decorators.js";import{set as l}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as o}from"../../../webgl.js";import u from"../../../webgl/RenderNode.js";import{G as n}from"../../../../../chunks/GlobalIllumination.glsl.js";import{G as m}from"../../../../../chunks/GlobalIlluminationBlur.glsl.js";import{GlobalIlluminationBlurTechnique as h}from"./GlobalIlluminationBlurTechnique.js";import{GlobalIlluminationTechnique as c}from"./GlobalIlluminationTechnique.js";import{GlobalIlluminationTechniqueConfiguration as p}from"./GlobalIlluminationTechniqueConfiguration.js";import{G as _}from"../../../../../chunks/GlobalIlluminationUpscale.glsl.js";import{GlobalIlluminationUpscaleTechnique as d}from"./GlobalIlluminationUpscaleTechnique.js";import{DepthStencilAttachment as f,ColorAttachment1 as b}from"../../../../webgl/enums.js";const g=1;let w=class extends u{constructor(e){super(e),this.consumes={required:["normals"]},this.produces=o.AMBIENT_ILLUMINATION,this._passParameters=new n,this._drawParameters=new m,this._drawParametersUpscale=new _,this._maxFrames=256,this._lowQualityResolutionScale=.25,this._configuration=new p,this._lastOutput=null,this._isGlobalIlluminationUpdate=!1,this._resetBuffer=!1}initialize(){this.addHandles(r(()=>this.view.stage.renderer.hasGlobalIllumination,()=>{this._reset(),this._requestRender()},s))}destroy(){this._lastOutput=t(this._lastOutput)}resetAccumulatedFrames(){this._isGlobalIlluminationUpdate||this._reset()}render(e){if(this._passParameters.accumulatedFrames>=this._maxFrames)return this._lastOutput?.retain(),this._lastOutput;const t=e.find(({name:e})=>"normals"===e),r=t?.getTexture(),s=t?.getTexture(f),a=this._mode;if(!r||!s)return this._emptyOutput;if(0===a)return this._resetBuffer=!1,this._emptyOutput;if(!this._canRender)return this._resetBuffer=!1,this._requestRender(),this._emptyOutput;const i=this.bindParameters;this._configuration.hasEmission=!!i.reprojection.lastFrameEmission;const u=this.techniques.getCompiled(c,this._configuration),n=this.techniques.getCompiled(h),m=1===a,p=m?this._lowQualityResolutionScale:1,_=m?this.techniques.getCompiled(d):null;if(!u||!n||m&&!_)return this._requestRender(),this._emptyOutput;const w=this.renderingContext,{camera:P}=i;this._passParameters.normalTexture=r,this._passParameters.depthTexture=s,this._passParameters.projScale=1/P.computeScreenPixelSizeAtDist(1),this._passParameters.scaleGlobalIllumination=p;const{fullWidth:I,fullHeight:x}=P,T=Math.max(1,Math.floor(I*p)),q=Math.max(1,Math.floor(x*p)),F=this.fboCache.acquire(T,q,"global illumination input").acquireColor(b,0);w.bindFramebuffer(F.fbo),w.setViewport(0,0,T,q),w.bindTechnique(u,i,this._passParameters,this._drawParameters),w.screen.draw();const O=F.obtainAttachment(b),C=Math.max(1,Math.round(T/g)),G=Math.max(1,Math.round(q/g)),j=this.fboCache.acquire(C,G,"global illumination blur horizontal");w.bindFramebuffer(j.fbo),this._drawParameters.texture=F.getTexture(),this._drawParameters.weightTexture=O.attachment,l(this._drawParameters.blurSize,0,g/q),w.bindTechnique(n,i,this._passParameters,this._drawParameters),w.setViewport(0,0,C,G),w.screen.draw(),F.release();const y=m?"global illumination blur vertical":o.AMBIENT_ILLUMINATION,M=this.fboCache.acquire(C,G,y);w.bindFramebuffer(M.fbo),w.setViewport(0,0,C,G),w.setClearColor(1,1,1,0),w.clear(16384),this._drawParameters.texture=j.getTexture(),this._drawParameters.weightTexture=O.attachment,l(this._drawParameters.blurSize,g/C,0),w.bindTechnique(n,i,this._passParameters,this._drawParameters),w.setViewport(0,0,C,G),w.screen.draw(),j.release(),M.attachColor(O,b),O.release();let R=M;return _&&(R=this.fboCache.acquire(I,x,o.AMBIENT_ILLUMINATION).acquireColor(b,0),w.bindFramebuffer(R.fbo),w.setViewport(0,0,I,x),w.setClearColor(1,1,1,0),w.clear(16384),this._drawParametersUpscale.colorTexture=M.getTexture(),this._drawParametersUpscale.weightTexture=M.getTexture(b),w.bindTechnique(_,i,this._passParameters,this._drawParametersUpscale),w.screen.draw(),M.release()),w.setViewport4fv(P.fullViewport),this._passParameters.temporalSampleFrame=(this._passParameters.temporalSampleFrame+1)%64,++this._passParameters.accumulatedFrames,this._storeOutput(R),this._passParameters.accumulatedFrames<this._maxFrames&&this._requestRender(),R}_requestRender(){this._isGlobalIlluminationUpdate=!0,this.requestRender(1),this._isGlobalIlluminationUpdate=!1}_storeOutput(e){this._lastOutput!==e&&(this._lastOutput=t(this._lastOutput),this._lastOutput=e,this._lastOutput.retain())}get _emptyOutput(){const e=this.renderingContext,{fullWidth:t,fullHeight:r}=this.bindParameters.camera,s=this.fboCache.acquire(t,r,o.AMBIENT_ILLUMINATION).acquireColor(b,0);return e.bindFramebuffer(s.fbo),e.setViewport(0,0,t,r),e.clearBuffer(0,[0,0,0,1]),e.clearBuffer(1,[0,0,0,0]),s}get _canRender(){const{reprojection:e,hasEmission:t,globalIllumination:r}=this.bindParameters;return!(!e.lastFrameColor||t&&!e.lastFrameEmission||!e.lastFrameDepth||!r||this._resetBuffer)}get _mode(){const{hasGlobalIlluminationHighQuality:e,hasGlobalIllumination:t}=this.view.stage.renderer;return e?2:t?1:0}_reset(){this._passParameters.accumulatedFrames=0,this._lastOutput=t(this._lastOutput)}get test(){const e=this;return{passParameters:this._passParameters,configuration:this._configuration,get maxFrames(){return e._maxFrames},set maxFrames(t){e._maxFrames=t},get lowQualityResolutionScale(){return e._lowQualityResolutionScale},set lowQualityResolutionScale(t){e._lowQualityResolutionScale=t},get mode(){return e._mode},restartAccumulation:()=>{this._reset(),this._passParameters.temporalSampleFrame=0,this._resetBuffer=!0,this._requestRender()}}}};e([a()],w.prototype,"consumes",void 0),e([a()],w.prototype,"produces",void 0),w=e([i("esri.views.3d.webgl-engine.effects.globalIllumination.GlobalIllumination")],w);export{w as GlobalIllumination,g as blurSizePixels};
2
+ import{__decorate as e}from"tslib";import{releaseMaybe as t}from"../../../../../core/maybe.js";import{watch as s,syncAndInitial as r}from"../../../../../core/reactiveUtils.js";import{property as a,subclass as i}from"../../../../../core/accessorSupport/decorators.js";import{set as l}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as o}from"../../../webgl.js";import u from"../../../webgl/RenderNode.js";import{G as n}from"../../../../../chunks/GlobalIllumination.glsl.js";import{G as m}from"../../../../../chunks/GlobalIlluminationBlur.glsl.js";import{GlobalIlluminationBlurTechnique as h}from"./GlobalIlluminationBlurTechnique.js";import{GlobalIlluminationTechnique as c}from"./GlobalIlluminationTechnique.js";import{GlobalIlluminationTechniqueConfiguration as p}from"./GlobalIlluminationTechniqueConfiguration.js";import{G as _}from"../../../../../chunks/GlobalIlluminationUpscale.glsl.js";import{GlobalIlluminationUpscaleTechnique as d}from"./GlobalIlluminationUpscaleTechnique.js";import{DepthStencilAttachment as f,ColorAttachment1 as b}from"../../../../webgl/enums.js";const g=1,w=100;let P=class extends u{constructor(e){super(e),this.consumes={required:["normals"]},this.produces=o.AMBIENT_ILLUMINATION,this._passParameters=new n,this._drawParameters=new m,this._drawParametersUpscale=new _,this._maxFrames=256,this._lowQualityResolutionScale=.25,this._configuration=new p,this._lastOutput=null,this._isGlobalIlluminationUpdate=!1,this._resetBuffer=!1}initialize(){this.addHandles(s(()=>this.view.stage.renderer.hasGlobalIllumination,()=>{this._reset(),this._requestRender()},r))}destroy(){this._lastOutput=t(this._lastOutput)}resetAccumulatedFrames(){this._isGlobalIlluminationUpdate||!(this._passParameters.accumulatedFrames>w)&&this._configuration.hasEmission||this._reset()}render(e){if(this._passParameters.accumulatedFrames>=this._maxFrames)return this._lastOutput?.retain(),this._lastOutput;const t=e.find(({name:e})=>"normals"===e),s=t?.getTexture(),r=t?.getTexture(f),a=this._mode;if(!s||!r)return this._emptyOutput;if(0===a)return this._resetBuffer=!1,this._emptyOutput;if(!this._canRender)return this._resetBuffer=!1,this._requestRender(),this._emptyOutput;const i=this.bindParameters;this._configuration.hasEmission=!!i.reprojection.lastFrameEmission;const u=this.techniques.getCompiled(c,this._configuration),n=this.techniques.getCompiled(h),m=1===a,p=m?this._lowQualityResolutionScale:1,_=m?this.techniques.getCompiled(d):null;if(!u||!n||m&&!_)return this._requestRender(),this._emptyOutput;const w=this.renderingContext,{camera:P}=i;this._passParameters.normalTexture=s,this._passParameters.depthTexture=r,this._passParameters.projScale=1/P.computeScreenPixelSizeAtDist(1),this._passParameters.scaleGlobalIllumination=p;const{fullWidth:I,fullHeight:x}=P,T=Math.max(1,Math.floor(I*p)),q=Math.max(1,Math.floor(x*p)),F=this.fboCache.acquire(T,q,"global illumination input").acquireColor(b,2);w.bindFramebuffer(F.fbo),w.setViewport(0,0,T,q),w.bindTechnique(u,i,this._passParameters,this._drawParameters),w.screen.draw();const O=F.obtainAttachment(b),C=Math.max(1,Math.round(T/g)),G=Math.max(1,Math.round(q/g)),j=this.fboCache.acquire(C,G,"global illumination blur horizontal");w.bindFramebuffer(j.fbo),this._drawParameters.texture=F.getTexture(),this._drawParameters.weightTexture=O.attachment,l(this._drawParameters.blurSize,0,g/q),w.bindTechnique(n,i,this._passParameters,this._drawParameters),w.setViewport(0,0,C,G),w.screen.draw(),F.release();const y=m?"global illumination blur vertical":o.AMBIENT_ILLUMINATION,M=this.fboCache.acquire(C,G,y);w.bindFramebuffer(M.fbo),w.setViewport(0,0,C,G),w.setClearColor(1,1,1,0),w.clear(16384),this._drawParameters.texture=j.getTexture(),this._drawParameters.weightTexture=O.attachment,l(this._drawParameters.blurSize,g/C,0),w.bindTechnique(n,i,this._passParameters,this._drawParameters),w.setViewport(0,0,C,G),w.screen.draw(),j.release(),M.attachColor(O,b),O.release();let R=M;return _&&(R=this.fboCache.acquire(I,x,o.AMBIENT_ILLUMINATION).acquireColor(b,2),w.bindFramebuffer(R.fbo),w.setViewport(0,0,I,x),w.setClearColor(1,1,1,0),w.clear(16384),this._drawParametersUpscale.colorTexture=M.getTexture(),this._drawParametersUpscale.weightTexture=M.getTexture(b),w.bindTechnique(_,i,this._passParameters,this._drawParametersUpscale),w.screen.draw(),M.release()),w.setViewport4fv(P.fullViewport),this._passParameters.temporalSampleFrame=(this._passParameters.temporalSampleFrame+1)%64,++this._passParameters.accumulatedFrames,this._storeOutput(R),this._passParameters.accumulatedFrames<this._maxFrames&&this._requestRender(),R}_requestRender(){this._isGlobalIlluminationUpdate=!0,this.requestRender(1),this._isGlobalIlluminationUpdate=!1}_storeOutput(e){this._lastOutput!==e&&(this._lastOutput=t(this._lastOutput),this._lastOutput=e,this._lastOutput.retain())}get _emptyOutput(){const e=this.renderingContext,{fullWidth:t,fullHeight:s}=this.bindParameters.camera,r=this.fboCache.acquire(t,s,o.AMBIENT_ILLUMINATION).acquireColor(b,2);return e.bindFramebuffer(r.fbo),e.setViewport(0,0,t,s),e.clearBuffer(0,[0,0,0,1]),e.clearBuffer(1,[0,0,0,0]),r}get _canRender(){const{reprojection:e,hasEmission:t,globalIllumination:s}=this.bindParameters;return!(!e.lastFrameColor||t&&!e.lastFrameEmission||!e.lastFrameDepth||!s||this._resetBuffer)}get _mode(){const{hasGlobalIlluminationHighQuality:e,hasGlobalIllumination:t}=this.view.stage.renderer;return e?2:t?1:0}_reset(){this._passParameters.accumulatedFrames=0,this._lastOutput=t(this._lastOutput)}get test(){const e=this;return{passParameters:this._passParameters,configuration:this._configuration,get maxFrames(){return e._maxFrames},set maxFrames(t){e._maxFrames=t},get lowQualityResolutionScale(){return e._lowQualityResolutionScale},set lowQualityResolutionScale(t){e._lowQualityResolutionScale=t},get mode(){return e._mode},restartAccumulation:()=>{this._reset(),this._passParameters.temporalSampleFrame=0,this._resetBuffer=!0,this._requestRender()}}}};e([a()],P.prototype,"consumes",void 0),e([a()],P.prototype,"produces",void 0),P=e([i("esri.views.3d.webgl-engine.effects.globalIllumination.GlobalIllumination")],P);export{P as GlobalIllumination,g as blurSizePixels};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{nextPowerOfTwo as t}from"../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as r}from"../../../../core/maybe.js";import{property as s,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{ortho as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{set as n}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UNIT_X as d,ZEROS as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as l}from"../../webgl.js";import{Frustum as m}from"../../state/Frustum.js";import{glLayout as p}from"../../support/buffer/glUtil.js";import{newLayout as _}from"../../support/buffer/InterleavedLayout.js";import f from"../../webgl/RenderCamera.js";import g from"../../webgl/RenderNode.js";import{VertexArrayObject as C}from"./VertexArrayObject.js";import{CutFillMinMaxDepthTechnique as w}from"../shaders/CutFillMinMaxDepthTechnique.js";import{C as x}from"../../../../chunks/CutFillReduction.glsl.js";import{CutFillReductionTechnique as T}from"../shaders/CutFillReductionTechnique.js";import{CutFillReductionTechniqueConfiguration as P}from"../shaders/CutFillReductionTechniqueConfiguration.js";import{C as R}from"../../../../chunks/CutFillTargetDepth.glsl.js";import{CutFillTargetDepthTechnique as b}from"../shaders/CutFillTargetDepthTechnique.js";import{C as y}from"../../../../chunks/CutFillTotalDepth.glsl.js";import{CutFillTotalDepthTechnique as F}from"../shaders/CutFillTotalDepthTechnique.js";import{ImmediateTask as B,TaskPriority as j}from"../../../support/Scheduler.js";import{Yield as E}from"../../../support/Yield.js";import{PrimitiveType as O,DataType as S}from"../../../webgl/enums.js";import{Sync as q}from"../../../webgl/Sync.js";import{VertexBuffer as D}from"../../../webgl/VertexBuffer.js";let v=class extends g{constructor(e){super(e),this.consumes={required:[l.CUTFILL_COMPUTATION,l.TRANSPARENT_NO_DEPTH]},this.produces=l.CUTFILL_COMPUTATION,this.needsRender=!1,this.readyToRun=!1,this.done=!0,this._frameTask=B,this._result=new L,this._localOrigin=u(),this._maxTextureSize=512,this._width=0,this._height=0,this._reducedWidth=0,this._reducedHeight=0,this._depthFormat=14,this._colorFormat=11,this._numChannels=2,this._reductionConfiguration=new P,this._targetDepthParameters=new R,this._depthParameters=new y,this._reductionParameters=new x,this._numReductions=3,this._reductionPasses=0,this._pixelBufferSize=0,this._pixelBufferOffset=0,this._perReductionPixelBufferSize=0}initialize(){this._frameTask=this.view.resourceController.scheduler.registerTask(j.VOLUME_MEASUREMENT,this),this.addHandles(this._frameTask),this._maxTextureSize=Math.min(this._maxTextureSize,this.fboCache.rctx.parameters.maxTextureSize),this._frustum=new m(this.view.renderCoordsHelper)}destroy(){this._targetGeometryVao=i(this._targetGeometryVao),this._sync=r(this._sync),this._pixelBuffer&&(this.gl.deleteBuffer(this._pixelBuffer),this._pixelBuffer=null,this._pixelBufferSize=0)}precompile(){this.view.stage.renderer.precompileCutFillOrthographicReferenceDepth()}render(){const e=this.input;if(!this._orthographicCamera||!this._targetGeometryVao||!this.needsRender||this._sync)return e;const t=this.techniques.getCompiled(b),i=this.techniques.getCompiled(F),r=this.techniques.getCompiled(w);this._reductionConfiguration.reductionPass=0;const s=this.techniques.getCompiled(T,this._reductionConfiguration);this._reductionConfiguration.reductionPass=1;const h=this.techniques.getCompiled(T,this._reductionConfiguration);this._reductionConfiguration.reductionPass=2;const o=this.techniques.getCompiled(T,this._reductionConfiguration);if(!(t&&i&&r&&s&&h&&o))return this.requestRender(1),e;this.needsRender=!1;const n=this.renderingContext,a=this.fboCache,u=this.gl,c=n.getViewport(),l=a.acquire(this._width,this._height,"cutfill reference depth",this._depthFormat);n.bindFramebuffer(l.fbo),n.setViewport(0,0,this._width,this._height),n.clear(1280),this.view.stage.renderer.renderCutFillOrthographicReferenceDepth(this._orthographicCamera);const m=a.acquire(this._width,this._height,"cutfill target depth",this._depthFormat);n.bindFramebuffer(m.fbo),n.setViewport(0,0,this._width,this._height),n.setClearDepth(1),n.clear(256),this._targetDepthParameters.origin=this._localOrigin,this._targetDepthParameters.cutFillCamera=this._orthographicCamera,n.bindTechnique(t,this.bindParameters,this._targetDepthParameters),n.bindVAO(this._targetGeometryVao),n.drawArrays(O.TRIANGLES,0,this._targetGeometryVao.vertexCount("geometry"));const p=a.acquire(this._width,this._height,"cutfill reduction even",this._colorFormat),_=a.acquire(Math.ceil(this._width/2),Math.ceil(this._height/2),"cutfill reduction odd",this._colorFormat);return this._depthParameters.referenceDepth=l.depthTexture,this._depthParameters.targetDepth=m.depthTexture,this._pixelBuffer||(this._pixelBuffer=u.createBuffer()),u.bindBuffer(u.PIXEL_PACK_BUFFER,this._pixelBuffer),u.bufferData(u.PIXEL_PACK_BUFFER,this._pixelBufferSize,u.STREAM_READ),this._prepareFBO(p,this.width,this.height),n.bindTechnique(i,this.bindParameters,this._depthParameters),n.screen.draw(),this._runPyramidReduction(p,_,s),this._prepareFBO(p,this.width,this.height,d),n.bindTechnique(r,this.bindParameters,this._depthParameters),n.screen.draw(),this._runPyramidReduction(p,_,h),this._prepareFBO(p,this.width,this.height),n.bindTechnique(r,this.bindParameters,this._depthParameters),n.screen.draw(),this._runPyramidReduction(p,_,o),l.release(),m.release(),p.release(),_.release(),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),n.setViewport(c.x,c.y,c.width,c.height),this._sync=new q(u),setTimeout(()=>this.readyToRun=!0,0),e}update(e,i){if(!this.done)return;this.done=!1;const r=this.renderingContext,{cameraDimensions:{width:s,height:h},localOriginRenderSpace:o}=e,n=this._maxTextureSize,a=h/s,u=s>h?n:n/a,d=s>h?n*a:n;this._width=t(u),this._height=t(d);const c=[this._width,this._height];this._orthographicCamera=this._createCamera(e,c),this._frustum?.update(this._orthographicCamera),this._updateTargetVao(r,i),this._localOrigin=o,this._reductionPasses=Math.ceil(Math.log2(Math.min(this._width,this._height))),this._reducedWidth=Math.ceil(this._width/2**this._reductionPasses),this._reducedHeight=Math.ceil(this._height/2**this._reductionPasses),this._perReductionPixelBufferSize=this._reducedWidth*this._reducedHeight*this._numChannels*4,this._pixelBufferSize=this._perReductionPixelBufferSize*this._numReductions,this._pixelBufferOffset=0,this.needsRender=!0,this.requestRender(1)}runTask(){if(!this._sync)return void(this.readyToRun=!1);try{if(!this._sync.poll())return E}catch(t){return this.readyToRun=!1,void(this._sync=r(this._sync))}this.readyToRun=!1,this._sync=r(this._sync);const e=this.gl;this._cpuBuffer=new Float32Array(this._pixelBufferSize/4),e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pixelBuffer),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._cpuBuffer),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),this._updateResults(this._cpuBuffer),this.done=!0}getResult(){return this._result}get frustum(){return this._frustum}get width(){return this._width}get height(){return this._height}get updating(){return this.readyToRun||!this.done||this._frameTask.updating}_runPyramidReduction(e,t,i){const r=this.renderingContext,s=this.gl;let h=this._width,o=this._height;for(let n=0;n<this._reductionPasses;n++)h=Math.ceil(h/2),o=Math.ceil(o/2),this._reductionParameters.depthTexture=e.getTexture(),this._prepareFBO(t,h,o),r.bindTechnique(i,this.bindParameters,this._reductionParameters),r.screen.draw(),[e,t]=[t,e];s.readPixels(0,0,h,o,33319,S.FLOAT,this._pixelBufferOffset),this._pixelBufferOffset+=this._perReductionPixelBufferSize}_updateResults(e){const t=new z(0,1,a()),i=new z(0,0,a());for(let r=0;r<this._reducedWidth;r++)for(let s=0;s<this._reducedHeight;s++){let h=(r+s*this._reducedWidth)*this._numChannels;const o=this._reducedWidth*this._reducedHeight*this._numChannels;t.totalDepth+=e[h],i.totalDepth+=e[h+1],h+=o;const n=e[h];n<t.depthExtremum&&(t.depthExtremum=n,V(t.depthExtremumCoords,e[h+1],this._width)),h+=o;const a=e[h];a>i.depthExtremum&&(i.depthExtremum=a,V(i.depthExtremumCoords,e[h+1],this._width))}this._result=new L(this._width,this._height,t,i)}_prepareFBO(e,t,i,r=c){const s=this.renderingContext;s.bindFramebuffer(e.fbo),s.setViewport(0,0,t,i),s.setClearColor(r[0],r[1],r[2],r[3]),s.clear(16384)}_createCamera(e,t){const{cameraPositionRenderSpace:i,localOriginRenderSpace:r,northVector:s,cameraDimensions:{width:h,height:n},cameraNearFar:{near:a,far:u}}=e,d=new f({eye:i,center:r,up:s,near:a,far:u});return d.viewport=[0,0,t[0],t[1]],o(d.projectionMatrix,-h/2,h/2,-n/2,n/2,a,u),d}_updateTargetVao(e,t){this._targetGeometryVao=i(this._targetGeometryVao);const r=t.indices.length,s=M.createBuffer(r),h=s.position,{positions:o,indices:n}=t;for(let i=0;i<n.length;++i){const e=3*n[i];h.set(i,0,o[e]),h.set(i,1,o[e+1]),h.set(i,2,o[e+2])}const a=new D(e,p(M),s.buffer);this._targetGeometryVao=new C(e,a)}};e([s()],v.prototype,"consumes",void 0),e([s()],v.prototype,"produces",void 0),e([s()],v.prototype,"needsRender",void 0),e([s()],v.prototype,"readyToRun",void 0),e([s()],v.prototype,"done",void 0),e([s()],v.prototype,"updating",null),e([s()],v.prototype,"_frameTask",void 0),v=e([h("esri.views.3d.webgl-engine.lib.CutFillComputation")],v);const M=_().vec3f("position").freeze();function V(e,t,i){const r=t%i,s=Math.floor(t/i);n(e,r,s)}class A{constructor(e,t){this.positions=e,this.indices=t}}class z{constructor(e,t,i){this.totalDepth=e,this.depthExtremum=t,this.depthExtremumCoords=i}}class L{constructor(e=0,t=0,i=new z(0,1,a()),r=new z(0,0,a())){this.width=e,this.height=t,this.cut=i,this.fill=r}}export{v as CutFillComputation,L as CutFillComputationResult,z as CutFillDepthResult,A as TargetGeometryRenderInfo};
2
+ import{__decorate as e}from"tslib";import{nextPowerOfTwo as t}from"../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as r,releaseMaybe as s}from"../../../../core/maybe.js";import{property as h,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{ortho as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UNIT_X as c,ZEROS as f}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as l}from"../../webgl.js";import{Frustum as p}from"../../state/Frustum.js";import{glLayout as m}from"../../support/buffer/glUtil.js";import{newLayout as _}from"../../support/buffer/InterleavedLayout.js";import g from"../../webgl/RenderCamera.js";import C from"../../webgl/RenderNode.js";import{VertexArrayObject as x}from"./VertexArrayObject.js";import{CutFillMinMaxDepthTechnique as w}from"../shaders/CutFillMinMaxDepthTechnique.js";import{C as T}from"../../../../chunks/CutFillReduction.glsl.js";import{CutFillReductionTechnique as b}from"../shaders/CutFillReductionTechnique.js";import{CutFillReductionTechniqueConfiguration as y}from"../shaders/CutFillReductionTechniqueConfiguration.js";import{C as R}from"../../../../chunks/CutFillTargetDepth.glsl.js";import{CutFillTargetDepthTechnique as B}from"../shaders/CutFillTargetDepthTechnique.js";import{C as F}from"../../../../chunks/CutFillTotalDepth.glsl.js";import{CutFillTotalDepthTechnique as P}from"../shaders/CutFillTotalDepthTechnique.js";import{ImmediateTask as j,TaskPriority as E}from"../../../support/Scheduler.js";import{Yield as D}from"../../../support/Yield.js";import{PrimitiveType as S,DataType as v}from"../../../webgl/enums.js";import{Sync as O}from"../../../webgl/Sync.js";import{VertexBuffer as V}from"../../../webgl/VertexBuffer.js";let M=class extends C{constructor(e){super(e),this.consumes={required:[l.CUTFILL_COMPUTATION,l.TRANSPARENT_NO_DEPTH]},this.produces=l.CUTFILL_COMPUTATION,this.needsRender=!1,this.readyToRun=!1,this.done=!0,this._frameTask=j,this._localOrigin=d(),this._maxTextureSize=512,this._width=0,this._height=0,this._reducedWidth=0,this._reducedHeight=0,this._depthFormat=14,this._colorFormat=11,this._numChannels=4,this._reductionConfiguration=new y,this._targetDepthPass=new R,this._depthPass=new F,this._reductionPass=new T,this._numReductions=2,this._reductionPasses=0,this._pixelBufferSize=0,this._pixelBufferOffset=0,this._perReductionPixelBufferSize=0}initialize(){this._frameTask=this.view.resourceController.scheduler.registerTask(E.VOLUME_MEASUREMENT,this),this.addHandles(this._frameTask),this._maxTextureSize=Math.min(this._maxTextureSize,this.fboCache.rctx.parameters.maxTextureSize),this._frustum=new p(this.view.renderCoordsHelper)}destroy(){this._targetGeometryVao=i(this._targetGeometryVao),this._sync=r(this._sync),this._pixelBuffer&&(this.gl.deleteBuffer(this._pixelBuffer),this._pixelBuffer=null,this._pixelBufferSize=0)}precompile(){this.view.stage.renderer.precompileCutFillDepth()}render(){const e=this.input;if(!this._orthographicCamera||!this._targetGeometryVao||!this.needsRender||this._sync)return e;const t=this.techniques,i=t.getCompiled(B),r=t.getCompiled(P),h=t.getCompiled(w);this._reductionConfiguration.pass=0;const o=t.getCompiled(b,this._reductionConfiguration);this._reductionConfiguration.pass=1;const n=t.getCompiled(b,this._reductionConfiguration);if(!(i&&r&&h&&o&&n))return this.requestRender(1),e;this.needsRender=!1;const a=this.renderingContext,u=this.fboCache,{_width:d,_height:f,_depthPass:l,_depthFormat:p,_colorFormat:m,_orthographicCamera:_,_targetDepthPass:g}=this,C=this.gl,x=a.getViewport();l.referenceDepth=u.acquire(d,f,"cutfill reference depth",p),a.bindFramebuffer(l.referenceDepth.fbo),a.setViewport(0,0,d,f),a.clear(1280),this.view.stage.renderer.renderCutFillDepth(_),l.targetDepth=u.acquire(d,f,"cutfill target depth",p),a.bindFramebuffer(l.targetDepth.fbo),a.setViewport(0,0,d,f),a.setClearDepth(1),a.clear(256),g.origin=this._localOrigin,g.cutFillCamera=_,a.bindTechnique(i,this.bindParameters,g),a.bindVAO(this._targetGeometryVao),a.drawArrays(S.TRIANGLES,0,this._targetGeometryVao.vertexCount("geometry"));const T=u.acquire(d,f,"cutfill reduction even",m),y=u.acquire(Math.ceil(d/2),Math.ceil(f/2),"cutfill reduction odd",m);return this._pixelBuffer||(this._pixelBuffer=C.createBuffer()),C.bindBuffer(C.PIXEL_PACK_BUFFER,this._pixelBuffer),C.bufferData(C.PIXEL_PACK_BUFFER,this._pixelBufferSize,C.STREAM_READ),this._prepareFBO(T,this.width,this.height),a.bindTechnique(r,this.bindParameters,l),a.screen.draw(),this._runPyramidReduction(T,y,o),this._prepareFBO(T,this.width,this.height,c),a.bindTechnique(h,this.bindParameters,l),a.screen.draw(),this._runPyramidReduction(T,y,n),l.referenceDepth=s(l.referenceDepth),l.targetDepth=s(l.targetDepth),T.release(),y.release(),C.bindBuffer(C.PIXEL_PACK_BUFFER,null),a.setViewport(x.x,x.y,x.width,x.height),this._sync=new O(C),setTimeout(()=>this.readyToRun=!0,0),e}update(e,i){if(!this.done)return;this.done=!1;const r=this.renderingContext,{cameraDimensions:{width:s,height:h},localOriginRenderSpace:o}=e,n=this._maxTextureSize,a=h/s,u=s>h?n:n/a,d=s>h?n*a:n;this._width=t(u),this._height=t(d);const c=[this._width,this._height];this._orthographicCamera=this._createCamera(e,c),this._frustum?.update(this._orthographicCamera),this._updateTargetVao(r,i),this._localOrigin=o,this._reductionPasses=Math.ceil(Math.log2(Math.min(this._width,this._height))),this._reducedWidth=Math.ceil(this._width/2**this._reductionPasses),this._reducedHeight=Math.ceil(this._height/2**this._reductionPasses),this._perReductionPixelBufferSize=this._reducedWidth*this._reducedHeight*this._numChannels*4,this._pixelBufferSize=this._perReductionPixelBufferSize*this._numReductions,this._pixelBufferOffset=0,this.needsRender=!0,this.requestRender(1)}runTask(){if(!this._sync)return void(this.readyToRun=!1);try{if(!this._sync.poll())return D}catch(t){return this.readyToRun=!1,void(this._sync=r(this._sync))}this.readyToRun=!1,this._sync=r(this._sync);const e=this.gl;this._cpuBuffer=new Float32Array(this._pixelBufferSize/4),e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pixelBuffer),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._cpuBuffer),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),this._updateResults(this._cpuBuffer),this.done=!0}get result(){return this._result}get frustum(){return this._frustum}get width(){return this._width}get height(){return this._height}get updating(){return this.readyToRun||!this.done||this._frameTask.updating}_runPyramidReduction(e,t,i){const r=this.renderingContext,s=this.gl;let h=this._width,o=this._height;for(let n=0;n<this._reductionPasses;n++)h=Math.ceil(h/2),o=Math.ceil(o/2),this._reductionPass.depthTexture=e.getTexture(),r.bindFramebuffer(t.fbo),r.setViewport(0,0,h,o),r.bindTechnique(i,this.bindParameters,this._reductionPass),r.screen.draw(),[e,t]=[t,e];s.readPixels(0,0,h,o,6408,v.FLOAT,this._pixelBufferOffset),this._pixelBufferOffset+=this._perReductionPixelBufferSize}_updateResults(e){const t=new L(0,1),i=new L(0,0);for(let r=0;r<this._reducedWidth;r++)for(let s=0;s<this._reducedHeight;s++){let h=(r+s*this._reducedWidth)*this._numChannels;const o=this._reducedWidth*this._reducedHeight*this._numChannels;t.totalDepth+=e[h],i.totalDepth+=e[h+1],h+=o;const n=e[h];n<t.depthExtremum&&(t.depthExtremum=n,q(t.depthExtremumCoords,e[h+1],this._width));const a=e[h+2];a>i.depthExtremum&&(i.depthExtremum=a,q(i.depthExtremumCoords,e[h+3],this._width))}this._result=new U(this._width,this._height,t,i)}_prepareFBO(e,t,i,r=f){const s=this.renderingContext;s.bindFramebuffer(e.fbo),s.setViewport(0,0,t,i),s.setClearColor(r[0],r[1],r[2],r[3]),s.clear(16384)}_createCamera(e,t){const{cameraPositionRenderSpace:i,localOriginRenderSpace:r,northVector:s,cameraDimensions:{width:h,height:o},cameraNearFar:{near:a,far:u}}=e,d=new g({eye:i,center:r,up:s,near:a,far:u});return d.viewport=[0,0,t[0],t[1]],n(d.projectionMatrix,-h/2,h/2,-o/2,o/2,a,u),d}_updateTargetVao(e,t){this._targetGeometryVao=i(this._targetGeometryVao);const{positions:r,indices:s}=t,h=s.length,o=A.createBuffer(h),n=o.position;for(let i=0;i<s.length;++i){const e=3*s[i];n.set(i,0,r[e]),n.set(i,1,r[e+1]),n.set(i,2,r[e+2])}const a=new V(e,m(A),o.buffer);this._targetGeometryVao=new x(e,a)}};e([h()],M.prototype,"consumes",void 0),e([h()],M.prototype,"produces",void 0),e([h()],M.prototype,"needsRender",void 0),e([h()],M.prototype,"readyToRun",void 0),e([h()],M.prototype,"done",void 0),e([h()],M.prototype,"_frameTask",void 0),M=e([o("esri.views.3d.webgl-engine.lib.CutFillComputation")],M);const A=_().vec3f("position").freeze();function q(e,t,i){const r=t%i,s=Math.floor(t/i);a(e,r,s)}class z{constructor(e,t){this.positions=e,this.indices=t}}class L{constructor(e,t){this.totalDepth=e,this.depthExtremum=t,this.depthExtremumCoords=u()}}class U{constructor(e=0,t=0,i,r){this.width=e,this.height=t,this.cut=i,this.fill=r}}export{M as CutFillComputation,U as CutFillComputationResult,L as CutFillDepthResult,z as TargetGeometryRenderInfo};