创建从对象的位置和半径以及摄像机位置派生的 Occluder。
遮挡物可用于确定其他对象是否可见或隐藏在
由 Occluder 和 Camera Position 定义的可见地平线。
Name | Type | Description |
---|---|---|
occluderBoundingSphere |
BoundingSphere | 围绕遮挡物的边界球体。 |
cameraPosition |
Cartesian3 | 查看器/相机的坐标。 |
Example:
// Construct an occluder one unit away from the origin with a radius of one.
const cameraPosition = Cesium.Cartesian3.ZERO;
const occluderBoundingSphere = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, -1), 1);
const occluder = new Cesium.Occluder(occluderBoundingSphere, cameraPosition);
Members
cameraPosition : Cartesian3
相机的位置。
position : Cartesian3
遮挡物的位置。
遮挡物的半径。
Methods
static Cesium.Occluder.computeOccludeePoint(occluderBoundingSphere, occludeePosition, positions) → object
计算可用作可见性函数的遮挡位置的点。
对遮挡对象半径使用零的半径。 通常,用户会计算一个围绕
用于可见性的对象;但是,也可以计算一个点,如果
seen/not seen 还将指示对象是否可见/不可见。 这个功能比较好
适用于不相对于遮挡物移动且较大的对象,例如
地形。 最好不要调用此函数,而是将对象的边界球体用于对象
例如卫星或地面车辆。
Name | Type | Description |
---|---|---|
occluderBoundingSphere |
BoundingSphere | 围绕遮挡物的边界球体。 |
occludeePosition |
Cartesian3 | 被遮挡物(半径为 0 的边界球体)所在的点。 |
positions |
Array.<Cartesian3> | 遮挡物表面附近地平线上的高度点列表。 |
Returns:
包含两个属性的对象:
occludeePoint
和 valid
的 Boolean 值。
Throws:
-
DeveloperError :
positions
must contain at least one element.
Example:
const cameraPosition = new Cesium.Cartesian3(0, 0, 0);
const occluderBoundingSphere = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, -8), 2);
const occluder = new Cesium.Occluder(occluderBoundingSphere, cameraPosition);
const positions = [new Cesium.Cartesian3(-0.25, 0, -5.3), new Cesium.Cartesian3(0.25, 0, -5.3)];
const tileOccluderSphere = Cesium.BoundingSphere.fromPoints(positions);
const occludeePosition = tileOccluderSphere.center;
const occludeePt = Cesium.Occluder.computeOccludeePoint(occluderBoundingSphere, occludeePosition, positions);
计算一个点,该点可用作矩形中可见性函数的遮挡位置。
Name | Type | Default | Description |
---|---|---|---|
rectangle |
Rectangle | 用于创建边界球体的矩形。 | |
ellipsoid |
Ellipsoid |
Ellipsoid.default
|
optional 用于确定矩形位置的椭球体。 |
Returns:
包含两个属性的对象:
occludeePoint
和 valid
的 Boolean 值。
static Cesium.Occluder.fromBoundingSphere(occluderBoundingSphere, cameraPosition, result) → Occluder
从边界球体和相机位置创建遮挡物。
Name | Type | Description |
---|---|---|
occluderBoundingSphere |
BoundingSphere | 围绕遮挡物的边界球体。 |
cameraPosition |
Cartesian3 | 查看器/相机的坐标。 |
result |
Occluder | optional 要在其上存储结果的对象。 |
Returns:
从对象的位置和半径以及相机位置派生的遮挡物。
computeVisibility(occludeeBS) → Visibility
确定被遮挡对象的可见程度 (不可见、部分可见或完全可见)。
Name | Type | Description |
---|---|---|
occludeeBS |
BoundingSphere | 被遮挡对象的边界球体。 |
Returns:
Visibility.NONE 如果被遮挡对象不可见,
Visibility.PARTIAL(如果被遮挡对象部分可见),或者
Visibility.FULL(如果被遮挡对象完全可见)。
Example:
const sphere1 = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, -1.5), 0.5);
const sphere2 = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, -2.5), 0.5);
const cameraPosition = new Cesium.Cartesian3(0, 0, 0);
const occluder = new Cesium.Occluder(sphere1, cameraPosition);
occluder.computeVisibility(sphere2); //returns Visibility.NONE
确定球体(
被遮挡
物)是否被遮挡物隐藏。
Name | Type | Description |
---|---|---|
occludee |
BoundingSphere | 包围被遮挡物体的边界球。 |
Returns:
如果 occludee 可见,则为
true
;否则为 false
。
Example:
const cameraPosition = new Cesium.Cartesian3(0, 0, 0);
const littleSphere = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, -1), 0.25);
const occluder = new Cesium.Occluder(littleSphere, cameraPosition);
const bigSphere = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, -3), 1);
occluder.isBoundingSphereVisible(bigSphere); //returns true
See:
Determines whether or not a point, the
occludee
, is hidden from view by the occluder.
Name | Type | Description |
---|---|---|
occludee |
Cartesian3 | The point surrounding the occludee object. |
Returns:
true
if the occludee is visible; otherwise false
.
Example:
const cameraPosition = new Cesium.Cartesian3(0, 0, 0);
const littleSphere = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, -1), 0.25);
const occluder = new Cesium.Occluder(littleSphere, cameraPosition);
const point = new Cesium.Cartesian3(0, 0, -3);
occluder.isPointVisible(point); //returns true