BoundingSphere

具有中心和半径的包围球。

new Cesium.BoundingSphere(center, radius)

Name Type Default Description
center Cartesian3 Cartesian3.ZERO optional 包围球的中心。
radius number 0.0 optional 包围球的半径。
See:

Members

static Cesium.BoundingSphere.packedLength : number

用于将对象打包到数组中的元素数量。
球的中心点。
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

由从包围球中心到 position 的向量在 direction 方向上的投影计算出的距离, 加上/减去包围球的半径。
如果想象有无数个法线方向为 direction 的平面,此方法计算从 position 到与包围球相交的 最近和最远平面的最小距离。
Name Type Description
sphere BoundingSphere 要计算距离的包围球。
position Cartesian3 计算距离的起始位置。
direction Cartesian3 从 position 出发的方向。
result Interval optional 用于存储最近和最远距离的 Interval。
Returns:
从 position 沿 direction 方向到包围球的最近和最远距离。

static Cesium.BoundingSphere.distanceSquaredTo(sphere, cartesian)number

计算从包围球上最近点到某点的估计距离的平方。
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);
});

static Cesium.BoundingSphere.equals(left, right)boolean

逐分量比较提供的 BoundingSphere,如果它们相等则返回 true,否则返回 false
Name Type Description
left BoundingSphere optional 第一个 BoundingSphere。
right BoundingSphere optional 第二个 BoundingSphere。
Returns:
如果 left 和 right 相等则返回 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

计算一个紧密贴合的包围球,以包围 EncodedCartesian3 列表,其中点以 X、Y、Z 顺序 存储在并行扁平数组中。包围球通过运行两种 算法计算:朴素算法和 Ritter 算法。使用两个球中较小的一个来 确保紧密贴合。
Name Type Description
positionsHigh Array.<number> optional 包围球将包围的编码笛卡尔坐标的高位数组。每个点 由数组中的三个元素按 X、Y、Z 顺序组成。
positionsLow Array.<number> optional 包围球将包围的编码笛卡尔坐标的低位数组。每个点 由数组中的三个元素按 X、Y、Z 顺序组成。
result BoundingSphere optional 用于存储结果的对象。
Returns:
修改后的结果参数,如果未提供则为新的 BoundingSphere 实例。
See:

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 包围球将包围的点数组。每个点必须具有 xyz 属性。
result BoundingSphere optional 用于存储结果的对象。
Returns:
修改后的结果参数,如果未提供则为新的 BoundingSphere 实例。
See:

static Cesium.BoundingSphere.fromRectangle2D(rectangle, projection, result)BoundingSphere

从投影到 2D 的矩形计算包围球。
Name Type Default Description
rectangle Rectangle optional 要为其创建包围球的矩形。
projection MapProjection GeographicProjection optional 用于将矩形投影到 2D 的投影。
result BoundingSphere optional 用于存储结果的对象。
Returns:
修改后的结果参数,如果未提供则为新的 BoundingSphere 实例。

static Cesium.BoundingSphere.fromRectangle3D(rectangle, ellipsoid, surfaceHeight, result)BoundingSphere

从 3D 中的矩形计算包围球。该包围球是使用椭球体上包含在矩形内的点子样本 创建的。对于所有类型的椭球体上的所有矩形,它可能并不准确。
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

从投影到 2D 的矩形计算包围球。该包围球考虑了 对象在矩形上的最小和最大高度。
Name Type Default Description
rectangle Rectangle optional 要为其创建包围球的矩形。
projection MapProjection GeographicProjection optional 用于将矩形投影到 2D 的投影。
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> | TypedArray 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

static Cesium.BoundingSphere.isOccluded(sphere, occluder)boolean

确定球体是否被遮挡物遮挡而不可见。
Name Type Description
sphere BoundingSphere 包围被遮挡对象的包围球。
occluder Occluder 遮挡物。
Returns:
如果球体不可见则返回 true;否则返回 false

static Cesium.BoundingSphere.pack(value, array, startingIndex)Array.<number>

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

static Cesium.BoundingSphere.projectTo2D(sphere, projection, result)BoundingSphere

从 3D 世界坐标中的包围球创建 2D 中的包围球。
Name Type Default Description
sphere BoundingSphere 要转换为 2D 的包围球。
projection MapProjection GeographicProjection optional 到 2D 的投影。
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 实例。
复制此 BoundingSphere 实例。
Name Type Description
result BoundingSphere optional 用于存储结果的对象。
Returns:
修改后的结果参数,如果未提供则为新的 BoundingSphere 实例。

computePlaneDistances(position, direction, result)Interval

由从包围球中心到 position 的向量在 direction 方向上的投影计算出的距离, 加上/减去包围球的半径。
如果想象有无数个法线方向为 direction 的平面,此方法计算从 position 到与包围球相交的 最近和最远平面的最小距离。
Name Type Description
position Cartesian3 计算距离的起始位置。
direction Cartesian3 从 position 出发的方向。
result Interval optional 用于存储最近和最远距离的 Interval。
Returns:
从 position 沿 direction 方向到包围球的最近和最远距离。

distanceSquaredTo(cartesian)number

计算从包围球上最近点到某点的估计距离的平方。
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);
});

equals(right)boolean

将此 BoundingSphere 与提供的 BoundingSphere 逐分量比较,如果它们相等则返回 true,否则返回 false
Name Type Description
right BoundingSphere optional 右侧的 BoundingSphere。
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
计算 BoundingSphere 的半径。
Returns:
BoundingSphere 的半径。
需要帮助?获取答案的最快方式是在 Cesium 论坛 上向社区和团队提问。