@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.89 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{rad2deg as e,deg2rad as t}from"../core/mathUtils.js";import{fromZRotation as r,rotateX as o}from"../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as n}from"../core/libs/gl-matrix-2/factories/vec2f64.js";import{t as s,g as a,f as m,b as c,i as p}from"./vec32.js";import{fromValues as l,create as f}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import u from"../geometry/Extent.js";import g from"../geometry/Polygon.js";import{projectPointToVector as d}from"../geometry/projection/projectPointToVector.js";import{projectVectorToVector as j}from"../geometry/projection/projectVectorToVector.js";import{isClockwise as y}from"../geometry/support/coordsUtils.js";import{PlaneIndex as T}from"../geometry/support/frustum.js";import{clipPolygonToExtent as x}from"../geometry/support/polygonExtentClipping.js";import{wrap as R}from"../geometry/support/ray.js";import{LineIndex as b}from"../views/3d/state/Frustum.js";import{createDirectionUp as h,directionToHeadingTilt as v,clampLineSegmentToPlane as A}from"../views/3d/support/cameraUtilsInternal.js";const w=l(0,1,0),E=l(0,0,1),F=i(),_=f(),C=f();function H(e,i,n,m=h()){const{direction:c,up:p}=m;return r(F,-t(i)),o(F,F,t(n)),s(c,E,F),a(c,c,-1),s(p,w,F),m}function U(e,t,r,o){return v(t,r,o,E,w)}function V(e,t,r,o){const i=H(e,r,o),n=f();return a(n,i.direction,-t),m(n,n,e),{up:i.up,eye:n,heading:r,tilt:o}}function P(t){return e(t)}function S(e){return t(e)}function k(e,t,r,o,i){const n=e.renderSpatialReference,s=e.spatialReference??t.spatialReference;return d(t,_,n),d(t,C,n),_[0]-=r/2,C[0]+=r/2,_[1]-=o/2,C[1]+=o/2,j(_,n,_,s),j(C,n,C,s),i?(i.xmin=_[0],i.ymin=_[1],i.xmax=C[0],i.ymax=C[1],i.spatialReference=s):i=new u(_[0],_[1],C[0],C[1],s),i}function I(e,t){const r=e.frustum,{renderCoordsHelper:o}=e,i=o.getAltitude(t),s=e.spatialReference,a=e.state.camera.eye,m=[],c=r.planes[T.FAR];for(let p=0;p<4;p++){const e=r.lines[p];o.intersectInfiniteManifold(R(e.origin,e.direction),i,O)||L(O,r,o,e.endpoint,i),A(O,a,O,c),m.push(n(O[0],O[1]))}return M(x(m,o.extent),o,s)}function L(e,t,r,o,i){const n=t.lines[b.FAR_LEFT].direction,s=(i-r.getAltitude(o))/n[2];c(e,o,n,s)}function M(e,t,r){const o=e.map((e=>(p(O,e[0],e[1],0),t.fromRenderCoords(O,O,r),[O[0],O[1]])));return o.length<=2?new g({spatialReference:r}):(o.push(o[0].slice()),y(o)||o.reverse(),new g({rings:[o],spatialReference:r}))}const O=f(),z=Object.freeze(Object.defineProperty({__proto__:null,directionToHeadingTilt:U,eyeForCenterWithHeadingTilt:V,eyeTiltToLookAtTilt:S,headingTiltToDirectionUp:H,lookAtTiltToEyeTilt:P,toArea:I,toExtent:k},Symbol.toStringTag,{value:"Module"}));export{S as a,I as b,z as c,U as d,V as e,H as h,P as l,k as t};