@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 3.97 kB
JavaScript
import t from"../../../../../Color.js";import{unwrap as e}from"../../../../../core/maybe.js";import{E as i}from"../../../../../chunks/mat4.js";import{c as a}from"../../../../../chunks/mat4f64.js";import{s as r}from"../../../../../chunks/vec3.js";import{f as s}from"../../../../../chunks/vec3f64.js";import{sv3d as o,sm4d as n}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as l}from"../../../../../support/elevationInfoUtils.js";import{Manipulator3D as p}from"../../Manipulator3D.js";import{RenderObject as c}from"../../RenderObject.js";import{screenToMapXYAtLocation as m}from"../dragEventPipeline3D.js";import{ManipulatorType as u}from"../ManipulatorType.js";import{colors as h}from"../settings.js";import{DISC_RADIUS as d,GEOMETRY_SEGMENTS as _,DISC_HEIGHT as f,DISC_COLLISION_RADIUS as g}from"./config.js";import{Manipulation as j}from"./Manipulation.js";import{createGraphicMoveDragPipeline as M}from"./moveUtils.js";import{SnapToScene as T}from"../snapping/SnapToScene.js";import{CullFaceOptions as S}from"../../../webgl-engine/lib/basicInterfaces.js";import{createCylinderGeometry as v}from"../../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as w}from"../../../webgl-engine/lib/Material.js";import{ColorMaterial as y}from"../../../webgl-engine/materials/ColorMaterial.js";import{createManipulatorDragEventPipeline as b,dragAtLocation as E,addScreenDelta as x}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as A}from"../../../../interactive/interfaces.js";class k extends j{constructor(t){super(),this._snapToScene=new T,this._discMaterial=this._createMaterial(),this._discMaterialTransparent=this._createMaterial(.5),this._scale=1,this._radius=d,this._view=t.view,this._tool=t.tool,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.forEachManipulator((t=>{this._tool.manipulators.remove(t),t.destroy()})),this._tool=null,this._view=null,this._manipulator=null}forEachManipulator(t){t(this._manipulator,u.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())}createGraphicDragPipeline(t,i,a){const r=i.graphic,s=l(r),o=e(r.geometry).spatialReference;return M(i,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)),this._view.state.viewingMode)}createDragPipeline(t,e,i,a){const r=this._view;return b(this._manipulator,((s,o,n,l,p)=>{const c=o.next(E(r,s.elevationAlignedLocation)).next(m(r,s.elevationAlignedLocation,e,i,a)).next(...this._snapToScene.createDragEventPipelineStep(r,e)).next((t=>({...t,manipulatorType:u.TRANSLATE_XY}))).next(x());t(s,c,n,l,p)}))}_updateManipulatorTransform(){const t=i(n.get(),r(o.get(),this.displayScale,this.displayScale,this.displayScale));this._manipulator.modelTransform=t}_createManipulator(){const t=this._view;this._manipulator=new p({view:t,worldSized:!1,autoScaleRenderObjects:!1,focusMultiplier:1,touchMultiplier:1,collisionType:{type:"disc",direction:s(0,0,1)},worldOriented:!0}),this._updateManipulator()}_updateManipulator(){const t=v(this._discMaterial,f,1,_,s(0,0,1),s(0,0,0));t.transformation=i(a(),s(this._radius,this._radius,this._radius)),this._manipulator.renderObjects=[new c(t,A.Focused),new c(t.instantiate({material:this._discMaterialTransparent}),A.Unfocused)],this._manipulator.radius=g*(this._radius/d)}_createMaterial(e=1){const i=t.toUnitRGBA(h.main);return i[3]*=e,new y({color:i,transparent:1!==e,cullFace:S.Back,renderOccluded:w.Transparent})}get test(){return{discManipulator:this._manipulator}}}export{k as MoveXYDiscManipulation};