| 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)
static Cesium.BoundingSphere.computePlaneDistances(sphere, position, direction, result) → Interval
通过从边界球中心到位置的向量投影到方向计算的距离,
加上/减去边界球的半径。
如果想象无限多个具有法线方向的平面,这将计算从位置到 与边界球相交的最近和最远平面的最小距离。
如果想象无限多个具有法线方向的平面,这将计算从位置到 与边界球相交的最近和最远平面的最小距离。
| Name | Type | Description |
|---|---|---|
sphere |
BoundingSphere | 要计算距离的边界球。 |
position |
Cartesian3 | 要计算距离的位置。 |
direction |
Cartesian3 | 从位置出发的方向。 |
result |
Interval | optional 用于存储最近和最远距离的Interval。 |
Returns:
从位置沿方向到边界球的最近和最远距离。
计算从边界球上最近点到某点的估计距离的平方。
| Name | Type | Description |
|---|---|---|
sphere |
BoundingSphere | 球体。 |
cartesian |
Cartesian3 | 该点 |
Returns:
从边界球到该点的距离平方。如果该点在球内则返回0。
Example:
// 从后到前对边界球排序
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:
如果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:
// 在单位立方体周围创建边界球
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
边界球将包围的点数组。每个点必须具有x、y和z属性。 |
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。当步幅为3时,下一个位置的X坐标从数组索引3开始。如果 步幅为5,则跳过两个数组元素,下一个位置从数组 索引5开始。 |
result |
BoundingSphere | optional 存储结果的对象。 |
Returns:
修改后的结果参数;如果未提供则返回新的BoundingSphere实例。
Example:
// 从3个位置计算边界球,每个位置相对于一个中心指定。
// 除了X、Y和Z坐标外,点数组还包含每个点额外的
// 两个元素,在计算边界球时会被忽略。
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
从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实例。
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 用于存储最近和最远距离的Interval。 |
Returns:
从位置沿方向到边界球的最近和最远距离。
计算从边界球上最近点到某点的估计距离的平方。
| Name | Type | Description |
|---|---|---|
cartesian |
Cartesian3 | 该点 |
Returns:
从边界球到该点的估计距离平方。
Example:
// 从后到前对边界球排序
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。
计算BoundingSphere的半径。
Returns:
BoundingSphere的半径。
