Class: BoundingBox

BoundingBox()

Represents a bounding box in Cartesian coordinates. Typically used as a bounding volume.

Constructor

new BoundingBox()

Constructs a unit bounding box. The unit box has its R, S and T axes aligned with the X, Y and Z axes, respectively, and has its length, width and height set to 1.
Source:

Members

bottomCenter :Vec3

The center point of the box's bottom. (The origin of the R axis.)
Type:
Default Value:
  • (-0.5, 0, 0)
Source:

center :Vec3

The box's center point.
Type:
Default Value:
  • (0, 0, 0)
Source:

r :Vec3

The box's R axis, its longest axis.
Type:
Default Value:
  • (1, 0, 0)
Source:

radius :number

The box's radius. (The half-length of its diagonal.)
Type:
  • number
Default Value:
  • sqrt(3)
Source:

s :Vec3

The box's S axis, its mid-length axis.
Type:
Default Value:
  • (0, 1, 0)
Source:

t :Vec3

The box's T axis, its shortest axis.
Type:
Default Value:
  • (0, 0, 1)
Source:

topCenter :Vec3

The center point of the box's top. (The end of the R axis.)
Type:
Default Value:
  • (0.5, 0, 0)
Source:

Methods

distanceTo(point) → {Number}

Computes the approximate distance between this bounding box and a specified point.

This calculation treats the bounding box as a sphere with the same radius as the box.

Parameters:
Name Type Description
point Vec3 The point to compute the distance to.
Source:
Throws:
If the specified point is null or undefined.
Type
ArgumentError
Returns:
The distance from the edge of this bounding box to the specified point.
Type
Number

effectiveRadius(plane) → {Number}

Computes the effective radius of this bounding box relative to a specified plane.
Parameters:
Name Type Description
plane Plane The plane of interest.
Source:
Throws:
If the specified plane is null or undefined.
Type
ArgumentError
Returns:
The effective radius of this bounding box to the specified plane.
Type
Number

getCorners() → {Array}

Returns the eight Vec3 corners of the box.
Source:
Returns:
the eight box corners in the order bottom-lower-left, bottom-lower-right, bottom-upper-right, bottom-upper-left, top-lower-left, top-lower-right, top-upper-right, top-upper-left.
Type
Array

intersectsFrustum(frustum) → {boolean}

Indicates whether this bounding box intersects a specified frustum.
Parameters:
Name Type Description
frustum Frustum The frustum of interest.
Source:
Throws:
If the specified frustum is null or undefined.
Type
ArgumentError
Returns:
true if the specified frustum intersects this bounding box, otherwise false.
Type
boolean

render(dc)

Renders this bounding box in a semi-transparent color with a highlighted outline. This function is intended for diagnostic use only.
Parameters:
Name Type Description
dc DrawContext dc The current draw context.
Source:

setToPoints(points) → {BoundingBox}

Sets this bounding box such that it minimally encloses a specified collection of points.
Parameters:
Name Type Description
points Float32Array The points to contain.
Source:
Throws:
If the specified list of points is null, undefined or empty.
Type
ArgumentError
Returns:
This bounding box set to contain the specified points.
Type
BoundingBox

setToSector(sector, globe, minElevation, maxElevation) → {BoundingBox}

Sets this bounding box such that it contains a specified sector on a specified globe with min and max elevation.

To create a bounding box that contains the sector at mean sea level, specify zero for the minimum and maximum elevations. To create a bounding box that contains the terrain surface in this sector, specify the actual minimum and maximum elevation values associated with the sector, multiplied by the model's vertical exaggeration.

Parameters:
Name Type Description
sector Sector The sector for which to create the bounding box.
globe Globe The globe associated with the sector.
minElevation Number The minimum elevation within the sector.
maxElevation Number The maximum elevation within the sector.
Source:
Throws:
If either the specified sector or globe is null or undefined.
Type
ArgumentError
Returns:
This bounding box set to contain the specified sector.
Type
BoundingBox

setToVec3Points(points) → {BoundingBox}

Sets this bounding box such that it minimally encloses a specified collection of points.
Parameters:
Name Type Description
points Vec3 The points to contain.
Source:
Throws:
If the specified list of points is null, undefined or empty.
Type
ArgumentError
Returns:
This bounding box set to contain the specified points.
Type
BoundingBox

translate(translation) → {BoundingBox}

Translates this bounding box by a specified translation vector.
Parameters:
Name Type Description
translation Vec3 The translation vector.
Source:
Throws:
If the specified translation vector is null or undefined.
Type
ArgumentError
Returns:
This bounding box translated by the specified translation vector.
Type
BoundingBox