UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.15 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{rad2deg as r,clamp as e}from"../../../../core/mathUtils.js";import{fromRotation as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{n as o,c as a,r as s,t as i,f as c,a as m,g as p,h as l}from"../../../../chunks/vec32.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getNormal as f,fromPositionAndNormal as u,create as g}from"../../../../geometry/support/plane.js";import{viewshedToolManipulatorConfiguration as h}from"./ViewshedConfiguration.js";import{calculateTranslateRotateFromBases as j,calculateInputRotationTransform as b}from"../../interactive/manipulatorUtils.js";import{screenToRenderPlane as x}from"../../interactive/editingTools/dragEventPipeline3D.js";import{headingTiltToDirectionUp as v}from"../../support/cameraUtils.js";import{createDirectionUp as S}from"../../support/cameraUtilsInternal.js";function R({tiltedUpVector:r,rightVector:e,observerRenderSpace:t},n){const o=j(r,e,t,n);return o[12]=0,o[13]=0,o[14]=0,o}function U(t,n,s,i){const j=d(),v=f(s.plane),S=E(n,v);let R;if(Math.abs(S)>h.viewAngleThreshold)R=t.next(x(n,s.plane));else{const r=u(i.targetRenderSpace,s.basis1,g()),a=o(D,s.basis1),f=o(M,s.basis2);R=t.next(x(n,r)).next((r=>{const t=r=>{const t=c(m(V,r,s.origin),f),n=Math.acos(e(t/i.farDistanceRenderSpace,-1,1)),o=Math.sin(n)*i.farDistanceRenderSpace;return p(d(),s.origin,p(d(),l(V,a,o),l(w,f,t)))},n=t(r.renderStart),o=t(r.renderEnd);return{...r,renderStart:n,renderEnd:o}}))}return R.next((e=>{"start"===e.action&&a(j,e.renderStart);const t=r(b(j,e.renderEnd,s.origin,v));return{...e,deltaAngle:t}}))}function E(e,t){const n=D;e.renderCoordsHelper.toRenderCoords(e.camera.position,n);const o=v(e,n,e.camera.heading,e.camera.tilt,S()).direction;return r(s(o,t))-90}function C(r,e,n,o){return t(A,n,o),i(r,e,A)}const D=d(),M=d(),V=d(),w=d(),A=n();export{R as getViewshedRotationMatrix,C as rotateBy,U as screenToCircleAngle};