UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 5.24 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import t from"../../../../../Color.js";import{darken as e}from"../../../../../core/colorUtils.js";import i from"../../../../../core/Evented.js";import{makeHandle as r}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{clamp as a}from"../../../../../core/mathUtils.js";import{removeMaybe as o}from"../../../../../core/maybe.js";import{watch as s}from"../../../../../core/reactiveUtils.js";import{translate as n,rotateX as l}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{F as m,d,n as u,e as p,h,g as f}from"../../../../../chunks/vec32.js";import{fromValues as _,create as j}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Manipulator3D as w}from"../../Manipulator3D.js";import{createManipulatorMaterial as v}from"../../manipulatorUtils.js";import{RenderObject as g}from"../../RenderObject.js";import{screenToZConstrained as M}from"../dragEventPipeline3D.js";import{ManipulatorType as U}from"../ManipulatorType.js";import{Settings as O}from"../settings.js";import{discRadius as b}from"./config.js";import{Manipulation as y}from"./Manipulation.js";import{createManipulatedMoveDragPipeline as P}from"./moveUtils.js";import{createTubeGeometry as T,createConeGeometry as F}from"../../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as z}from"../../../webgl-engine/lib/Material.js";import{createManipulatorDragEventPipeline as x,addScreenDelta as A}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as E}from"../../../../interactive/interfaces.js";class R extends y{constructor(t){super(),this._radius=b,this.events=new i,this._tool=t.tool,this._view=t.view;const e=new O({getTheme:()=>this._view.effectiveTheme});this._settings=e,null!=t.radius&&(this._radius=t.radius);const r=this._view.effectiveTheme.accentColor;this._materials={materialUnfocused:v(C(r,1,.25),z.Occlude),materialFocused:v(C(r,1,0),z.Occlude),materialOccludedUnfocused:v(C(r,.7,0),e.zManipulator.renderOccluded),materialOccludedFocused:v(C(r,.85,0),e.zManipulator.renderOccluded)},this._themeHandle=s((()=>this._view.effectiveTheme.accentColor),(t=>{const e=C(t,1,.25),i=C(t,1,0),r=C(t,.7,0),a=C(t,.85,0),{materialUnfocused:o,materialFocused:s,materialOccludedUnfocused:n,materialOccludedFocused:l}=this._materials;o.setParameters({color:e}),s.setParameters({color:i}),n.setParameters({color:r}),l.setParameters({color:a})})),this._createManipulator(),this.forEachManipulator((t=>this._tool.manipulators.add(t)))}destroy(){this._themeHandle=o(this._themeHandle),this._manipulator.applyObjectTransform=L,this.forEachManipulator((t=>{this._tool.manipulators.remove(t),t.destroy()}))}forEachManipulator(t){t(this._manipulator,U.TRANSLATE_Z)}createManipulatedObjectDragPipeline(t,e,i){if(!e.operations)return r();const a=e.operations.data.spatialReference;return P(e,i,(e=>this.createDragPipeline(((i,r,a,o,s)=>(({steps:r,cancel:a}=t(i,r,a,o,s)),e(i,r,a))),a)))}createDragPipeline(t,e){const i=this._view;return x(this._manipulator,((r,a,o,s,n)=>{const l=a.next((t=>({...t,manipulatorType:U.TRANSLATE_Z}))).next(M(i,r.renderLocation,e)).next(A());t(r,l,o,s,n)}))}get radius(){return this._radius}set radius(t){t!==this._radius&&(this._radius=t,this._updateManipulator())}_updateManipulator(){const t=this._settings,e=this._radius/b,i=t.zManipulator.height*e,r=t.zManipulator.coneHeight*e,a=t.zManipulator.coneWidth*e,o=t.zManipulator.width*e,s=[_(0,0,0),_(0,0,i)],m=[_(0,0,0),_(0,0,i+r)],d=(()=>{const t=c();return n(t,t,[0,0,i]),l(t,t,Math.PI/2),t})(),{materialUnfocused:u,materialFocused:p,materialOccludedUnfocused:h,materialOccludedFocused:f}=this._materials,j=T(u,s,o/2,16,!1),w=F(u,r,a/2,16,!1);w.transformation=d,this._manipulator.renderObjects=[new g(w,E.Unfocused),new g(j,E.Unfocused),new g(w.instantiate({material:p}),E.Focused),new g(j.instantiate({material:p}),E.Focused),new g(w.instantiate({material:h}),E.Unfocused),new g(j.instantiate({material:h}),E.Unfocused),new g(w.instantiate({material:f}),E.Focused),new g(j.instantiate({material:f}),E.Focused)],this._manipulator.radius=o/2+2,this._manipulator.collisionType={type:"line",paths:[m]}}_createManipulator(){const t=this._view,e=new w({view:t,autoScaleRenderObjects:!1,worldSized:!1,selectable:!1,cursor:"ns-resize",elevationInfo:this.elevationInfo,worldOriented:!0,collisionPriority:1.6});e.applyObjectTransform=e=>{const i=t.state.camera,r=D;t.renderCoordsHelper.toRenderCoords(this._manipulator.elevationAlignedLocation,r);const o=m(i.eye,r),s=i.computeRenderPixelSizeAtDist(o),n=d(H,r,i.eye);u(n,n);const l=S;t.renderCoordsHelper.worldUpAtPosition(D,l);const c=Math.abs(p(n,l)),_=h(H,n,l),j=h(H,_,l),w=a(c,.01,1),v=1-Math.sqrt(1-w*w)/w/i.fullWidth,g=this._settings,M=this._radius/b,U=g.zManipulator.width*M;f(j,u(j,j),(1/v-1)*o+s*U),e[12]-=H[0],e[13]-=H[1],e[14]-=H[2]},this._manipulator=e,this._updateManipulator()}get test(){}}function C(i,r,a){const o=e(i,a);return o.a*=r,t.toUnitRGBA(o)}const D=j(),H=j(),S=j(),L=()=>{};export{R as MoveZManipulation};