创建 OrientedBoundingBox 的实例。某个对象的 OrientedBoundingBox 是一个封闭的凸长方体。它可以提供比 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.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
center |
Cartesian3 |
Cartesian3.ZERO
|
可选 optional 盒子的中心。 The center of the box. |
halfAxes |
Matrix3 |
Matrix3.ZERO
|
可选 optional 边界框的三个正交半轴。等效地,变换矩阵,用于旋转和缩放以原点为中心的 2x2x2 立方体。 The three orthogonal half-axes of the bounding box. Equivalently, the transformation matrix, to rotate and scale a 2x2x2 cube centered at the origin. |
示例: 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
用于将对象打包到数组中的元素数量。 The number of elements used to pack the object into an array.
盒子的中心。 The center of the box.
-
默认值: Default Value:
Cartesian3.ZERO
边界框的三个正交半轴。等效地,变换矩阵,用于旋转和缩放以原点为中心的 2x2x2 立方体。 The three orthogonal half-axes of the bounding box. Equivalently, the transformation matrix, to rotate and scale a 2x2x2 cube centered at the origin.
-
默认值: Default Value:
Matrix3.ZERO
方法 Methods
static Cesium.OrientedBoundingBox.clone(box, result) → OrientedBoundingBox
Duplicates a OrientedBoundingBox instance.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
box |
OrientedBoundingBox | 要复制的边界框。 The bounding box to duplicate. |
result |
OrientedBoundingBox | 可选 optional 用于存储结果的对象。 The object onto which to store the result. |
返回: Returns:
修改后的结果参数或新的 OrientedBoundingBox 实例(如果未提供)。 (如果框未定义,则返回未定义) 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>
计算定向边界框的八个角。角点按 (-X、-Y、-Z)、(-X、-Y、+Z)、(-X、+Y、-Z)、(-X、+Y、+Z)、(+X、-Y、-Z)、(+X、-Y、+Z)、(+X、+Y、-Z)、(+X、+Y、+Z) 排序。 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.
如果您想象法线方向有无限多个平面,这将计算距与边界框相交的位置最近和最远平面的最小距离。 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:
计算从边界框上最近的点到点的估计距离的平方。 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:
从定向边界框到点的距离的平方。如果点位于框内,则返回 0。 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);
});
比较提供的 OrientedBoundingBox 组件并返回 Compares the provided OrientedBoundingBox componentwise and returns
true 如果它们相等, if they are equal, false otherwise.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
left |
OrientedBoundingBox | 可选 optional 第一个 OrientedBoundingBox。 The first OrientedBoundingBox. |
right |
OrientedBoundingBox | 可选 optional 第二个 OrientedBoundingBox。 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 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
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
positions |
Array.<Cartesian3> |
可选 optional
名单 List of Cartesian3 边界框将包围的点。 points that the bounding box will enclose. |
result |
OrientedBoundingBox | 可选 optional 用于存储结果的对象。 The object onto which to store the result. |
返回: Returns:
修改后的结果参数或新的 OrientedBoundingBox 实例(如果未提供)。 The modified result parameter or a new OrientedBoundingBox instance if one was not provided.
示例: 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 来限制 Computes an OrientedBoundingBox that bounds a
Rectangle 在一个表面上 on the surface of an Ellipsoid。无法保证边界框的方向。 . There are no guarantees about the orientation of the bounding box.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
rectangle |
Rectangle | 椭球体表面上的制图矩形。 The cartographic rectangle on the surface of the ellipsoid. | |
minimumHeight |
number |
0.0
|
可选 optional 图块内的最小高度(标高)。 The minimum height (elevation) within the tile. |
maximumHeight |
number |
0.0
|
可选 optional 图块内的最大高度(标高)。 The maximum height (elevation) within the tile. |
ellipsoid |
Ellipsoid |
Ellipsoid.default
|
可选 optional 定义矩形的椭球体。 The ellipsoid on which the rectangle is defined. |
result |
OrientedBoundingBox | 可选 optional 用于存储结果的对象。 The object onto which to store the result. |
返回: Returns:
修改后的结果参数或新的 OrientedBoundingBox 实例(如果未提供)。 The modified result parameter or a new OrientedBoundingBox instance if none was provided.
抛出: Throws:
-
DeveloperError :矩形宽度必须介于 0 到 2 * pi 之间。 : rectangle.width must be between 0 and 2 * pi.
-
DeveloperError :矩形的高度必须介于 0 和 pi 之间。 : rectangle.height must be between 0 and pi.
static Cesium.OrientedBoundingBox.fromTransformation(transformation, result) → OrientedBoundingBox
计算限制仿射变换的 OrientedBoundingBox。 Computes an OrientedBoundingBox that bounds an affine transformation.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
transformation |
Matrix4 | 仿射变换。 The affine transformation. |
result |
OrientedBoundingBox | 可选 optional 用于存储结果的对象。 The object onto which to store the result. |
返回: Returns:
修改后的结果参数或新的 OrientedBoundingBox 实例(如果未提供)。 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.
| 名称 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.
确定边界框是否被遮挡器隐藏在视图之外。 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.
将提供的实例存储到提供的数组中。 Stores the provided instance into the provided array.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
value |
OrientedBoundingBox | 包装的价值。 The value to pack. | |
array |
Array.<number> | 要打包到的数组。 The array to pack into. | |
startingIndex |
number |
0
|
可选 optional 开始打包元素的数组索引。 The index into the array at which to start packing the elements. |
返回: Returns:
被打包成的数组 The array that was packed into
static Cesium.OrientedBoundingBox.unpack(array, startingIndex, result) → OrientedBoundingBox
从打包数组中检索实例。 Retrieves an instance from a packed array.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
array |
Array.<number> | 打包的数组。 The packed array. | |
startingIndex |
number |
0
|
可选 optional 要解包的元素的起始索引。 The starting index of the element to be unpacked. |
result |
OrientedBoundingBox | 可选 optional 用于存储结果的对象。 The object into which to store the result. |
返回: Returns:
修改后的结果参数或新的 OrientedBoundingBox 实例(如果未提供)。 The modified result parameter or a new OrientedBoundingBox instance if one was not provided.
clone(result) → OrientedBoundingBox
复制此 OrientedBoundingBox 实例。 Duplicates this OrientedBoundingBox instance.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
result |
OrientedBoundingBox | 可选 optional 用于存储结果的对象。 The object onto which to store the result. |
返回: Returns:
修改后的结果参数或新的 OrientedBoundingBox 实例(如果未提供)。 The modified result parameter or a new OrientedBoundingBox instance if one was not provided.
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) 排序。 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.
如果您想象法线方向有无限多个平面,这将计算距与边界框相交的位置最近和最远平面的最小距离。 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:
计算从边界框上最近的点到点的估计距离的平方。 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);
});
将此 OrientedBoundingBox 与提供的 OrientedBoundingBox 组件进行比较并返回 Compares this OrientedBoundingBox against the provided OrientedBoundingBox componentwise and returns
true 如果它们相等, if they are equal, false otherwise.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
right |
OrientedBoundingBox | 可选 optional 右侧 OrientedBoundingBox。 The right hand side OrientedBoundingBox. |
返回: Returns:
true 如果它们相等, if they are equal, false otherwise.
intersectPlane(plane) → Intersect
确定定向边界框位于平面的哪一侧。 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.
确定边界框是否被遮挡器隐藏在视图之外。 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.
