import { vec3 } from "gl-matrix" ; export interface IAABBBounding { min : vec3 ; max : vec3 ; } export interface IAABBOptions { } export const AABB_DEFAULT_OPTIONS = { } ; export class AABB { private _min : vec3 = null ; private _max : vec3 = null ; param options public constructor ( options ? ) { options = Object . assign ( { } , AABB_DEFAULT_OPTIONS , options ) ; this . _min = vec3 . create ( ) ; this . _max = vec3 . create ( ) ; } /**
     * The minimum size of the AABB
     */ public getMin ( ) { return this . _min ; } /**
     * The maximum size of the AABB
     */ public getMax ( ) { return this . _max ; } /**
     * The center of the AABB
     */ public getCenter ( ) { const out = vec3 . create ( ) ; vec3 . add ( out , this . getMin ( ) , this . getMax ( ) ) ; vec3 . scale ( out , out , 0.5 ) ; return out ; } /**
     * The size of the AABB
     */ public getSize ( ) { const out = vec3 . create ( ) ; vec3 . subtract ( out , this . getMax ( ) , this . getMin ( ) ) ; return out ; } param aabb public intersectsAABB ( aabb ) { const min = aabb . getMin ( ) ; const max = aabb . getMax ( ) ; return ! ( max [ 0 ] < this . _min [ 0 ] || min [ 0 ] > this . _max [ 0 ] || max [ 1 ] < this . _min [ 1 ] || min [ 1 ] > this . _max [ 1 ] || max [ 2 ] < this . _min [ 2 ] || min [ 2 ] > this . _max [ 2 ] ) ; } param aabb public containsAABB ( aabb ) { const min = aabb . getMin ( ) ; const max = aabb . getMax ( ) ; return ( this . _min [ 0 ] <= min [ 0 ] && max [ 0 ] <= this . _max [ 0 ] && this . _min [ 1 ] <= min [ 1 ] && max [ 1 ] <= this . _max [ 1 ] && this . _min [ 2 ] <= min [ 2 ] && max [ 2 ] <= this . _max [ 2 ] ) ; } param pt public containsPoint ( pt ) { return ! ( pt [ 0 ] < this . _min [ 0 ] || pt [ 0 ] > this . _max [ 0 ] || pt [ 1 ] < this . _min [ 1 ] || pt [ 1 ] > this . _max [ 1 ] || pt [ 2 ] < this . _min [ 2 ] || pt [ 2 ] > this . _max [ 2 ] ) ; } }