Skip to content

BoundingBox

Axis-aligned bounding box for collision and visibility testing

Example:

javascript
var box = entity.boundingBox;
var center = box.center;
var size = box.extents;

// Check if point is inside
if (BoundingBox.contains(box, point)) {
    console.log('Point inside!');
}

// Check intersection
if (BoundingBox.intersects(box1, box2)) {
    console.log('Boxes overlap!');
}

Properties

boundingRadius

  • Type: number
  • Radius of bounding sphere

center

  • Type: Vector3
  • Center point of the box

extents

  • Type: Vector3
  • Half-size extents from center

isEmpty

  • Type: boolean
  • Whether the box has zero volume

max

  • Type: Vector3
  • Maximum corner of the box

min

  • Type: Vector3
  • Minimum corner of the box

Methods

contains()

javascript
contains(box: BoundingBox, point: Vector3): boolean

Check if a point is inside the box

Parameters:

Returns: boolean

contains()

javascript
contains(point: Vector3): boolean

Check if point is inside bounding box

Parameters:

Returns: boolean

containsBox()

javascript
containsBox(box1: BoundingBox, box2: BoundingBox): boolean

Check if one box fully contains another

Parameters:

Returns: boolean

containsBox()

javascript
containsBox(other: BoundingBox): boolean

Check if another bounding box is fully contained

Parameters:

Returns: boolean

create()

javascript
create(min: Vector3, max: Vector3): BoundingBox

Create a bounding box from min/max corners

Parameters:

Returns: BoundingBox

createEmpty()

javascript
createEmpty(): BoundingBox

Create an empty bounding box

Returns: BoundingBox

intersects()

javascript
intersects(box1: BoundingBox, box2: BoundingBox): boolean

Check if two boxes intersect

Parameters:

Returns: boolean

intersects()

javascript
intersects(other: BoundingBox): boolean

Check if bounding boxes intersect

Parameters:

Returns: boolean