@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 2.73 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */
import{deg2rad as e,rad2deg 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{scale as s,add as a,transformMat4 as c,scaleAndAdd as m,set as l}from"../core/libs/gl-matrix-2/math/vec3.js";import{create as p,fromValues 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{clipPolygonToExtent as T}from"../geometry/support/polygonExtentClipping.js";import{wrap as x}from"../geometry/support/ray.js";import{directionToHeadingTilt as h,createDirectionUp as b,clampLineSegmentToPlane as R}from"../views/3d/support/cameraUtilsInternal.js";const v=f(0,1,0),A=f(0,0,1),w=i(),C=p(),E=p();function H(t,i,n,a=b()){const{direction:m,up:l}=a;return r(w,-e(i)),o(w,w,e(n)),c(m,A,w),s(m,m,-1),c(l,v,w),a}function U(e,t,r,o){return h(t,r,o,A,v)}function V(e,t,r,o){const i=H(e,r,o),n=p();return s(n,i.direction,-t),a(n,n,e),{up:i.up,eye:n,heading:r,tilt:o}}function _(e){return t(e)}function P(t){return e(t)}function S(e,t,r,o,i){const n=e.renderSpatialReference,s=e.spatialReference??t.spatialReference;return d(t,C,n),d(t,E,n),C[0]-=r/2,E[0]+=r/2,C[1]-=o/2,E[1]+=o/2,j(C,n,C,s),j(E,n,E,s),i?(i.xmin=C[0],i.ymin=C[1],i.xmax=E[0],i.ymax=E[1],i.spatialReference=s):i=new u(C[0],C[1],E[0],E[1],s),i}function k(e,t){const r=e.frustum,{renderCoordsHelper:o}=e,i=o.getAltitude(t),s=e.spatialReference,a=e.state.camera.eye,c=[],m=r.planes[5];for(let l=0;l<4;l++){const e=r.lines[l];o.intersectInfiniteManifold(x(e.origin,e.direction),i,O)||I(O,r,o,e.endpoint,i),R(O,a,O,m),c.push(n(O[0],O[1]))}return M(T(c,o.extent),o,s)}function I(e,t,r,o,i){const n=t.lines[11].direction,s=(i-r.getAltitude(o))/n[2];m(e,o,n,s)}function M(e,t,r){const o=e.map(e=>(l(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=p(),z=Object.freeze(Object.defineProperty({__proto__:null,directionToHeadingTilt:U,eyeForCenterWithHeadingTilt:V,eyeTiltToLookAtTilt:P,headingTiltToDirectionUp:H,lookAtTiltToEyeTilt:_,toArea:k,toExtent:S},Symbol.toStringTag,{value:"Module"}));export{P as a,S as b,z as c,U as d,V as e,H as h,_ as l,k as t};