@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 4.85 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */
import{darken as t}from"../../../../../core/colorUtils.js";import{EventEmitter as e}from"../../../../../core/Evented.js";import{makeHandle as i}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{clamp as r}from"../../../../../core/mathUtils.js";import{removeMaybe as a}from"../../../../../core/maybe.js";import{watch as o}from"../../../../../core/reactiveUtils.js";import{translate as s,rotateX as n}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{dist as c,subtract as m,normalize as d,dot as u,cross as p,scale as h}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as f,create as _}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Manipulator3D as j}from"../../Manipulator3D.js";import{createManipulatorMaterial as w}from"../../manipulatorUtils.js";import{RenderObject as v}from"../../RenderObject.js";import{screenToZConstrained as g}from"../dragEventPipeline3D.js";import{Settings as M}from"../settings.js";import{discRadius as b}from"./config.js";import{Manipulation as O}from"./Manipulation.js";import{createManipulatedMoveDragPipeline as U}from"./moveUtils.js";import{createTubeGeometry as P,createConeGeometry as y}from"../../../webgl-engine/lib/GeometryUtil.js";import{createManipulatorDragEventPipeline as x,addScreenDelta as z}from"../../../../interactive/dragEventPipeline.js";class T extends O{constructor(t){super(),this._radius=b,this.events=new e,this._tool=t.tool,this._view=t.view;const i=new M({getTheme:()=>this._view.effectiveTheme});this._settings=i,null!=t.radius&&(this._radius=t.radius);const r=this._view.effectiveTheme.accentColor;this._materials={materialUnfocused:w(D(r,1,.25),1),materialFocused:w(D(r,1,0),1),materialOccludedUnfocused:w(D(r,.7,0),i.zManipulator.renderOccluded),materialOccludedFocused:w(D(r,.85,0),i.zManipulator.renderOccluded)},this._themeHandle=o(()=>this._view.effectiveTheme.accentColor,t=>{const e=D(t,1,.25),i=D(t,1,0),r=D(t,.7,0),a=D(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=a(this._themeHandle),this._manipulator.applyObjectTransform=R,this.forEachManipulator(t=>{this._tool.manipulators.remove(t),t.destroy()})}forEachManipulator(t){t(this._manipulator,0)}createManipulatedObjectDragPipeline(t,e,r){if(!e.operations)return i();const a=e.operations.data.spatialReference;return U(e,r,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:0})).next(g(i,r.renderLocation,e)).next(z());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,c=[f(0,0,0),f(0,0,i)],m=[f(0,0,0),f(0,0,i+r)],d=(()=>{const t=l();return s(t,t,[0,0,i]),n(t,t,Math.PI/2),t})(),{materialUnfocused:u,materialFocused:p,materialOccludedUnfocused:h,materialOccludedFocused:_}=this._materials,j=P(u,c,o/2,16,!1),w=y(u,r,a/2,16,!1);w.transformation=d,this._manipulator.renderObjects=[new v(w,1),new v(j,1),new v(w.instantiate({material:p}),2),new v(j.instantiate({material:p}),2),new v(w.instantiate({material:h}),1),new v(j.instantiate({material:h}),1),new v(w.instantiate({material:_}),2),new v(j.instantiate({material:_}),2)],this._manipulator.radius=o/2+2,this._manipulator.collisionType={type:"line",paths:[m]}}_createManipulator(){const t=this._view,e=new j({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,a=E;t.renderCoordsHelper.toRenderCoords(this._manipulator.elevationAlignedLocation,a);const o=c(i.eye,a),s=i.computeRenderPixelSizeAtDist(o),n=m(F,a,i.eye);d(n,n);const l=H;t.renderCoordsHelper.worldUpAtPosition(E,l);const f=Math.abs(u(n,l)),_=p(F,n,l),j=p(F,_,l),w=r(f,.01,1),v=1-Math.sqrt(1-w*w)/w/i.fullWidth,g=this._settings,M=this._radius/b,O=g.zManipulator.width*M;h(j,d(j,j),(1/v-1)*o+s*O),e[12]-=F[0],e[13]-=F[1],e[14]-=F[2]},this._manipulator=e,this._updateManipulator()}get test(){}}function D(e,i,r){const a=t(e,r);return a.a*=i,a.toUnitRGBA()}const E=_(),F=_(),H=_(),R=()=>{};export{T as MoveZManipulation};