@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 4.36 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import t from"../../../../Color.js";import{getContrast as e}from"../../../../core/colorUtils.js";import{watch as r,initial as o}from"../../../../core/reactiveUtils.js";import{identity as i,translate as a,scale as s,fromQuat as n,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{subtract as p,normalize as u,scale as f,add as d,set as g}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as h,fromValues as b}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{sv3d as j,sm4d as M,sq4d as w}from"../../../../geometry/support/vectorStacks.js";import{shiftRestartOffsetDistance as v,shiftRestartTipRadius as O,shiftRestartTipLength as U,shiftRestartArrowOutlineWidth as x,shiftRestartArrowLength as y,shiftRestartTubeRadius as D,shiftRestartTubeFocusMultiplier as P,shiftRestartTipFocusMultiplier as R}from"./sliceToolConfig.js";import{DidPointerMoveRecentlyFlag as C,IsShiftEdgeOnScreenFlag as G}from"./sliceToolUtils.js";import{Manipulator3D as A}from"../../interactive/Manipulator3D.js";import{RenderObject as B}from"../../interactive/RenderObject.js";import{createPolylineGeometry as F,createConeGeometry as T,createPathExtrusionGeometry as H}from"../../webgl-engine/lib/GeometryUtil.js";import{ColorMaterial as S}from"../../webgl-engine/materials/ColorMaterial.js";import{RibbonLineMaterial as _}from"../../webgl-engine/materials/RibbonLineMaterial.js";class k extends A{constructor(i,a){const s=new _({width:1,renderOccluded:4,isDecoration:!0},i.state.isGlobal),n=new S({cullFace:2,renderOccluded:16,isDecoration:!0}),c=new S({cullFace:2,renderOccluded:16,isDecoration:!0}),l=new S({cullFace:2,renderOccluded:16,isDecoration:!0}),m=new S({writeDepth:!1,cullFace:1,renderOccluded:2,isDecoration:!0});super({view:i,...q({offsetMode:a,tubeMaterial:n,tipMaterial:c,capMaterial:l,outlineMaterial:m,calloutMaterial:s})}),this._themeHandle=r(()=>i.effectiveTheme.accentColor,r=>{const o=e(r),i=r.toUnitRGBA(),a=o.toUnitRGBA(),p=t.blendColors(o,r,.4).toUnitRGBA(),u=t.blendColors(o,r,.14).toUnitRGBA();s.setParameters({color:i}),n.setParameters({color:u}),c.setParameters({color:a}),l.setParameters({color:p}),m.setParameters({color:i})},o)}destroy(){this._themeHandle.remove(),super.destroy()}}function q({offsetMode:t,tubeMaterial:e,tipMaterial:r,capMaterial:o,outlineMaterial:i,calloutMaterial:a}){const s=0===t?v:0,n=[b(s,0,-y/2),b(s,0,y/2)],c=z(n),l=I({vertices:n,padding:0,materials:{tube:e,tip:r,cap:o}}),m=I({vertices:n,padding:x,materials:{tube:i,tip:i,cap:i}}),p=F(a,[[s,0,0],[s-v,0,0]]),u=F(a,[[s,0,0],[s-v,0,0]]);return{renderObjects:[...l.normal.map(t=>new B(t,1|C)),...m.normal.map(t=>new B(t,1|C)),new B(p,1|C|G),...l.focused.map(t=>new B(t,2|C)),...m.focused.map(t=>new B(t,2|C)),new B(u,2|C|G)],autoScaleRenderObjects:!1,collisionType:{type:"line",paths:[c]},collisionPriority:1,radius:O,state:C}}function I({vertices:t,padding:e,materials:r}){const o=o=>{const v=t.slice(),x=p(j.get(),v[0],v[1]);u(x,x);const y=p(j.get(),v[v.length-1],v[v.length-2]);if(u(y,y),e>0){const t=f(h(),y,-e);v[v.length-1]=d(t,t,v[v.length-1]);const r=f(h(),x,-e);v[0]=d(r,r,v[0])}const C=o?R:1,G=U*C,A=O*C,B=i(M.get());if(e>0){const t=G/4,r=g(j.get(),0,t,0),o=1+e/t;a(B,B,r),s(B,B,g(j.get(),o,o,o)),a(B,B,f(r,r,-1/o))}const F=i(l()),H=b(0,1,0),S=n(l(),m(w.get(),H,y));S[12]=v[v.length-1][0],S[13]=v[v.length-1][1],S[14]=v[v.length-1][2],c(S,S,B);const _=r.tube,k=L(D*(o?P:1)+e,v,_);k.transformation=F;const q=[k],I=r.tip,z=T(I,G,A,24,!1,!1,!0);z.transformation=S,q.push(z);const E=r.cap,J=T(E,G,A,24,!1,!0,!1);J.transformation=S,q.push(J);const K=n(l(),m(w.get(),H,x));return K[12]=v[0][0],K[13]=v[0][1],K[14]=v[0][2],c(K,K,B),q.push(z.instantiate({transformation:K})),q.push(J.instantiate({transformation:K})),q};return{normal:o(!1),focused:o(!0)}}function L(t,e,r){const o=[],i=12;for(let a=0;a<i;a++){const e=a/i*2*Math.PI;o.push([Math.cos(e)*t,Math.sin(e)*t])}return H(r,o,e,[],[],!1)}function z(t,e){const r=p(h(),t[t.length-1],t[t.length-2]);u(r,r),f(r,r,U),d(r,r,t[t.length-1]);{const e=p(h(),t[0],t[1]);return u(e,e),f(e,e,U),d(e,e,t[0]),[e,...t,r]}}export{k as ShiftManipulator};