OrientedBoundingBox

new Cesium.OrientedBoundingBox(center, halfAxes)

创建 OrientedBoundingBox 的实例。 某个对象的 OrientedBoundingBox 是一个闭合的凸面矩形长方体。在许多情况下,它可以提供比 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
边界框的三个正交半轴。等效地, 变换矩阵,旋转和缩放以 起源。
Default Value: Matrix3.ZERO

Methods

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

复制BoundingBox实例。
Name Type Description
box OrientedBoundingBox 要复制的边界框。
result OrientedBoundingBox optional 要在其上存储结果的对象。
Returns:
修改后的结果参数 or a new OrientedBoundingBox instance if none was provided. (Returns undefined if box is 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 存储最近和最远距离的间隔。
Returns:
边界框上距 direction 位置最近的和最远的距离。

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

对提供的 OrientedBoundingBox 组件进行比较,并返回 true,否则为false
Name Type Description
left OrientedBoundingBox optional 第一个 OrientedBoundingBox。
right OrientedBoundingBox optional 第二个 OrientedBoundingBox。
Returns:
true如果左和右相等,否则false

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

计算给定位置的 OrientedBoundingBox 实例。 这是 Stefan Gottschalk 的 Collision Queries using Oriented Bounding Boxes 解决方案(博士论文)的实现。 Reference: 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

计算一个 OrientedBoundingBox,该 BoundingBox 将 Rectangle 限定在 Ellipsoid 的表面上。 无法保证边界框的方向。
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

确定定向边界框位于平面的哪一侧。
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 The 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:
修改后的结果参数 or a new OrientedBoundingBox instance if one was not provided.
复制OrientedBoundingBox实例。
Name Type Description
result OrientedBoundingBox optional 要在其上存储结果的对象。
Returns:
修改后的结果参数 或者一个新的 OrientedBoundingBox 实例(如果未提供)。

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 存储最近和最远距离的间隔。
Returns:
边界框上距 direction 位置最近的和最远的距离。

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);
});
将此 OrientedBoundingBox 与提供的 OrientedBoundingBox 组件进行比较,并返回 true,否则为false
Name Type Description
right OrientedBoundingBox optional 右边 OrientedBoundingBox.
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
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.