OrientedBoundingBox

new Cesium.OrientedBoundingBox(center, halfAxes)

创建一个OrientedBoundingBox实例。 在许多情况下,它可以提供比BoundingSphereAxisAlignedBoundingBox更紧密的(tighter)包围盒。 一个物体的OrientedBoundingBox是一个封闭的、凸的长方体。
Name Type Default Description
center Cartesian3 Cartesian3.ZERO optional 盒子的中心。
halfAxes Matrix3 Matrix3.ZERO optional 包围盒的三个正交半轴。 同样地,变换矩阵,旋转和缩放一个以原点为中心的0x0x0立方体。
Example:
// 创建一个OrientedBoundingBox使用转换矩阵,Box将被平移和缩放到一个位置。
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

staticCesium.OrientedBoundingBox.packedLength : Number

用于将对象打包成数组的元素数。
盒子的中心。
Default Value: Cartesian3.ZERO
变换矩阵,将Box旋转到正确的位置
Default Value: Matrix3.ZERO

Methods

staticCesium.OrientedBoundingBox.clone(box, result)OrientedBoundingBox

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

staticCesium.OrientedBoundingBox.computePlaneDistances(box, position, direction, result)Interval

由向量计算的从包围盒中心到投影到方向上的位置的距离。
如果你想象有无限个方向为法线的平面,这就计算出与包围盒相交的最近和最远的平面之间的最小距离。
Name Type Description
box OrientedBoundingBox 计算距离的终止位置的包围盒。
position Cartesian3 计算距离的起始位置。
direction Cartesian3 位置的方向。
result Interval optional 存储最近和最远距离的间隔。
Returns:
包围盒距方向位置的最近距离和最远距离。

staticCesium.OrientedBoundingBox.distanceSquaredTo(box, cartesian)Number

计算从包围盒上的最近点到某点的估算距离的平方。
Name Type Description
box OrientedBoundingBox 包围盒。
cartesian Cartesian3 点。
Returns:
从包围球到该点的估算距离的平方。
Example:
// 将包围盒从后向前排序。
boxes.sort(function(a, b) {
    return Cesium.OrientedBoundingBox.distanceSquaredTo(b, camera.positionWC) - Cesium.OrientedBoundingBox.distanceSquaredTo(a, camera.positionWC);
});

staticCesium.OrientedBoundingBox.equals(left, right)Boolean

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

staticCesium.OrientedBoundingBox.fromPoints(positions, result)OrientedBoundingBox

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

计算一个OrientedBoundingBox,它将Rectangle限定在Ellipsoid的表面上。 不能保证包围盒的朝向。
Name Type Default Description
rectangle Rectangle 椭球面上的地图矩形。
minimumHeight Number 0.0 optional 瓦片内的最小高度(仰角)。
maximumHeight Number 0.0 optional 瓦片内的最大高度(仰角)。
ellipsoid Ellipsoid Ellipsoid.WGS84 optional 定义矩形的椭球面。
result OrientedBoundingBox optional 存储结果的对象。
Returns:
修改后的结果参数或新的 OrientedBoundingBox实例(如果没有提供)。
Throws:

staticCesium.OrientedBoundingBox.intersectPlane(box, plane)Intersect

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

staticCesium.OrientedBoundingBox.isOccluded(box, occluder)Boolean

确定一个包围盒是否被遮光器(occluder)从视图中隐藏。
Name Type Description
box OrientedBoundingBox 包围occludee物体的包围框。
occluder Occluder 遮光器(occluder)。
Returns:
如果盒子不可见,则为true;否则false

staticCesium.OrientedBoundingBox.pack(value, array, startingIndex)Array.<Number>

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

staticCesium.OrientedBoundingBox.unpack(array, startingIndex, result)OrientedBoundingBox

从已包装的数组中检索实例。
Name Type Default Description
array Array.<Number> 包装的数组。
startingIndex Number 0 optional 要解包的元素的起始索引。
result OrientedBoundingBox optional 存储结果的对象。
Returns:
修改后的结果参数或新的 OrientedBoundingBox实例(如果没有提供)。
复制此OrientedBoundingBox实例。
Name Type Description
result OrientedBoundingBox optional 存储结果的对象。
Returns:
修改后的结果参数或新的OrientedBoundingBox实例(如果没有提供)。

computePlaneDistances(position, direction, result)Interval

由向量计算的从包围盒中心到投影到方向上的位置的距离。
如果你想象有无限个方向为法线的平面,这就计算出与包围盒相交的最近和最远的平面之间的最小距离。
Name Type Description
position Cartesian3 计算距离的起始位置。
direction Cartesian3 位置的方向。
result Interval optional 存储最近和最远距离的间隔。
Returns:
包围盒距方向位置的最近距离和最远距离。

distanceSquaredTo(cartesian)Number

计算从包围盒上的最近点到某点的估算距离的平方。
Name Type Description
cartesian Cartesian3 点。
Returns:
从包围球到该点的估算距离的平方。
Example:
// 将包围盒从后向前排序
boxes.sort(function(a, b) {
    return b.distanceSquaredTo(camera.positionWC) - a.distanceSquaredTo(camera.positionWC);
});

equals(right)Boolean

将这个OrientedBoundingBox与提供的OrientedBoundingBox分量进行比较,如果相等,则返回true,否则返回false
Name Type Description
right OrientedBoundingBox optional 要进行比较的OrientedBoundingBox。
Returns:
如果它们相等true,否则false

intersectPlane(plane)Intersect

确定定向包围盒位于平面的哪一侧。
Name Type Description
plane Plane 要测试的平面。
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

确定一个包围盒是否被遮光器(occluder)从视图中隐藏。
Name Type Description
occluder Occluder 遮光器(occluder)。
Returns:
如果球体不可见,则true;否则false