Creates an instance of an OrientedBoundingBox.
An OrientedBoundingBox of some object is a closed and convex rectangular cuboid. It can provide a tighter bounding volume than
BoundingSphere
or AxisAlignedBoundingBox
in many cases.
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
center |
Cartesian3 |
Cartesian3.ZERO
|
可选 The center of the box. |
halfAxes |
Matrix3 |
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. |
使用示例:
// Create an OrientedBoundingBox using a transformation matrix, a position where the box will be translated, and a scale.
const center = new Cesium.Cartesian3(1.0, 0.0, 0.0);
const halfAxes = Cesium.Matrix3.fromScale(new Cesium.Cartesian3(1.0, 3.0, 2.0), new Cesium.Matrix3());
const obb = new Cesium.OrientedBoundingBox(center, halfAxes);
参考:
成员(属性)
The number of elements used to pack the object into an array.
The center of the box.
-
默认值:
Cartesian3.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.
-
默认值:
Matrix3.ZERO
方法
static Cesium.OrientedBoundingBox.clone(box, result) → OrientedBoundingBox
Duplicates a OrientedBoundingBox instance.
参数名称 | 类型 | 描述信息 |
---|---|---|
box |
OrientedBoundingBox | The bounding box to duplicate. |
result |
OrientedBoundingBox | 可选 The object onto which to store the result. |
返回值:
The modified result parameter or a new OrientedBoundingBox instance if none was provided. (Returns undefined if box is undefined)
static Cesium.OrientedBoundingBox.computeCorners(box, result) → Array.<Cartesian3>
Computes the eight corners of an oriented bounding box. The corners are ordered by (-X, -Y, -Z), (-X, -Y, +Z), (-X, +Y, -Z), (-X, +Y, +Z), (+X, -Y, -Z), (+X, -Y, +Z), (+X, +Y, -Z), (+X, +Y, +Z).
参数名称 | 类型 | 描述信息 |
---|---|---|
box |
OrientedBoundingBox | The oriented bounding box. |
result |
Array.<Cartesian3> |
可选
An array of eight Cartesian3 instances onto which to store the corners. |
返回值:
The modified result parameter or a new array if none was provided.
static Cesium.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.
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.
参数名称 | 类型 | 描述信息 |
---|---|---|
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 | 可选 A Interval to store the nearest and farthest distances. |
返回值:
The nearest and farthest distances on the bounding box from position in direction.
static Cesium.OrientedBoundingBox.computeTransformation(box, result) → Matrix4
Computes a transformation matrix from an oriented bounding box.
参数名称 | 类型 | 描述信息 |
---|---|---|
box |
OrientedBoundingBox | The oriented bounding box. |
result |
Matrix4 | The object onto which to store the result. |
返回值:
The modified result parameter or a new
Matrix4
instance if none was provided.
Computes the estimated distance squared from the closest point on a bounding box to a point.
参数名称 | 类型 | 描述信息 |
---|---|---|
box |
OrientedBoundingBox | The box. |
cartesian |
Cartesian3 | The point |
返回值:
The distance squared from the oriented bounding box to the point. Returns 0 if the point is inside the box.
使用示例:
// 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
true
if they are equal, false
otherwise.
参数名称 | 类型 | 描述信息 |
---|---|---|
left |
OrientedBoundingBox | The first OrientedBoundingBox. |
right |
OrientedBoundingBox | The second OrientedBoundingBox. |
返回值:
true
if left and right are equal, false
otherwise.
static Cesium.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
参数名称 | 类型 | 描述信息 |
---|---|---|
positions |
Array.<Cartesian3> |
可选
List of Cartesian3 points that the bounding box will enclose. |
result |
OrientedBoundingBox | 可选 The object onto which to store the result. |
返回值:
The modified result parameter or a new OrientedBoundingBox instance if one was not provided.
使用示例:
// Compute an object oriented bounding box enclosing two points.
const box = Cesium.OrientedBoundingBox.fromPoints([new Cesium.Cartesian3(2, 0, 0), new Cesium.Cartesian3(-2, 0, 0)]);
static Cesium.OrientedBoundingBox.fromRectangle(rectangle, minimumHeight, maximumHeight, ellipsoid, result) → 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.
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
rectangle |
Rectangle | The cartographic rectangle on the surface of the ellipsoid. | |
minimumHeight |
number |
0.0
|
可选 The minimum height (elevation) within the tile. |
maximumHeight |
number |
0.0
|
可选 The maximum height (elevation) within the tile. |
ellipsoid |
Ellipsoid |
Ellipsoid.default
|
可选 The ellipsoid on which the rectangle is defined. |
result |
OrientedBoundingBox | 可选 The object onto which to store the result. |
返回值:
The modified result parameter or a new OrientedBoundingBox instance if none was provided.
Throws:
-
DeveloperError : rectangle.width must be between 0 and 2 * pi.
-
DeveloperError : rectangle.height must be between 0 and pi.
-
DeveloperError : ellipsoid must be an ellipsoid of revolution (
radii.x == radii.y
)
static Cesium.OrientedBoundingBox.fromTransformation(transformation, result) → OrientedBoundingBox
Computes an OrientedBoundingBox that bounds an affine transformation.
参数名称 | 类型 | 描述信息 |
---|---|---|
transformation |
Matrix4 | The affine transformation. |
result |
OrientedBoundingBox | 可选 The object onto which to store the result. |
返回值:
The modified result parameter or a new OrientedBoundingBox instance if none was provided.
static Cesium.OrientedBoundingBox.intersectPlane(box, plane) → Intersect
Determines which side of a plane the oriented bounding box is located.
参数名称 | 类型 | 描述信息 |
---|---|---|
box |
OrientedBoundingBox | The oriented bounding box to test. |
plane |
Plane | The plane to test against. |
返回值:
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.
Determines whether or not a bounding box is hidden from view by the occluder.
参数名称 | 类型 | 描述信息 |
---|---|---|
box |
OrientedBoundingBox | The bounding box surrounding the occludee object. |
occluder |
Occluder | The occluder. |
返回值:
true
if the box is not visible; otherwise false
.
Stores the provided instance into the provided array.
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
value |
OrientedBoundingBox | The value to pack. | |
array |
Array.<number> | The array to pack into. | |
startingIndex |
number |
0
|
可选 The index into the array at which to start packing the elements. |
返回值:
The array that was packed into
static Cesium.OrientedBoundingBox.unpack(array, startingIndex, result) → OrientedBoundingBox
Retrieves an instance from a packed array.
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
array |
Array.<number> | The packed array. | |
startingIndex |
number |
0
|
可选 The starting index of the element to be unpacked. |
result |
OrientedBoundingBox | 可选 The object into which to store the result. |
返回值:
The modified result parameter or a new OrientedBoundingBox instance if one was not provided.
clone(result) → OrientedBoundingBox
Duplicates this OrientedBoundingBox instance.
参数名称 | 类型 | 描述信息 |
---|---|---|
result |
OrientedBoundingBox | 可选 The object onto which to store the result. |
返回值:
The modified result parameter or a new OrientedBoundingBox instance if one was not provided.
computeCorners(result) → Array.<Cartesian3>
Computes the eight corners of an oriented bounding box. The corners are ordered by (-X, -Y, -Z), (-X, -Y, +Z), (-X, +Y, -Z), (-X, +Y, +Z), (+X, -Y, -Z), (+X, -Y, +Z), (+X, +Y, -Z), (+X, +Y, +Z).
参数名称 | 类型 | 描述信息 |
---|---|---|
result |
Array.<Cartesian3> |
可选
An array of eight Cartesian3 instances onto which to store the corners. |
返回值:
The modified result parameter or a new array if none was 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.
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.
参数名称 | 类型 | 描述信息 |
---|---|---|
position |
Cartesian3 | The position to calculate the distance from. |
direction |
Cartesian3 | The direction from position. |
result |
Interval | 可选 A Interval to store the nearest and farthest distances. |
返回值:
The nearest and farthest distances on the bounding box from position in direction.
computeTransformation(result) → Matrix4
Computes a transformation matrix from an oriented bounding box.
参数名称 | 类型 | 描述信息 |
---|---|---|
result |
Matrix4 | The object onto which to store the result. |
返回值:
The modified result parameter or a new
Matrix4
instance if none was provided.
Computes the estimated distance squared from the closest point on a bounding box to a point.
参数名称 | 类型 | 描述信息 |
---|---|---|
cartesian |
Cartesian3 | The point |
返回值:
The estimated distance squared from the bounding sphere to the point.
使用示例:
// 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
true
if they are equal, false
otherwise.
参数名称 | 类型 | 描述信息 |
---|---|---|
right |
OrientedBoundingBox | 可选 The right hand side OrientedBoundingBox. |
返回值:
true
if they are equal, false
otherwise.
intersectPlane(plane) → Intersect
Determines which side of a plane the oriented bounding box is located.
参数名称 | 类型 | 描述信息 |
---|---|---|
plane |
Plane | The plane to test against. |
返回值:
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.
Determines whether or not a bounding box is hidden from view by the occluder.
参数名称 | 类型 | 描述信息 |
---|---|---|
occluder |
Occluder | The occluder. |
返回值:
true
if the sphere is not visible; otherwise false
.