一个具有中心和半径的包围球。
| Name | Type | Default | Description |
|---|---|---|---|
center |
Cartesian3 |
Cartesian3.ZERO
|
optional 包围球的中心。 |
radius |
number |
0.0
|
optional 包围球的半径。 |
Members
用于将对象打包到数组中的元素数量。
球体的中心点。
-
Default Value:
Cartesian3.ZERO
球体的半径。
-
Default Value:
0.0
Methods
static Cesium.BoundingSphere.clone(sphere, result) → BoundingSphere
复制一个 BoundingSphere 实例。
| Name | Type | Description |
|---|---|---|
sphere |
BoundingSphere | 要复制的包围球。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。(如果 sphere 为 undefined,则返回 undefined)
static Cesium.BoundingSphere.computePlaneDistances(sphere, position, direction, result) → Interval
由包围球中心到在方向上投影到位置的向量计算出的距离,加上/减去包围球的半径。
如果想象无限数量的法线方向的平面,这将计算与位置相交的包围球最近和最远平面的最小距离。
如果想象无限数量的法线方向的平面,这将计算与位置相交的包围球最近和最远平面的最小距离。
| Name | Type | Description |
|---|---|---|
sphere |
BoundingSphere | 要计算距离的包围球。 |
position |
Cartesian3 | 要计算距离的起始位置。 |
direction |
Cartesian3 | 从位置出发的方向。 |
result |
Interval | optional 用于存储最近和最远距离的区间。 |
Returns:
从位置沿指定方向到包围球的最近和最远距离。
计算包围球上到指定点的最近点的估计平方距离。
| Name | Type | Description |
|---|---|---|
sphere |
BoundingSphere | 包围球。 |
cartesian |
Cartesian3 | 指定的点。 |
Returns:
从包围球到点的平方距离。如果点在球体内部,则返回 0。
Example:
// Sort bounding spheres from back to front
spheres.sort(function(a, b) {
return Cesium.BoundingSphere.distanceSquaredTo(b, camera.positionWC) - Cesium.BoundingSphere.distanceSquaredTo(a, camera.positionWC);
});
逐个比较提供的 BoundingSphere 并返回
如果相等则为
true,否则为 false
| Name | Type | Description |
|---|---|---|
left |
BoundingSphere | optional 第一个 BoundingSphere。 |
right |
BoundingSphere | optional 第二个 BoundingSphere。 |
Returns:
如果两个矩形相等,则返回
true,否则返回 false。
static Cesium.BoundingSphere.expand(sphere, point, result) → BoundingSphere
通过扩大提供的球体来计算一个包围球,以包含指定点。
| Name | Type | Description |
|---|---|---|
sphere |
BoundingSphere | 要扩展的球体。 |
point |
Cartesian3 | 要包围在包围球中的点。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
static Cesium.BoundingSphere.fromBoundingSpheres(boundingSpheres, result) → BoundingSphere
计算一个紧密包围提供的包围球数组的包围球。
| Name | Type | Description |
|---|---|---|
boundingSpheres |
Array.<BoundingSphere> | optional 包围球的数组。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
static Cesium.BoundingSphere.fromCornerPoints(corner, oppositeCorner, result) → BoundingSphere
从轴对齐包围盒的角点计算出包围球。该球体紧密而完全地包围盒子。
| Name | Type | Description |
|---|---|---|
corner |
Cartesian3 | optional 矩形的最小高度。 |
oppositeCorner |
Cartesian3 | optional 矩形的最大高度。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
Example:
// Create a bounding sphere around the unit cube
const sphere = Cesium.BoundingSphere.fromCornerPoints(new Cesium.Cartesian3(-0.5, -0.5, -0.5), new Cesium.Cartesian3(0.5, 0.5, 0.5));
static Cesium.BoundingSphere.fromEllipsoid(ellipsoid, result) → BoundingSphere
创建一个包围椭球体的包围球。
| Name | Type | Description |
|---|---|---|
ellipsoid |
Ellipsoid | 要围绕其创建包围球的椭球体。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
Example:
const boundingSphere = Cesium.BoundingSphere.fromEllipsoid(ellipsoid);
static Cesium.BoundingSphere.fromEncodedCartesianVertices(positionsHigh, positionsLow, result) → BoundingSphere
计算一个紧密包围给定 EncodedCartesian3s 列表的包围球,这些点存储在并行的平坦数组中,顺序为 X, Y, Z。
包围球的计算通过运行两种算法,一种是简单算法,另一种是 Ritter 的算法。
使用两个球体中较小的一个以确保紧密贴合。
| Name | Type | Description |
|---|---|---|
positionsHigh |
Array.<number> | optional 一个包含编码 Cartesian 的高位部分的数组,包围球将包含这些点。每个点由数组中的三个元素组成,顺序为 X, Y, Z。 |
positionsLow |
Array.<number> | optional 一个包含编码 Cartesian 的低位部分的数组,包围球将包含这些点。每个点由数组中的三个元素组成,顺序为 X, Y, Z。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
static Cesium.BoundingSphere.fromOrientedBoundingBox(orientedBoundingBox, result) → BoundingSphere
计算一个紧密包围提供的定向包围盒的包围球。
| Name | Type | Description |
|---|---|---|
orientedBoundingBox |
OrientedBoundingBox | 定向包围盒。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
static Cesium.BoundingSphere.fromPoints(positions, result) → BoundingSphere
计算一个紧密包围给定 3D 直角坐标点列表的包围球。
包围球是通过运行两个算法来计算的,一个是简单算法,另一个是 Ritter 的算法。
使用两个球体中较小的一个以确保紧密贴合。
| Name | Type | Description |
|---|---|---|
positions |
Array.<Cartesian3> |
optional
一个包含要被包围的点的数组。每个点必须具有 x、y 和 z 属性。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
static Cesium.BoundingSphere.fromRectangle2D(rectangle, projection, result) → BoundingSphere
从投影到二维的矩形计算出包围球。
| Name | Type | Default | Description |
|---|---|---|---|
rectangle |
Rectangle | optional 要围绕其创建包围球的矩形。 | |
projection |
object |
GeographicProjection
|
optional 用于将矩形投影到二维的投影。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
static Cesium.BoundingSphere.fromRectangle3D(rectangle, ellipsoid, surfaceHeight, result) → BoundingSphere
从三维矩形计算出包围球。包围球是使用矩形上椭球体的点的子样本创建的。
对于所有类型的椭球体,可能并不适用于所有矩形。
| Name | Type | Default | Description |
|---|---|---|---|
rectangle |
Rectangle | optional 用于创建包围球的有效矩形。 | |
ellipsoid |
Ellipsoid |
Ellipsoid.default
|
optional 用于确定矩形位置的椭球体。 |
surfaceHeight |
number |
0.0
|
optional 椭球体表面之上的高度。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
static Cesium.BoundingSphere.fromRectangleWithHeights2D(rectangle, projection, minimumHeight, maximumHeight, result) → BoundingSphere
从投影到二维的矩形计算出包围球。包围球考虑了矩形上物体的最小和最大高度。
| Name | Type | Default | Description |
|---|---|---|---|
rectangle |
Rectangle | optional 要围绕其创建包围球的矩形。 | |
projection |
object |
GeographicProjection
|
optional 用于将矩形投影到二维的投影。 |
minimumHeight |
number |
0.0
|
optional 矩形上的最小高度。 |
maximumHeight |
number |
0.0
|
optional 矩形上的最大高度。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
static Cesium.BoundingSphere.fromTransformation(transformation, result) → BoundingSphere
计算一个紧密包围提供的仿射变换的包围球。
| Name | Type | Description |
|---|---|---|
transformation |
Matrix4 | 该仿射变换。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
static Cesium.BoundingSphere.fromVertices(positions, center, stride, result) → BoundingSphere
计算一个紧密包围给定 3D 点列表的包围球,这些点存储在一个平坦的数组中,顺序为 X, Y, Z。
包围球的计算通过运行两种算法,一种是简单算法,另一种是 Ritter 的算法。
使用两个球体中较小的一个以确保紧密贴合。
| Name | Type | Default | Description |
|---|---|---|---|
positions |
Array.<number> | optional 一个包含要被包围的点的数组。每个点由数组中的三个元素组成,顺序为 X, Y, Z。 | |
center |
Cartesian3 |
Cartesian3.ZERO
|
optional 点的位置相对于的基准位置,不必是坐标系的原点。 这在点将用于相对于中心 (RTC) 渲染时非常有用。 |
stride |
number |
3
|
optional 每个顶点的数组元素数量。必须至少为 3,但可以更高。 无论此参数的值如何,第一个位置的 X 坐标位于数组索引 0,Y 坐标位于数组索引 1, Z 坐标位于数组索引 2。当 stride 为 3 时,下一个位置的 X 坐标则从数组索引 3 开始。 如果 stride 为 5,则会跳过两个数组元素,下一个位置从数组索引 5 开始。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
Example:
// Compute the bounding sphere from 3 positions, each specified relative to a center.
// In addition to the X, Y, and Z coordinates, the points array contains two additional
// elements per point which are ignored for the purpose of computing the bounding sphere.
const center = new Cesium.Cartesian3(1.0, 2.0, 3.0);
const points = [1.0, 2.0, 3.0, 0.1, 0.2,
4.0, 5.0, 6.0, 0.1, 0.2,
7.0, 8.0, 9.0, 0.1, 0.2];
const sphere = Cesium.BoundingSphere.fromVertices(points, center, 5);
See:
static Cesium.BoundingSphere.intersectPlane(sphere, plane) → Intersect
确定一个球体位于平面的哪一侧。
| Name | Type | Description |
|---|---|---|
sphere |
BoundingSphere | 要测试的包围球。 |
plane |
Plane | 要测试的平面。 |
Returns:
如果整个球体位于平面法线指向的一侧,则返回
Intersect.INSIDE;
如果整个球体位于相反的一侧,则返回 Intersect.OUTSIDE;
如果球体与平面相交,则返回 Intersect.INTERSECTING。
判断一个球体是否被遮挡物遮挡而不可见。
| Name | Type | Description |
|---|---|---|
sphere |
BoundingSphere | 包围被遮挡对象的包围球。 |
occluder |
Occluder | 遮挡物。 |
Returns:
如果球体不可见则返回
true;否则返回 false。
将提供的实例存储到提供的数组中.
| Name | Type | Default | Description |
|---|---|---|---|
value |
BoundingSphere | 要打包的值. | |
array |
Array.<number> | 要打包到的数组. | |
startingIndex |
number |
0
|
optional 开始打包元素的数组索引. |
Returns:
被打包成的数组
static Cesium.BoundingSphere.projectTo2D(sphere, projection, result) → BoundingSphere
从三维世界坐标中的包围球创建一个二维包围球。
| Name | Type | Default | Description |
|---|---|---|---|
sphere |
BoundingSphere | 要转换为二维的包围球。 | |
projection |
object |
GeographicProjection
|
optional 用于投影到二维的投影。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
static Cesium.BoundingSphere.transform(sphere, transform, result) → BoundingSphere
对包围球应用一个 4x4 仿射变换矩阵。
| Name | Type | Description |
|---|---|---|
sphere |
BoundingSphere | 要应用变换的包围球。 |
transform |
Matrix4 | 要应用于包围球的变换矩阵。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
static Cesium.BoundingSphere.transformWithoutScale(sphere, transform, result) → BoundingSphere
对包围球应用一个 4x4 仿射变换矩阵,该变换不涉及缩放。
变换矩阵未验证是否具有统一的 1 的缩放。
此方法比使用
BoundingSphere.transform 计算一般的包围球变换要快。
| Name | Type | Description |
|---|---|---|
sphere |
BoundingSphere | 要应用变换的包围球。 |
transform |
Matrix4 | 要应用于包围球的变换矩阵。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
Example:
const modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid);
const boundingSphere = new Cesium.BoundingSphere();
const newBoundingSphere = Cesium.BoundingSphere.transformWithoutScale(boundingSphere, modelMatrix);
static Cesium.BoundingSphere.union(left, right, result) → BoundingSphere
计算一个包围球,包含左侧和右侧的包围球。
| Name | Type | Description |
|---|---|---|
left |
BoundingSphere | 要包围在包围球中的左侧球体。 |
right |
BoundingSphere | 要包围在包围球中的右侧球体。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
static Cesium.BoundingSphere.unpack(array, startingIndex, result) → BoundingSphere
从打包数组中检索实例。
| Name | Type | Default | Description |
|---|---|---|---|
array |
Array.<number> | 压缩数组。 | |
startingIndex |
number |
0
|
optional 需要解包的元素的起始索引。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
clone(result) → BoundingSphere
复制此 BoundingSphere 实例。
| Name | Type | Description |
|---|---|---|
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回一个新的 BoundingSphere 实例。
computePlaneDistances(position, direction, result) → Interval
由包围球中心到在方向上投影到指定位置的向量计算出的距离,加上/减去包围球的半径。
如果想象无数个法线方向的平面,这将计算与指定位置相交的包围球最近和最远平面的最小距离。
如果想象无数个法线方向的平面,这将计算与指定位置相交的包围球最近和最远平面的最小距离。
| Name | Type | Description |
|---|---|---|
position |
Cartesian3 | 要计算距离的起始位置。 |
direction |
Cartesian3 | 从指定位置的方向。 |
result |
Interval | optional 一个区间用于存储最近和最远的距离。 |
Returns:
从指定位置沿指定方向到包围球的最近和最远距离。
计算从包围球上最近点到指定点的估计平方距离。
| Name | Type | Description |
|---|---|---|
cartesian |
Cartesian3 | 指定的点。 |
Returns:
从包围球到该点的估计平方距离。
Example:
// Sort bounding spheres from back to front
spheres.sort(function(a, b) {
return b.distanceSquaredTo(camera.positionWC) - a.distanceSquaredTo(camera.positionWC);
});
将此 BoundingSphere 与提供的 BoundingSphere 逐个比较,并返回
如果相等则为
true,否则为 false
| Name | Type | Description |
|---|---|---|
right |
BoundingSphere | optional 右侧的 BoundingSphere。 |
Returns:
如果两个矩形相等,则返回
true,否则返回 false。
intersectPlane(plane) → Intersect
确定一个球体位于平面的哪一侧。
| Name | Type | Description |
|---|---|---|
plane |
Plane | 要测试的平面。 |
Returns:
如果整个球体位于平面法线指向的一侧,则返回
Intersect.INSIDE;
如果整个球体位于相反的一侧,则返回 Intersect.OUTSIDE;
如果球体与平面相交,则返回 Intersect.INTERSECTING。
判断一个球体是否被遮挡物遮挡而不可见。
| Name | Type | Description |
|---|---|---|
occluder |
Occluder | 遮挡物。 |
Returns:
如果球体不可见则返回
true;否则返回 false。
计算包围球的半径。
Returns:
包围球的半径。
