UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 4.9 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import e from"../../../../Color.js";import{getContrast as t}from"../../../../core/colorUtils.js";import{watch as r,initial as o}from"../../../../core/reactiveUtils.js";import{identity as a,translate as n,scale as i,fromQuat as s,multiply as c}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{rotationTo as m}from"../../../../core/libs/gl-matrix-2/math/quat.js";import{d as p,n as u,g as f,f as d,i as g}from"../../../../chunks/vec32.js";import{create as h,fromValues as b}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{sv3d as j,sm4d as O,sq4d as w}from"../../../../geometry/support/vectorStacks.js";import{shiftRestartOffsetDistance as M,shiftRestartTipRadius as R,shiftRestartTipLength as v,shiftRestartArrowOutlineWidth as C,shiftRestartArrowLength as T,shiftRestartTubeRadius as U,shiftRestartTubeFocusMultiplier as _,shiftRestartTipFocusMultiplier as A}from"./sliceToolConfig.js";import{DidPointerMoveRecentlyFlag as E,IsShiftEdgeOnScreenFlag as N}from"./sliceToolUtils.js";import{Manipulator3D as F}from"../../interactive/Manipulator3D.js";import{RenderObject as y}from"../../interactive/RenderObject.js";import{CullFaceOptions as B}from"../../webgl-engine/lib/basicInterfaces.js";import{createPolylineGeometry as D,createConeGeometry as L,createPathExtrusionGeometry as P}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as x}from"../../webgl-engine/lib/Material.js";import{ColorMaterial as k}from"../../webgl-engine/materials/ColorMaterial.js";import{RibbonLineMaterial as G}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{ManipulatorStateFlags as q}from"../../../interactive/interfaces.js";var H;!function(e){e[e.CENTER_ON_CALLOUT=0]="CENTER_ON_CALLOUT",e[e.CENTER_ON_ARROW=1]="CENTER_ON_ARROW"}(H||(H={}));class I extends F{constructor(a,n){const i=new G({width:1,renderOccluded:x.OccludeAndTransparent,isDecoration:!0}),s=new k({cullFace:B.Back,renderOccluded:x.Opaque,isDecoration:!0}),c=new k({cullFace:B.Back,renderOccluded:x.Opaque,isDecoration:!0}),l=new k({cullFace:B.Back,renderOccluded:x.Opaque,isDecoration:!0}),m=new k({writeDepth:!1,cullFace:B.Front,renderOccluded:x.Transparent,isDecoration:!0});super({view:a,...S({offsetMode:n,tubeMaterial:s,tipMaterial:c,capMaterial:l,outlineMaterial:m,calloutMaterial:i})}),this._themeHandle=r((()=>a.effectiveTheme.accentColor),(r=>{const o=t(r),a=e.toUnitRGBA(r),n=e.toUnitRGBA(o),p=e.toUnitRGBA(e.blendColors(o,r,.4)),u=e.toUnitRGBA(e.blendColors(o,r,.14));i.setParameters({color:a}),s.setParameters({color:u}),c.setParameters({color:n}),l.setParameters({color:p}),m.setParameters({color:a})}),o)}destroy(){this._themeHandle.remove(),super.destroy()}}function S({offsetMode:e,tubeMaterial:t,tipMaterial:r,capMaterial:o,outlineMaterial:a,calloutMaterial:n}){const i=e===H.CENTER_ON_CALLOUT?M:0,s=[b(i,0,-24),b(i,0,T/2)],c=J(s),l=W({vertices:s,padding:0,materials:{tube:t,tip:r,cap:o}}),m=W({vertices:s,padding:C,materials:{tube:a,tip:a,cap:a}}),p=D(n,[[i,0,0],[i-M,0,0]]),u=D(n,[[i,0,0],[i-M,0,0]]);return{renderObjects:[...l.normal.map((e=>new y(e,q.Unfocused|E))),...m.normal.map((e=>new y(e,q.Unfocused|E))),new y(p,q.Unfocused|E|N),...l.focused.map((e=>new y(e,q.Focused|E))),...m.focused.map((e=>new y(e,q.Focused|E))),new y(u,q.Focused|E|N)],autoScaleRenderObjects:!1,collisionType:{type:"line",paths:[c]},collisionPriority:1,radius:R,state:E}}function W({vertices:e,padding:t,materials:r}){const o=o=>{const M=e.slice(),C=p(j.get(),M[0],M[1]);u(C,C);const T=p(j.get(),M[M.length-1],M[M.length-2]);if(u(T,T),t>0){const e=f(h(),T,-t);M[M.length-1]=d(e,e,M[M.length-1]);const r=f(h(),C,-t);M[0]=d(r,r,M[0])}const E=o?A:1,N=v*E,F=R*E,y=a(O.get());if(t>0){const e=N/4,r=g(j.get(),0,e,0),o=1+t/e;n(y,y,r),i(y,y,g(j.get(),o,o,o)),n(y,y,f(r,r,-1/o))}const B=a(l()),D=b(0,1,0),P=s(l(),m(w.get(),D,T));P[12]=M[M.length-1][0],P[13]=M[M.length-1][1],P[14]=M[M.length-1][2],c(P,P,y);const x=r.tube,k=z(U*(o?_:1)+t,M,x);k.transformation=B;const G=[k],q=r.tip,H=L(q,N,F,24,!1,!1,!0);H.transformation=P,G.push(H);const I=r.cap,S=L(I,N,F,24,!1,!0,!1);S.transformation=P,G.push(S);const W=s(l(),m(w.get(),D,C));return W[12]=M[0][0],W[13]=M[0][1],W[14]=M[0][2],c(W,W,y),G.push(H.instantiate({transformation:W})),G.push(S.instantiate({transformation:W})),G};return{normal:o(!1),focused:o(!0)}}function z(e,t,r){const o=[],a=12;for(let n=0;n<a;n++){const t=n/a*2*Math.PI;o.push([Math.cos(t)*e,Math.sin(t)*e])}return P(r,o,t,[],[],!1)}function J(e,t){const r=p(h(),e[e.length-1],e[e.length-2]);u(r,r),f(r,r,v),d(r,r,e[e.length-1]);{const t=p(h(),e[0],e[1]);return u(t,t),f(t,t,v),d(t,t,e[0]),[t,...e,r]}}export{H as OffsetMode,I as ShiftManipulator};