Class: OrientedBoundingBox

OrientedBoundingBox

new OrientedBoundingBox(centeropt, halfAxesopt)

Creates an instance of an OrientedBoundingBox. An OrientedBoundingBox of some object is a closed and convex cuboid. It can provide a tighter bounding volume than BoundingSphere or AxisAlignedBoundingBox in many cases.
Parameters:
Name Type Attributes Default Description
center Cartesian3 <optional>
Cartesian3.ZERO The center of the box.
halfAxes Matrix3 <optional>
Matrix3.ZERO The three orthogonal half-axes of the bounding box. Equivalently, the transformation matrix, to rotate and scale a 2x2x2 cube centered at the origin.
Source:
See:
Example
// Create an OrientedBoundingBox using a transformation matrix, a position where the box will be translated, and a scale.
var center = new Cesium.Cartesian3(1.0, 0.0, 0.0);
var halfAxes = Cesium.Matrix3.fromScale(new Cesium.Cartesian3(1.0, 3.0, 2.0), new Cesium.Matrix3());

var obb = new Cesium.OrientedBoundingBox(center, halfAxes);

Members

center :Cartesian3

The center of the box.
Type:
Default Value:
Source:

halfAxes :Matrix3

The transformation matrix, to rotate the box to the right position.
Type:
Default Value:
Source:

Methods

(static) clone(box, resultopt) → {OrientedBoundingBox}

Duplicates a OrientedBoundingBox instance.
Parameters:
Name Type Attributes Description
box OrientedBoundingBox The bounding box to duplicate.
result OrientedBoundingBox <optional>
The object onto which to store the result.
Source:
Returns:
The modified result parameter or a new OrientedBoundingBox instance if none was provided. (Returns undefined if box is undefined)
Type
OrientedBoundingBox

(static) computePlaneDistances(box, position, direction, resultopt) → {Interval}

The distances calculated by the vector from the center of the bounding box to position projected onto direction.
If you imagine the infinite number of planes with normal direction, this computes the smallest distance to the closest and farthest planes from position that intersect the bounding box.
Parameters:
Name Type Attributes Description
box OrientedBoundingBox The bounding box to calculate the distance to.
position Cartesian3 The position to calculate the distance from.
direction Cartesian3 The direction from position.
result Interval <optional>
A Interval to store the nearest and farthest distances.
Source:
Returns:
The nearest and farthest distances on the bounding box from position in direction.
Type
Interval

(static) distanceSquaredTo(box, cartesian) → {Number}

Computes the estimated distance squared from the closest point on a bounding box to a point.
Parameters:
Name Type Description
box OrientedBoundingBox The box.
cartesian Cartesian3 The point
Source:
Returns:
The estimated distance squared from the bounding sphere to the point.
Type
Number
Example
// Sort bounding boxes from back to front
boxes.sort(function(a, b) {
    return Cesium.OrientedBoundingBox.distanceSquaredTo(b, camera.positionWC) - Cesium.OrientedBoundingBox.distanceSquaredTo(a, camera.positionWC);
});

(static) equals(left, right) → {Boolean}

Compares the provided OrientedBoundingBox componentwise and returns true if they are equal, false otherwise.
Parameters:
Name Type Description
left OrientedBoundingBox The first OrientedBoundingBox.
right OrientedBoundingBox The second OrientedBoundingBox.
Source:
Returns:
true if left and right are equal, false otherwise.
Type
Boolean

(static) fromPoints(positions, resultopt) → {OrientedBoundingBox}

Computes an instance of an OrientedBoundingBox of the given positions. This is an implementation of Stefan Gottschalk's Collision Queries using Oriented Bounding Boxes solution (PHD thesis). Reference: http://gamma.cs.unc.edu/users/gottschalk/main.pdf
Parameters:
Name Type Attributes Description
positions Array.<Cartesian3> List of Cartesian3 points that the bounding box will enclose.
result OrientedBoundingBox <optional>
The object onto which to store the result.
Source:
Returns:
The modified result parameter or a new OrientedBoundingBox instance if one was not provided.
Type
OrientedBoundingBox
Example
// Compute an object oriented bounding box enclosing two points.
var box = Cesium.OrientedBoundingBox.fromPoints([new Cesium.Cartesian3(2, 0, 0), new Cesium.Cartesian3(-2, 0, 0)]);

(static) fromRectangle(rectangle, minimumHeightopt, maximumHeightopt, ellipsoidopt, resultopt) → {OrientedBoundingBox}

Computes an OrientedBoundingBox that bounds a Rectangle on the surface of an Ellipsoid. There are no guarantees about the orientation of the bounding box.
Parameters:
Name Type Attributes Default Description
rectangle Rectangle The cartographic rectangle on the surface of the ellipsoid.
minimumHeight Number <optional>
0.0 The minimum height (elevation) within the tile.
maximumHeight Number <optional>
0.0 The maximum height (elevation) within the tile.
ellipsoid Ellipsoid <optional>
Ellipsoid.WGS84 The ellipsoid on which the rectangle is defined.
result OrientedBoundingBox <optional>
The object onto which to store the result.
Source:
Throws:
  • rectangle.width must be between 0 and pi.
    Type
    DeveloperError
  • rectangle.height must be between 0 and pi.
    Type
    DeveloperError
  • ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)
    Type
    DeveloperError
Returns:
The modified result parameter or a new OrientedBoundingBox instance if none was provided.
Type
OrientedBoundingBox

(static) intersectPlane(box, plane) → {Intersect}

Determines which side of a plane the oriented bounding box is located.
Parameters:
Name Type Description
box OrientedBoundingBox The oriented bounding box to test.
plane Plane The plane to test against.
Source:
Returns:
Intersect.INSIDE if the entire box is on the side of the plane the normal is pointing, Intersect.OUTSIDE if the entire box is on the opposite side, and Intersect.INTERSECTING if the box intersects the plane.
Type
Intersect

(static) isOccluded(box, occluder) → {Boolean}

Determines whether or not a bounding box is hidden from view by the occluder.
Parameters:
Name Type Description
box OrientedBoundingBox The bounding box surrounding the occludee object.
occluder Occluder The occluder.
Source:
Returns:
true if the box is not visible; otherwise false.
Type
Boolean

clone(resultopt) → {OrientedBoundingBox}

Duplicates this OrientedBoundingBox instance.
Parameters:
Name Type Attributes Description
result OrientedBoundingBox <optional>
The object onto which to store the result.
Source:
Returns:
The modified result parameter or a new OrientedBoundingBox instance if one was not provided.
Type
OrientedBoundingBox

computePlaneDistances(position, direction, resultopt) → {Interval}

The distances calculated by the vector from the center of the bounding box to position projected onto direction.
If you imagine the infinite number of planes with normal direction, this computes the smallest distance to the closest and farthest planes from position that intersect the bounding box.
Parameters:
Name Type Attributes Description
position Cartesian3 The position to calculate the distance from.
direction Cartesian3 The direction from position.
result Interval <optional>
A Interval to store the nearest and farthest distances.
Source:
Returns:
The nearest and farthest distances on the bounding box from position in direction.
Type
Interval

distanceSquaredTo(cartesian) → {Number}

Computes the estimated distance squared from the closest point on a bounding box to a point.
Parameters:
Name Type Description
cartesian Cartesian3 The point
Source:
Returns:
The estimated distance squared from the bounding sphere to the point.
Type
Number
Example
// Sort bounding boxes from back to front
boxes.sort(function(a, b) {
    return b.distanceSquaredTo(camera.positionWC) - a.distanceSquaredTo(camera.positionWC);
});

equals(rightopt) → {Boolean}

Compares this OrientedBoundingBox against the provided OrientedBoundingBox componentwise and returns true if they are equal, false otherwise.
Parameters:
Name Type Attributes Description
right OrientedBoundingBox <optional>
The right hand side OrientedBoundingBox.
Source:
Returns:
true if they are equal, false otherwise.
Type
Boolean

intersectPlane(plane) → {Intersect}

Determines which side of a plane the oriented bounding box is located.
Parameters:
Name Type Description
plane Plane The plane to test against.
Source:
Returns:
Intersect.INSIDE if the entire box is on the side of the plane the normal is pointing, Intersect.OUTSIDE if the entire box is on the opposite side, and Intersect.INTERSECTING if the box intersects the plane.
Type
Intersect

isOccluded(occluder) → {Boolean}

Determines whether or not a bounding box is hidden from view by the occluder.
Parameters:
Name Type Description
occluder Occluder The occluder.
Source:
Returns:
true if the sphere is not visible; otherwise false.
Type
Boolean