一个有中心和半径的边界球。
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 instance.
Name | Type | Description |
---|---|---|
sphere |
BoundingSphere | 要复制的边界球体。 |
result |
BoundingSphere | optional 要在其上存储结果的对象。 |
Returns:
修改后的结果参数,如果没有提供,则为新的BoundingSphere实例。 (如果球体未定义则返回未定义)
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 | sphere. |
cartesian |
Cartesian3 | point |
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
Computes a bounding sphere by enlarging the provided sphere to contain the provided point.
Name | Type | Description |
---|---|---|
sphere |
BoundingSphere | A sphere to expand. |
point |
Cartesian3 | A point to enclose in a bounding sphere. |
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 最小高度 rectangle. |
oppositeCorner |
Cartesian3 | optional 最大高度 rectangle. |
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
计算一个紧密拟合的边界球,包含一个encodedcartesians列表,其中点在哪里
按X, Y, Z顺序存储在并行平面数组中。边界球是通过运行2来计算的
算法,朴素算法和里特算法。两个球体中较小的那个被用来
确保贴身。
Name | Type | Description |
---|---|---|
positionsHigh |
Array.<number> | optional 边界球将包围的编码笛卡尔坐标的高位数组。每一个点 由数组中的三个元素按顺序X, Y, Z组成。 |
positionsLow |
Array.<number> | optional 边界球将包围的编码笛卡尔坐标的低位数组。每一个点 由数组中的三个元素按顺序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笛卡尔点列表。
边界球是通过运行两种算法来计算的,一个朴素算法和
里特算法。两个球体中较小的一个用于确保紧密配合。
Name | Type | Description |
---|---|---|
positions |
Array.<Cartesian3> |
optional
边界球将包围的点数组。每个点必须具有x 、y 和z 属性。 |
result |
BoundingSphere | optional 要在其上存储结果的对象。 |
Returns:
修改后的结果参数或新的BoundingSphere实例(如果没有提供)。
static Cesium.BoundingSphere.fromRectangle2D(rectangle, projection, result) → BoundingSphere
从2D中投影的矩形计算边界球。
Name | Type | Default | Description |
---|---|---|---|
rectangle |
Rectangle | optional 要在其周围创建边界球的矩形。 | |
projection |
object |
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 |
object |
GeographicProjection
|
optional 用于将矩形投影到2D中的投影。 |
minimumHeight |
number |
0.0
|
optional 最小高度 rectangle. |
maximumHeight |
number |
0.0
|
optional 最大高度 rectangle. |
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顺序存储在平面数组中。边界球是通过运行2来计算的
算法,朴素算法和里特算法。两个球体中较小的那个被用来
确保贴身。
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:
// 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
Creates a bounding sphere in 2D from a bounding sphere in 3D world coordinates.
Name | Type | Default | Description |
---|---|---|---|
sphere |
BoundingSphere | The bounding sphere to transform to 2D. | |
projection |
object |
GeographicProjection
|
optional The projection to 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 instance.
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 | point |
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
。
计算BoundingSphere的半径。
Returns:
BoundingSphere的半径。