UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 4.47 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import t from"../../../../../Color.js";import e from"../../../../../core/Handles.js";import{makeHandle as i}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{watch as r,initial as s}from"../../../../../core/reactiveUtils.js";import{fromScaling as o}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as l}from"../../../../../chunks/vec32.js";import{fromValues as p}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{sv3d as c,sm4d as m}from"../../../../../geometry/support/vectorStacks.js";import{Manipulator3D as u}from"../../Manipulator3D.js";import{RenderObject as h}from"../../RenderObject.js";import{screenToMapXYAtLocation as d}from"../dragEventPipeline3D.js";import{ManipulatorType as _}from"../ManipulatorType.js";import{discRadius as f,geometrySegments as g,discHeight as j,discCollisionRadius as M}from"./config.js";import{Manipulation as T}from"./Manipulation.js";import{createManipulatedMoveDragPipeline as v}from"./moveUtils.js";import{SnapToScene as S}from"../snapping/SnapToScene.js";import{CullFaceOptions as w}from"../../../webgl-engine/lib/basicInterfaces.js";import{createCylinderGeometry as b}from"../../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as y}from"../../../webgl-engine/lib/Material.js";import{ColorMaterial as x}from"../../../webgl-engine/materials/ColorMaterial.js";import{createManipulatorDragEventPipeline as E,dragAtLocation as A,addScreenDelta as D}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as P}from"../../../../interactive/interfaces.js";class O extends T{constructor(t){super(),this._handles=new e,this._snapToScene=new S,this._scale=1,this._radius=f,this._view=t.view,this._tool=t.tool,this._discMaterial=this._createMaterial(),this._discMaterialTransparent=this._createMaterial(.5),null!=t.snapToScene&&(this.snapToScene=t.snapToScene),null!=t.radius&&(this._radius=t.radius),this._createManipulator(),this.forEachManipulator((t=>this._tool.manipulators.add(t)))}destroy(){this._handles=a(this._handles),this.forEachManipulator((t=>{this._tool.manipulators.remove(t),t.destroy()})),this._tool=null,this._view=null,this._manipulator=null}forEachManipulator(t){t(this._manipulator,_.TRANSLATE_XY)}get displayScale(){return this._scale}set displayScale(t){this._scale=t,this._updateManipulatorTransform()}get snapToScene(){return this._snapToScene.enabled}set snapToScene(t){this._snapToScene.enabled=t}get radius(){return this._radius}set radius(t){t!==this._radius&&(this._radius=t,this._updateManipulator())}get discManipulator(){return this._manipulator}createManipulatedObjectDragPipeline(t,e,a){if(!e.operations)return i();const r=e.graphic,s=e.elevationInfo,o=e.operations.data.spatialReference;return v(e,a,(e=>this.createDragPipeline(((i,a,r,s,o)=>(({steps:a,cancel:r}=t(i,a,r,s,o)),e(i,a,r))),s,o,r)))}createDragPipeline(t,e,i,a){const r=this._view;return E(this._manipulator,((s,o,n,l,p)=>{const c=o.next(A(r,s.elevationAlignedLocation)).next(d(r,s.elevationAlignedLocation,e,i,a)).next(...this._snapToScene.createDragEventPipelineStep(r,e)).next((t=>({...t,manipulatorType:_.TRANSLATE_XY}))).next(D());t(s,c,n,l,p)}))}_updateManipulatorTransform(){const t=o(m.get(),l(c.get(),this.displayScale,this.displayScale,this.displayScale));this._manipulator.modelTransform=t}_createManipulator(){const t=this._view;this._manipulator=new u({view:t,worldSized:!1,autoScaleRenderObjects:!1,focusMultiplier:1,touchMultiplier:1,collisionType:{type:"disc",direction:p(0,0,1)},worldOriented:!0}),this._updateManipulator()}_updateManipulator(){const t=b(this._discMaterial,j,1,g,p(0,0,1),p(0,0,0));t.transformation=o(n(),p(this._radius,this._radius,this._radius)),this._manipulator.renderObjects=[new h(t,P.Focused),new h(t.instantiate({material:this._discMaterialTransparent}),P.Unfocused)],this._manipulator.radius=M*(this._radius/f)}_createMaterial(e=1){const i=new x({cullFace:w.Back,renderOccluded:y.Transparent,isDecoration:!0});return this._handles.add(r((()=>t.toUnitRGBA(this._view.effectiveTheme.accentColor)),(t=>{t[3]*=e,i.setParameters({color:t})}),s)),i}get test(){}}export{O as MoveXYDiscManipulation};