@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 1.75 kB
JavaScript
import{c as t,r as i}from"../../../chunks/vec3.js";import{c as s}from"../../../chunks/vec3f64.js";import{PointIndex as e,create as r,createPoints as n,fromMatrix as o,computePlanes as u,intersectsSphere as h,intersectsRay as _,intersectsLineSegment as p,intersectsPoint as l,planePointIndices as c}from"../../../geometry/support/frustum.js";class d{get planes(){return this.frustum}get points(){return this._points}get mutablePoints(){return this._points}get direction(){return this._direction}constructor(t){this.renderCoordsHelper=t,this.frustum=r(),this._points=n(),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){o(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]);u(this.frustum,this._points),this._updateLines()}get altitude(){return this._altitude}intersectsSphere(t){return h(this.frustum,t)}intersectsRay(t){return _(this.frustum,t)}intersectsLineSegment(t,i){return p(this.frustum,t,i)}intersectsPoint(t){return l(this.frustum,t)}_updateLines(){const t=this._points;for(let i=0;i<4;i++){const s=i+4;a(this.lines[i],t[i],t[s]),a(this.lines[i+4],t[i],3===i?t[0]:t[i+1]),a(this.lines[i+8],t[s],3===i?t[4]:t[s+1])}}}function a(t,s,e){t.origin=s,t.endpoint=e,i(t.direction,s,e)}d.planePointIndices=c,d.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]];export{d as Frustum};