OrientedBoundingBox

new Cesium.OrientedBoundingBox(center, halfAxes)

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

Members

static Cesium.OrientedBoundingBox.packedLength : number

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

Methods

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

复制一个定向包围盒实例。
Name Type Description
box OrientedBoundingBox 要复制的包围盒。
result OrientedBoundingBox optional 存储结果的对象。
Returns:
修改后的结果参数,如果未提供则返回一个新的 OrientedBoundingBox 实例。(如果 box 为未定义,则返回 undefined)

static Cesium.OrientedBoundingBox.computeCorners(box, result)Array.<Cartesian3>

计算定向包围盒的八个顶点。顶点的顺序为 (-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 定向包围盒。
result Array.<Cartesian3> optional 用于存储八个 Cartesian3 实例的数组。
Returns:
修改后的结果参数,如果未提供则返回一个新的数组。

static Cesium.OrientedBoundingBox.computePlaneDistances(box, position, direction, result)Interval

由从包围盒中心到沿方向投影到位置的向量计算的距离。
如果想象无限多个法向方向的平面,这个计算会得到与包围盒相交的位置最近和最远的平面的最小距离。
Name Type Description
box OrientedBoundingBox 要计算距离的包围盒。
position Cartesian3 要计算距离的位置。
direction Cartesian3 从位置指向的方向。
result Interval optional 用于存储最近和最远距离的 Interval。
Returns:
从位置沿方向到包围盒的最近和最远距离。

static Cesium.OrientedBoundingBox.computeTransformation(box, result)Matrix4

从定向包围盒计算变换矩阵。
Name Type Description
box OrientedBoundingBox 定向包围盒。
result Matrix4 存储结果的对象。
Returns:
修改后的结果参数,如果未提供则返回一个新的 Matrix4 实例。

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

计算从包围盒上最近点到某一点的估计平方距离。
Name Type Description
box OrientedBoundingBox 包围盒。
cartesian Cartesian3 点。
Returns:
从定向包围盒到该点的平方距离。如果该点在包围盒内,则返回 0。
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

分别比较提供的定向包围盒,并返回 如果相等则为 true,否则为 false
Name Type Description
left OrientedBoundingBox 第一个定向包围盒。
right OrientedBoundingBox 第二个定向包围盒。
Returns:
如果左右相等,则 true,否则 false

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

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

计算一个定向包围盒,该盒子包围 Ellipsoid 表面上的 Rectangle。 对于包围盒的方向没有任何保证。
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

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

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

确定定向包围盒位于平面的哪一侧。
Name Type Description
box OrientedBoundingBox 要测试的定向包围盒。
plane Plane 要测试的平面。
Returns:
如果整个包围盒在平面法线指向的一侧,则返回 Intersect.INSIDE; 如果整个包围盒在相反的一侧,则返回 Intersect.OUTSIDE; 如果包围盒与平面相交,则返回 Intersect.INTERSECTING

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

确定一个包围盒是否被遮挡器隐藏在视野之外。
Name Type Description
box OrientedBoundingBox 包围被遮挡对象的包围盒。
occluder Occluder 遮挡器。
Returns:
如果包围盒不可见,则返回 true;否则返回 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 实例。
复制此定向包围盒实例。
Name Type Description
result OrientedBoundingBox optional 存储结果的对象。
Returns:
修改后的结果参数,如果未提供则返回一个新的定向包围盒实例。

computeCorners(result)Array.<Cartesian3>

计算定向包围盒的八个角。角的顺序为 (-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 一个包含八个 Cartesian3 实例的数组,用于存储角点。
Returns:
修改后的结果参数,如果没有提供则返回一个新数组。

computePlaneDistances(position, direction, result)Interval

从包围盒中心到沿方向投影的位置计算出的距离。
如果你想象一个无限数量的法向方向的平面,这将计算与包围盒相交的、离位置最近和最远的平面的最小距离。
Name Type Description
position Cartesian3 要计算距离的位置。
direction Cartesian3 从位置出发的方向。
result Interval optional 一个用于存储最近和最远距离的Interval。
Returns:
从位置沿方向到包围盒的最近和最远距离。

computeTransformation(result)Matrix4

从定向包围盒计算变换矩阵。
Name Type Description
result Matrix4 存储结果的对象。
Returns:
修改后的结果参数,如果没有提供则返回一个新的 Matrix4 实例。

distanceSquaredTo(cartesian)number

计算从包围盒上最近点到某一点的估计平方距离。
Name Type Description
cartesian Cartesian3 点。
Returns:
从包围球到该点的估计平方距离。
Example:
// Sort bounding boxes from back to front
boxes.sort(function(a, b) {
    return b.distanceSquaredTo(camera.positionWC) - a.distanceSquaredTo(camera.positionWC);
});
将此定向包围盒与提供的定向包围盒逐项比较,并返回 如果相等则为 true,否则为 false
Name Type Description
right OrientedBoundingBox optional 右侧的定向包围盒。
Returns:
如果相等则为 true,否则为 false
确定定向包围盒位于平面的哪一侧。
Name Type Description
plane Plane 要测试的平面。
Returns:
如果整个包围盒在平面法线指向的一侧,则返回 Intersect.INSIDE; 如果整个包围盒在相反的一侧,则返回 Intersect.OUTSIDE; 如果包围盒与平面相交,则返回 Intersect.INTERSECTING

isOccluded(occluder)boolean

确定一个包围盒是否被遮挡物隐藏。
Name Type Description
occluder Occluder 遮挡物。
Returns:
如果球体不可见则返回 true;否则返回 false
需要帮助?获得答案的最快方法是来自社区和团队 Cesium Forum.