@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 4.58 kB
JavaScript
/*
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,destroyHandle as t,refHandle as o}from"../../../../core/handleUtils.js";import{deg2rad as n}from"../../../../core/mathUtils.js";import{watch as i,initial as l}from"../../../../core/reactiveUtils.js";import{signal as r}from"../../../../core/signal.js";import{i as a}from"../../../../chunks/vec32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectPointToVector as c}from"../../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as p}from"../../../../geometry/projection/projectVectorToVector.js";import{empty as m,create as u,getMin as f}from"../../../../geometry/support/aaBoundingBox.js";import{containsXY as h}from"../../../../geometry/support/aaBoundingRect.js";import{featureExpressionInfoIsZero as v}from"../../../../support/elevationInfoUtils.js";import{GrabbingState as d}from"./GrabbingState.js";import{manipulatedObjectGeometry as g}from"./manipulatedObjectUtils.js";import{ManipulatorState as j}from"./ManipulatorState.js";import{Settings as b}from"./settings.js";import{ExtendedLineVisualElement as w}from"../visualElements/ExtendedLineVisualElement.js";import{LaserlineVisualElement as y}from"../visualElements/LaserlineVisualElement.js";import{PointVisualElement as E}from"../visualElements/PointVisualElement.js";import{evaluateElevationAlignmentAtPoint as T}from"../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as x}from"../../layers/graphics/ElevationContext.js";import{RenderOccludedFlag as D}from"../../webgl-engine/lib/Material.js";function P(t){const o=[],n=S(t,o);return I(t,o,n),{visualElement:n,remove:()=>e(o)}}function I(e,o,s){const{view:c,object:u}=e,h=new b({getTheme:()=>c.effectiveTheme}),E=new w({view:c,extensionType:h.visualElements.zVerticalLine.extensionType,innerWidth:1,attached:!1,writeDepthEnabled:!1,renderOccluded:D.OccludeAndTransparent,isDecoration:!0});o.push(i((()=>h.visualElements.zVerticalLine),(e=>e.apply(E)),l));const P=new y({view:c,intersectsLineInfinite:!0,attached:!1,isDecoration:!0}),I=n(h.visualElements.heightPlaneAngleCutoff),S=new y({view:c,attached:!1,angleCutoff:I,isDecoration:!0}),A=u.elevationInfo,L=x.fromElevationInfo(A),M="on-the-ground"===A.mode||!A.offset&&"absolute-height"!==A.mode,R=new j,O=r(1);o.push(i((()=>({heightPlane:h.visualElements.heightPlane,alpha:O.value})),(({heightPlane:e,alpha:t})=>e.apply(S,t)),l));const z=r(1);o.push(i((()=>({shadowStyle:h.visualElements.pointObjects.shadowStyle,alpha:z.value})),(({shadowStyle:e,alpha:t})=>e.apply(P,t)),l));const B=()=>{R.update(e);let t=V(g(u));const o=M&&(u.isDraped||null==t||!t.hasZ);let n=!0;if(o||null==t)n=!1;else{v(u.elevationInfo)&&(t=t.clone(),t.z=0);const e=T(t,c.elevationProvider,L,c.renderCoordsHelper);a(U,t.x,t.y,e),p(U,t.spatialReference,U,c.renderCoordsHelper.spatialReference),E.setStartEndFromWorldDownAtLocation(U),P.intersectsWorldUpAtLocation=U}const i=R.grabbingState&d.Z?h.visualElements.laserlineAlphaMultiplier:1;O.value=i;const l=m(C);!o&&u.visible&&s.calculateMapBounds(l)&&p(f(l,U),c.spatialReference,U,c.renderCoordsHelper.spatialReference)?(S.heightManifoldTarget=U,S.attached=!0):S.attached=!1;const r=R.grabbingState&d.XY?h.visualElements.laserlineAlphaMultiplier:1;z.value=r;const j=n&&u.visible&&!o;P.attached=j,E.attached=j};o.push(i((()=>[u.visible,u.isDraped]),B),u.on("committed",B)),e.forEachManipulator((e=>{o.push(e.events.on("grab-changed",B))})),o.push(t(P)),o.push(t(E)),o.push(t(S)),B()}function S(e,o){const{view:n,object:i}=e,l=new E({view:n,geometry:V(g(i)),elevationInfo:i.elevationInfo,isDecoration:!0});return A(e,l,o),o.push(t(l)),l}function V(e){return null==e?null:"point"===e.type?e:"mesh"===e.type?e.origin.clone():null}function A(e,t,o){const{view:n,object:r}=e,a=()=>{t.attached=r.visible},s=new b({getTheme:()=>n.effectiveTheme});L(e,t,o),s.visualElements.pointObjects.outline.apply(t),o.push(i((()=>r.visible),a,l))}function L(e,t,n){const{view:i,object:l}=e;let r=null;const a=e=>{null!=r&&(r.remove(),r=null),l.isDraped&&null!=e&&(r=M(i,e,(()=>{t.geometry=e})))},s=()=>{const e=V(g(l));null!=e&&v(l.elevationInfo)&&(e.z=0),a(e),t.geometry=e};n.push(l.on("committed",s),o((()=>r))),s()}function M(e,t,o){const n=e.elevationProvider.spatialReference;c(t,U,n);const i=U[0],l=U[1];return e.elevationProvider.on("elevation-change",(e=>{h(e.extent,i,l)&&o()}))}const U=s(),C=u();export{P as createVisualElements};