BoundingSphere

new Cesium.BoundingSphere(center, radius)

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

Members

staticCesium.BoundingSphere.packedLength : Number

用于将对象打包成数组的元素数。
包围球的中心点。
Default Value: Cartesian3.ZERO

radius : Number

包围球的半径。
Default Value: 0.0

Methods

staticCesium.BoundingSphere.clone(sphere, result)BoundingSphere

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

staticCesium.BoundingSphere.computePlaneDistances(sphere, position, direction, result)Interval

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

staticCesium.BoundingSphere.distanceSquaredTo(sphere, cartesian)Number

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

staticCesium.BoundingSphere.equals(left, right)Boolean

比较提供的BoundingSphere分量,如果它们相等,则返回true,否则返回false
Name Type Description
left BoundingSphere optional 第一个BoundingSphere。
right BoundingSphere optional 第二个BoundingSphere。
Returns:
true 如果两者相等, 否则false

staticCesium.BoundingSphere.expand(sphere, point, result)BoundingSphere

通过扩大所提供的球体以包含所提供的点来计算包围球。
Name Type Description
sphere BoundingSphere 要扩展的球。
point Cartesian3 要在包围球中包围的点。
result BoundingSphere optional 存储结果的对象。
Returns:
修改后的结果参数或新的BoundingSphere实例(如果没有提供)。

staticCesium.BoundingSphere.fromBoundingSpheres(boundingSpheres, result)BoundingSphere

计算所提供的包围球数组包围的紧拟(tight-fitting)包围球。
Name Type Description
boundingSpheres Array.<BoundingSphere> optional 边界球的数组。
result BoundingSphere optional 存储结果的对象。
Returns:
修改后的结果参数或新的BoundingSphere实例(如果没有提供)。

staticCesium.BoundingSphere.fromCornerPoints(corner, oppositeCorner, result)BoundingSphere

从轴对齐的包围框的角点计算包围球。球紧紧地围绕着盒子。
Name Type Description
corner Cartesian3 optional 矩形的最小高度。
oppositeCorner Cartesian3 optional 矩形的最大高度。
result BoundingSphere optional 存储结果的对象。
Returns:
修改后的结果参数或新的BoundingSphere实例(如果没有提供)。
Example:
// 在单位立方体周围创建一个包围球体
var sphere = Cesium.BoundingSphere.fromCornerPoints(new Cesium.Cartesian3(-0.5, -0.5, -0.5), new Cesium.Cartesian3(0.5, 0.5, 0.5));

staticCesium.BoundingSphere.fromEllipsoid(ellipsoid, result)BoundingSphere

创建一个包围椭球的包围球。
Name Type Description
ellipsoid Ellipsoid 用来创建包围球的椭球体。
result BoundingSphere optional 存储结果的对象。
Returns:
修改后的结果参数或新的BoundingSphere实例(如果没有提供)。
Example:
var boundingSphere = Cesium.BoundingSphere.fromEllipsoid(ellipsoid);

staticCesium.BoundingSphere.fromEncodedCartesianVertices(positionsHigh, positionsLow, result)BoundingSphere

计算包围EncodedCartesian3s列表的紧拟(tight-fitting)包围球,其中点按X、Y、Z顺序存储在并行平面(flat)数组中。 包围球的计算有两种算法,一种是朴素(naive)算法,另一种是里特(Ritter's)算法。 两个球中较小的那个用来确保紧密配合(tight fit)。
Name Type Description
positionsHigh Array.<Number> optional 包围球将包围的已编码的笛卡尔坐标的高位数组。每个点由数组中的三个元素按X、Y、Z的顺序组成。
positionsLow Array.<Number> optional 包围球将包围的已编码的笛卡尔坐标的低位数组。每个点由数组中的三个元素按X、Y、Z的顺序组成。
result BoundingSphere optional 存储结果的对象。
Returns:
修改后的结果参数或新的BoundingSphere实例(如果没有提供)。
See:

staticCesium.BoundingSphere.fromOrientedBoundingBox(orientedBoundingBox, result)BoundingSphere

计算所提供的定向包围框包围的紧密配合的(tight-fitting)包围球。
Name Type Description
orientedBoundingBox OrientedBoundingBox 定向包围框。
result BoundingSphere optional 存储结果的对象。
Returns:
修改后的结果参数或新的BoundingSphere实例(如果没有提供)。

staticCesium.BoundingSphere.fromPoints(positions, result)BoundingSphere

计算包围三维笛卡尔坐标点列表的紧身(tight-fitting)包围球。 包围球的计算有两种算法,一种是朴素算法,另一种是里特算法。两个球中较小的那个用来确保紧密配合(tight fit)。
Name Type Description
positions Array.<Cartesian3> optional 包围球将包围的点的数组。每个点必须具有xyz属性。
result BoundingSphere optional 存储结果的对象。
Returns:
修改后的结果参数,或新的BoundingSphere实例(如果没有提供)。
See:

staticCesium.BoundingSphere.fromRectangle2D(rectangle, projection, result)BoundingSphere

从2D中投影的矩形计算包围球。
Name Type Default Description
rectangle Rectangle optional 用来创建包围球的矩形。
projection Object GeographicProjection optional 用于将矩形投影到2D中的投影。
result BoundingSphere optional 存储结果的对象。
Returns:
修改后的结果参数或新的BoundingSphere实例(如果没有提供)。

staticCesium.BoundingSphere.fromRectangle3D(rectangle, ellipsoid, surfaceHeight, result)BoundingSphere

在3D中从矩形中计算包围球。包围球是使用椭球面上和包含在矩形中的点的重采样(subsample)创建的。 它可能对所有类型的椭球上的所有矩形都不准确。
Name Type Default Description
rectangle Rectangle optional 用于创建包围球的有效矩形。
ellipsoid Ellipsoid Ellipsoid.WGS84 optional 用来确定矩形位置的椭球体。
surfaceHeight Number 0.0 optional 在椭球面上的高度。
result BoundingSphere optional 存储结果的对象。
Returns:
修改后的结果参数或新的BoundingSphere实例(如果没有提供)。

staticCesium.BoundingSphere.fromRectangleWithHeights2D(rectangle, projection, minimumHeight, maximumHeight, result)BoundingSphere

从2D中投影的矩形计算包围球。包围球表示对象在矩形上的最小高度和最大高度。
Name Type Default Description
rectangle Rectangle optional 用来创建包围球的矩形。
projection Object GeographicProjection optional 用于将矩形投影到2D中的投影。
minimumHeight Number 0.0 optional 矩形的最小高度。
maximumHeight Number 0.0 optional 矩形的最大高度。
result BoundingSphere optional 存储结果的对象。
Returns:
修改后的结果参数或新的BoundingSphere实例(如果没有提供)。

staticCesium.BoundingSphere.fromVertices(positions, center, stride, result)BoundingSphere

计算包围3D点列表的紧拟(tight-fitting)包围球,其中点按X、Y、Z顺序存储在平面(flat)数组中。 包围球的计算有两种算法,一种是朴素(naive)算法,另一种是里特(Ritter's)算法。 两个球中较小的那个用来确保紧密配合(tight fit)。
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处。 当步幅为3时,下一个位置的X坐标从数组索引3处开始。但是,如果步幅为5,则跳过两个数组元素,下一个位置从数组索引5开始。
result BoundingSphere optional 存储结果的对象。
Returns:
修改后的结果参数或新的BoundingSphere实例(如果没有提供)。
Example:
// 从3个位置计算包围球,每个指定的位置相对于一个中心。
// 除了X、Y和Z坐标外,点数组每个点还包含两个额外的元素,为了计算包围球而忽略它们。
var center = new Cesium.Cartesian3(1.0, 2.0, 3.0);
var 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];
var sphere = Cesium.BoundingSphere.fromVertices(points, center, 5);
See:

staticCesium.BoundingSphere.intersectPlane(sphere, plane)Intersect

确定球面位于平面的哪一侧。
Name Type Description
sphere BoundingSphere 要测试的包围球。
plane Plane 要测试的平面。
Returns:
Intersect.INSIDE 如果整个球面在法向量指向的平面的一侧,Intersect.OUTSIDE 如果整个球面在另一边, 或者Intersect.INTERSECTING 如果球面与平面相交。

staticCesium.BoundingSphere.isOccluded(sphere, occluder)Boolean

确定一个球体是否被限光器(occluder)从视野中隐藏。
Name Type Description
sphere BoundingSphere 围绕occludee对象的包围球。
occluder Occluder 限光器(occluder)。
Returns:
true如果球体不可见;否则false

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

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

staticCesium.BoundingSphere.projectTo2D(sphere, projection, result)BoundingSphere

从三维世界坐标的包围球创建一个二维的包围球。
Name Type Default Description
sphere BoundingSphere 要转换为2D的包围球。
projection Object GeographicProjection optional 2D的投影。
result BoundingSphere optional 存储结果的对象。
Returns:
修改后的结果参数或新的BoundingSphere实例(如果没有提供)。

staticCesium.BoundingSphere.transform(sphere, transform, result)BoundingSphere

对包围球应用4x4仿射变换矩阵。
Name Type Description
sphere BoundingSphere 要将转换应用到的包围球。
transform Matrix4 要应用于包围球的变换矩阵。
result BoundingSphere optional 存储结果的对象。
Returns:
修改后的结果参数或新的BoundingSphere实例(如果没有提供)。

staticCesium.BoundingSphere.transformWithoutScale(sphere, transform, result)BoundingSphere

将4x4仿射变换矩阵应用于没有缩放的包围球。 变换矩阵未被验证为均匀缩放为1。 该方法比使用BoundingSphere.transform计算一般的包围球转换要快。
Name Type Description
sphere BoundingSphere 要将转换应用到的包围球。
transform Matrix4 要应用于包围球的变换矩阵。
result BoundingSphere optional 存储结果的对象。
Returns:
修改后的结果参数或新的BoundingSphere实例(如果没有提供)。
Example:
var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid);
var boundingSphere = new Cesium.BoundingSphere();
var newBoundingSphere = Cesium.BoundingSphere.transformWithoutScale(boundingSphere, modelMatrix);

staticCesium.BoundingSphere.union(left, right, result)BoundingSphere

计算包含左右包围球的包围球。
Name Type Description
left BoundingSphere 包围在一个包围球内的球体。
right BoundingSphere 包围在一个包围球内的球体。
result BoundingSphere optional 存储结果的对象。
Returns:
修改后的结果参数或新的BoundingSphere实例(如果没有提供)。

staticCesium.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

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

distanceSquaredTo(cartesian)Number

计算从包围球上的最近点到某点的估计距离的平方。
Name Type Description
cartesian Cartesian3 点。
Returns:
从包围球到该点的估计距离的平方。
Example:
// 从后面到前面排序包围球
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

intersectPlane(plane)Intersect

确定球体位于平面的哪一侧。
Name Type Description
plane Plane 要测试的平面。
Returns:
Intersect.INSIDE 如果整个球面在法向量指向的平面的一侧,Intersect.OUTSIDE 如果整个球面在另一边, 或者 Intersect.INTERSECTING 如果球面与平面相交。

isOccluded(occluder)Boolean

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

volume()Number

计算包围球的半径。
Returns:
包围球的半径。