@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.45 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{c as t,E as i}from"../../../chunks/vec32.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as e,createPoints as r,fromMatrix as _,computePlanes as n,intersectsSphere as T,intersectsRay as o,intersectsLineSegment as R,intersectsPoint as u,planePointIndices as A,PointIndex 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=e(),this._points=r(),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){_(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]);n(this.frustum,this._points),this._updateLines()}get altitude(){return this._altitude}intersectsSphere(t){return T(this.frustum,t)}intersectsRay(t){return o(this.frustum,t)}intersectsLineSegment(t,i){return R(this.frustum,t,i)}intersectsPoint(t){return u(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])}}static{this.planePointIndices=A}static{this.nearFarLineIndices=[[h.NEAR_BOTTOM_LEFT,h.FAR_BOTTOM_LEFT],[h.NEAR_BOTTOM_RIGHT,h.FAR_BOTTOM_RIGHT],[h.NEAR_TOP_RIGHT,h.FAR_TOP_RIGHT],[h.NEAR_TOP_LEFT,h.FAR_TOP_LEFT]]}}var F;function E(t,s,e){t.origin=s,t.endpoint=e,i(t.direction,s,e)}!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};