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.
| Name | Type | Default | Description |
|---|---|---|---|
center |
Cartesian3 |
Cartesian3.ZERO
|
optional The center of the box. |
halfAxes |
Matrix3 |
Matrix3.ZERO
|
optional The three orthogonal half-axes of the bounding box. Equivalently, the transformation matrix, to rotate and scale a 2x2x2 cube centered at the origin. |
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);
See:
Members
-
center : Cartesian3
-
The center of the box.
-
Default Value:
Cartesian3.ZERO -
halfAxes : Matrix3
-
The transformation matrix, to rotate the box to the right position.
-
Default Value:
Matrix3.IDENTITY
Methods
-
staticCesium.OrientedBoundingBox.clone(box, result) → OrientedBoundingBox
-
Duplicates a OrientedBoundingBox instance.
Name Type Description boxOrientedBoundingBox The bounding box to duplicate. resultOrientedBoundingBox optional The object onto which to store the result. Returns:
The modified result parameter or a new OrientedBoundingBox instance if none was provided. (Returns undefined if box is undefined) -
staticCesium.OrientedBoundingBox.computePlaneDistances(box, position, direction, result) → 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.Name Type Description boxOrientedBoundingBox The bounding box to calculate the distance to. positionCartesian3 The position to calculate the distance from. directionCartesian3 The direction from position. resultInterval optional A Interval to store the nearest and farthest distances. Returns:
The nearest and farthest distances on the bounding box from position in direction. -
Computes the estimated distance squared from the closest point on a bounding box to a point.
Name Type Description boxOrientedBoundingBox The box. cartesianCartesian3 The point Returns:
The estimated distance squared from the bounding sphere to the point.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); }); -
Compares the provided OrientedBoundingBox componentwise and returns
trueif they are equal,falseotherwise.Name Type Description leftOrientedBoundingBox The first OrientedBoundingBox. rightOrientedBoundingBox The second OrientedBoundingBox. Returns:
trueif left and right are equal,falseotherwise. -
staticCesium.OrientedBoundingBox.fromPoints(positions, result) → 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
Name Type Description positionsArray.<Cartesian3> List of Cartesian3points that the bounding box will enclose.resultOrientedBoundingBox optional The object onto which to store the result. Returns:
The modified result parameter or a new OrientedBoundingBox instance if one was not provided.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)]); -
staticCesium.OrientedBoundingBox.fromRectangle(rectangle, minimumHeight, maximumHeight, ellipsoid, result) → OrientedBoundingBox
-
Computes an OrientedBoundingBox that bounds a
Rectangleon the surface of anEllipsoid. There are no guarantees about the orientation of the bounding box.Name Type Default Description rectangleRectangle The cartographic rectangle on the surface of the ellipsoid. minimumHeightNumber 0.0optional The minimum height (elevation) within the tile. maximumHeightNumber 0.0optional The maximum height (elevation) within the tile. ellipsoidEllipsoid Ellipsoid.WGS84optional The ellipsoid on which the rectangle is defined. resultOrientedBoundingBox optional The object onto which to store the result. Returns:
The modified result parameter or a new OrientedBoundingBox instance if none was provided.Throws:
-
DeveloperError : rectangle.width must be between 0 and pi.
-
DeveloperError : rectangle.height must be between 0 and pi.
-
DeveloperError : ellipsoid must be an ellipsoid of revolution (
radii.x == radii.y)
-
-
staticCesium.OrientedBoundingBox.intersectPlane(box, plane) → Intersect
-
Determines which side of a plane the oriented bounding box is located.
Name Type Description boxOrientedBoundingBox The oriented bounding box to test. planePlane The plane to test against. Returns:
Intersect.INSIDEif the entire box is on the side of the plane the normal is pointing,Intersect.OUTSIDEif the entire box is on the opposite side, andIntersect.INTERSECTINGif the box intersects the plane. -
Determines whether or not a bounding box is hidden from view by the occluder.
Name Type Description boxOrientedBoundingBox The bounding box surrounding the occludee object. occluderOccluder The occluder. Returns:
trueif the box is not visible; otherwisefalse. -
clone(result) → OrientedBoundingBox
-
Duplicates this OrientedBoundingBox instance.
Name Type Description resultOrientedBoundingBox optional The object onto which to store the result. Returns:
The modified result parameter or a new OrientedBoundingBox instance if one was not provided. -
computePlaneDistances(position, direction, result) → 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.Name Type Description positionCartesian3 The position to calculate the distance from. directionCartesian3 The direction from position. resultInterval optional A Interval to store the nearest and farthest distances. Returns:
The nearest and farthest distances on the bounding box from position in direction. -
Computes the estimated distance squared from the closest point on a bounding box to a point.
Name Type Description cartesianCartesian3 The point Returns:
The estimated distance squared from the bounding sphere to the point.Example:
// Sort bounding boxes from back to front boxes.sort(function(a, b) { return b.distanceSquaredTo(camera.positionWC) - a.distanceSquaredTo(camera.positionWC); }); -
Compares this OrientedBoundingBox against the provided OrientedBoundingBox componentwise and returns
trueif they are equal,falseotherwise.Name Type Description rightOrientedBoundingBox optional The right hand side OrientedBoundingBox. Returns:
trueif they are equal,falseotherwise. -
intersectPlane(plane) → Intersect
-
Determines which side of a plane the oriented bounding box is located.
Name Type Description planePlane The plane to test against. Returns:
Intersect.INSIDEif the entire box is on the side of the plane the normal is pointing,Intersect.OUTSIDEif the entire box is on the opposite side, andIntersect.INTERSECTINGif the box intersects the plane. -
Determines whether or not a bounding box is hidden from view by the occluder.
Name Type Description occluderOccluder The occluder. Returns:
trueif the sphere is not visible; otherwisefalse.
