@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.43 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{c as t,o as i}from"../../../chunks/vec32.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{PointIndex as e,create as r,createPoints as _,fromMatrix as n,computePlanes as T,intersectsSphere as o,intersectsRay as R,intersectsLineSegment as u,intersectsPoint as A,planePointIndices as h}from"../../../geometry/support/frustum.js";class O{get planes(){return this.frustum}get points(){return this._points}get mutablePoints(){return this._points}get direction(){return this._direction}get origin(){return this._origin}constructor(t){this.renderCoordsHelper=t,this.frustum=r(),this._points=_(),this.lines=new Array(12),this._origin=s(),this._direction=s(),this._altitude=null;for(let i=0;i<12;i++)this.lines[i]={origin:null,direction:s(),endpoint:null}}update(i){n(i.viewMatrix,i.projectionMatrix,this.frustum,this._points),t(this._origin,i.eye),t(this._direction,i.viewForward),this._altitude=this.renderCoordsHelper.getAltitude(this._origin),this._updateLines()}updatePoints(i){for(let s=0;s<this._points.length;s++)t(this._points[s],i[s]);T(this.frustum,this._points),this._updateLines()}get altitude(){return this._altitude}intersectsSphere(t){return o(this.frustum,t)}intersectsRay(t){return R(this.frustum,t)}intersectsLineSegment(t,i){return u(this.frustum,t,i)}intersectsPoint(t){return A(this.frustum,t)}_updateLines(){const t=this._points;for(let i=0;i<4;i++){const s=i+4;E(this.lines[i],t[i],t[s]),E(this.lines[i+4],t[i],3===i?t[0]:t[i+1]),E(this.lines[i+8],t[s],3===i?t[4]:t[s+1])}}}var F;function E(t,s,e){t.origin=s,t.endpoint=e,i(t.direction,s,e)}O.planePointIndices=h,O.nearFarLineIndices=[[e.NEAR_BOTTOM_LEFT,e.FAR_BOTTOM_LEFT],[e.NEAR_BOTTOM_RIGHT,e.FAR_BOTTOM_RIGHT],[e.NEAR_TOP_RIGHT,e.FAR_TOP_RIGHT],[e.NEAR_TOP_LEFT,e.FAR_TOP_LEFT]],function(t){t[t.NEAR_FAR_BOTTOM_LEFT=0]="NEAR_FAR_BOTTOM_LEFT",t[t.NEAR_FAR_BOTTOM_RIGHT=1]="NEAR_FAR_BOTTOM_RIGHT",t[t.NEAR_FAR_TOP_RIGHT=2]="NEAR_FAR_TOP_RIGHT",t[t.NEAR_FAR_TOP_LEFT=3]="NEAR_FAR_TOP_LEFT",t[t.NEAR_BOTTOM=4]="NEAR_BOTTOM",t[t.NEAR_RIGHT=5]="NEAR_RIGHT",t[t.NEAR_TOP=6]="NEAR_TOP",t[t.NEAR_LEFT=7]="NEAR_LEFT",t[t.FAR_BOTTOM=8]="FAR_BOTTOM",t[t.FAR_RIGHT=9]="FAR_RIGHT",t[t.FAR_TOP=10]="FAR_TOP",t[t.FAR_LEFT=11]="FAR_LEFT"}(F||(F={}));export{O as Frustum,F as LineIndex};