OrientedBoundingBox

new Cesium.OrientedBoundingBox(center, halfAxes)

创建 OrientedBoundingBox 的实例。 某个对象的定向边界框是一个封闭的凸长方体。在许多情况下,它比 BoundingSphereAxisAlignedBoundingBox 能提供更紧密的边界体积。
Name Type Default Description
center Cartesian3 Cartesian3.ZERO optional 边界框的中心。
halfAxes Matrix3 Matrix3.ZERO optional 边界框的三个正交半轴。 等效于用于旋转和缩放以原点为中心的 2x2x2 立方体的变换矩阵。
Example:
// 使用变换矩阵、边界框的平移位置和缩放创建 OrientedBoundingBox。
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);
See:

Members

static Cesium.OrientedBoundingBox.packedLength : number

用于将对象打包到数组中的元素数量。
边界框的中心。
Default Value: Cartesian3.ZERO
边界框的三个正交半轴。等效于用于旋转和缩放以原点为中心的 2x2x2 立方体的变换矩阵。
Default Value: Matrix3.ZERO

Methods

static Cesium.OrientedBoundingBox.clone(box, result)OrientedBoundingBox

复制OrientedBoundingBox实例。
Name Type Description
box OrientedBoundingBox 要复制的边界框。
result OrientedBoundingBox optional 存储结果的对象。
Returns:
修改后的结果参数,如果未提供则返回新的OrientedBoundingBox实例。(如果box未定义则返回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).
Name Type Description
box OrientedBoundingBox The oriented bounding box.
result Array.<Cartesian3> optional An array of eight Cartesian3 instances onto which to store the corners.
Returns:
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.
Name Type 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.
Returns:
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.
Name Type Description
box OrientedBoundingBox The oriented bounding box.
result Matrix4 The object onto which to store the result.
Returns:
The modified result parameter or a new Matrix4 instance if none was provided.

static Cesium.OrientedBoundingBox.distanceSquaredTo(box, cartesian)number

Computes the estimated distance squared from the closest point on a bounding box to a point.
Name Type Description
box OrientedBoundingBox The box.
cartesian Cartesian3 The point
Returns:
The distance squared from the oriented bounding box to the point. Returns 0 if the point is inside the box.
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 Cesium.OrientedBoundingBox.equals(left, right)boolean

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

static Cesium.OrientedBoundingBox.fromPoints(positions, result)OrientedBoundingBox

计算给定位置的 OrientedBoundingBox 实例。 这是 Stefan Gottschalk 的《使用定向边界框的碰撞查询》解决方案(博士论文)的实现。 参考:http://gamma.cs.unc.edu/users/gottschalk/main.pdf
Name Type Description
positions Array.<Cartesian3> optional 边界框将包围的 Cartesian3 点列表。
result OrientedBoundingBox optional 存储结果的对象。
Returns:
修改后的结果参数,如果未提供则返回新的 OrientedBoundingBox 实例。
Example:
// 计算包围两个点的定向边界框。
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

计算包围Ellipsoid表面Rectangle的OrientedBoundingBox。 不保证边界框的方向。
Name Type Default Description
rectangle Rectangle 椭球表面上的制图矩形。
minimumHeight number 0.0 optional 瓦片内的最小高度(海拔)。
maximumHeight number 0.0 optional 瓦片内的最大高度(海拔)。
ellipsoid Ellipsoid Ellipsoid.default optional 定义矩形的椭球。
result OrientedBoundingBox optional 存储结果的对象。
Returns:
修改后的结果参数,如果未提供则返回新的OrientedBoundingBox实例。
Throws:

static Cesium.OrientedBoundingBox.fromTransformation(transformation, result)OrientedBoundingBox

计算包围仿射变换的OrientedBoundingBox。
Name Type Description
transformation Matrix4 仿射变换。
result OrientedBoundingBox optional 存储结果的对象。
Returns:
修改后的结果参数,如果未提供则返回新的OrientedBoundingBox实例。

static Cesium.OrientedBoundingBox.intersectPlane(box, plane)Intersect

Determines which side of a plane the oriented bounding box is located.
Name Type Description
box OrientedBoundingBox The oriented bounding box to test.
plane Plane The plane to test against.
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.

static Cesium.OrientedBoundingBox.isOccluded(box, occluder)boolean

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

static Cesium.OrientedBoundingBox.pack(value, array, startingIndex)Array.<number>

将提供的实例存储到提供的数组中。
Name Type Default Description
value OrientedBoundingBox 要打包的值。
array Array.<number> 要打包到的数组。
startingIndex number 0 optional 数组中开始打包元素的索引。
Returns:
被打包到的数组

static Cesium.OrientedBoundingBox.unpack(array, startingIndex, result)OrientedBoundingBox

从打包的数组中检索实例。
Name Type Default Description
array Array.<number> 打包的数组。
startingIndex number 0 optional 要解包的元素起始索引。
result OrientedBoundingBox optional 存储结果的对象。
Returns:
修改后的结果参数,如果未提供则返回新的 OrientedBoundingBox 实例。
Duplicates this OrientedBoundingBox instance.
Name Type Description
result OrientedBoundingBox optional The object onto which to store the result.
Returns:
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).
Name Type Description
result Array.<Cartesian3> optional An array of eight Cartesian3 instances onto which to store the corners.
Returns:
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.
Name Type 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.
Returns:
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.
Name Type Description
result Matrix4 The object onto which to store the result.
Returns:
The modified result parameter or a new Matrix4 instance if none was provided.

distanceSquaredTo(cartesian)number

Computes the estimated distance squared from the closest point on a bounding box to a point.
Name Type Description
cartesian Cartesian3 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 true if they are equal, false otherwise.
Name Type Description
right OrientedBoundingBox optional The right hand side OrientedBoundingBox.
Returns:
true if they are equal, false otherwise.
Determines which side of a plane the oriented bounding box is located.
Name Type Description
plane Plane The plane to test against.
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.

isOccluded(occluder)boolean

Determines whether or not a bounding box is hidden from view by the occluder.
Name Type Description
occluder Occluder The occluder.
Returns:
true if the sphere is not visible; otherwise false.
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.