UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 4.2 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{removeHandles as e,handlesGroup as t,destroyHandle as n,refHandle as a}from"../../../../core/handleUtils.js";import{deg2rad as l}from"../../../../core/mathUtils.js";import{watch as i,initial as o}from"../../../../core/reactiveUtils.js";import{signal as s}from"../../../../core/signal.js";import{i as r,f as c,g as m}from"../../../../chunks/vec32.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Manipulator3D as p}from"../Manipulator3D.js";import{GrabbingState as h}from"./GrabbingState.js";import{manipulatedObjectGeometry as d}from"./manipulatedObjectUtils.js";import{ManipulatorState as f}from"./ManipulatorState.js";import{ManipulatorType as v}from"./ManipulatorType.js";import{Settings as g}from"./settings.js";import{ExtendedLineVisualElement as b}from"../visualElements/ExtendedLineVisualElement.js";import{LaserlineVisualElement as E}from"../visualElements/LaserlineVisualElement.js";import{OutlineVisualElement as j}from"../visualElements/OutlineVisualElement.js";import{RenderOccludedFlag as w}from"../../webgl-engine/lib/Material.js";function y(t){const{object:n}=t,a=S(t),l=[a,M(t,a.visualElement)];return n.maskOccludee&&l.push(n.maskOccludee()),{visualElement:a.visualElement,remove:()=>e(l)}}function S(e){const{view:a,object:l}=e,s=d(l),r=new j({view:a,geometry:D(s)?s:null,elevationInfo:l.elevationInfo,attached:!1,isDecoration:!0}),c=new g({getTheme:()=>a.effectiveTheme}),m=()=>{r.attached=l.visible},u=t([i((()=>c.visualElements.lineObjects.outline),(e=>e.apply(r)),o),i((()=>c.visualElements.lineObjects.shadowStyle),(e=>e.apply(r)),o),i((()=>l.visible),m),i((()=>l.isDraped),(e=>{r.isDraped=e}),o),l.on("committed",(()=>{const e=d(l);r.geometry=D(e)?e:null})),n(r)]);return m(),{visualElement:r,remove:()=>u.remove()}}function M(r,c){const{object:m,view:u}=r,p=[],v=m.elevationInfo,j="on-the-ground"===v.mode||!v.offset&&"absolute-height"!==v.mode,y=new f,S=new g({getTheme:()=>u.effectiveTheme}),M=S.visualElements,L=new b({view:u,extensionType:M.zVerticalLine.extensionType,innerWidth:1,attached:!1,writeDepthEnabled:!1,renderOccluded:w.OccludeAndTransparent,isDecoration:!0}),A=l(M.heightPlaneAngleCutoff),x=new E({view:u,attached:!1,angleCutoff:A,isDecoration:!0}),C=s(1);p.push(i((()=>({lineShadowStyle:S.visualElements.lineObjects.shadowStyle,pointShadowStyle:S.visualElements.pointObjects.shadowStyle,alpha:C.value})),(({lineShadowStyle:e,pointShadowStyle:t,alpha:n})=>{e.apply(c,n),t.apply(L,n)}),o));const V=s(1);p.push(i((()=>({heightPlane:S.visualElements.heightPlane,alpha:V.value})),(({heightPlane:e,alpha:t})=>e.apply(x,t)),o));const P=()=>{y.update(r);const e=d(m);if(!m.visible||j&&(m.isDraped||!D(e)||!e.hasZ))return c.laserlineEnabled=!1,L.attached=!1,void(x.attached=!1);c.laserlineEnabled=!0;const t=y.grabbingState&h.XY?M.laserlineAlphaMultiplier:1;C.value=t;const n=y.grabbingState&h.Z?M.laserlineAlphaMultiplier:1;V.value=n,T(L,y),O(r,c,x,y)};p.push(i((()=>S.visualElements.zVerticalLine),(e=>e.apply(L)),o)),p.push(m.on("committed",P),i((()=>m.visible),P),c.events.on("attachment-origin-changed",P),n(L),n(x));const U=[],X=()=>{e(U),U.length=0,r.forEachManipulator((e=>U.push(e.events.on("grab-changed",P)))),r.forEachManipulator((e=>U.push(e.events.on("select-changed",P)))),P()};return X(),p.push(r.onManipulatorsChanged(X),a((()=>t(U)))),t(p)}function T(e,t){const n=1===t.numSelected?t.firstSelected:t.numSelected>1&&null!=t.firstGrabbedXY?t.firstGrabbedXY:null;null!=n?(e.setStartEndFromWorldDownAtLocation(n.renderLocation),e.attached=!0):e.attached=!1}function O(e,t,n,a){if(a.numSelected>0){r(L,0,0,0);let t=0;e.forEachManipulator(((e,n)=>{n===v.TRANSLATE_XY&&e.selected&&e instanceof p&&(c(L,L,e.renderLocation),t++)})),t>0?(n.heightManifoldTarget=m(L,L,1/t),n.attached=!0):n.attached=!1}else{const a=t.attachmentOrigin;null!=a&&e.view.renderCoordsHelper.toRenderCoords(a,L)?(n.heightManifoldTarget=L,n.attached=!0):n.attached=!1}}function D(e){return null!=e&&("polygon"===e.type||"polyline"===e.type)}const L=u();export{y as createVisualElements};