Appearance
KBE3D / KBCore / Cesium / Occluder
类: Occluder
Creates an Occluder derived from an object's position and radius, as well as the camera position. The occluder can be used to determine whether or not other objects are visible or hidden behind the visible horizon defined by the occluder and camera position.
示例
ts
// 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);参数
The bounding sphere surrounding the occluder.
参数
The coordinate of the viewer/camera.
属性
position
position:
Cartesian3
The position of the occluder.
radius
radius:
number
The radius of the occluder.
cameraPosition
cameraPosition:
Cartesian3
The position of the camera.
方法
fromBoundingSphere()
staticfromBoundingSphere(occluderBoundingSphere:BoundingSphere,cameraPosition:Cartesian3,result?:Occluder):Occluder
Creates an occluder from a bounding sphere and the camera position.
参数
occluderBoundingSphere
The bounding sphere surrounding the occluder.
cameraPosition
The coordinate of the viewer/camera.
result?
Occluder
The object onto which to store the result.
返回
Occluder
The occluder derived from an object's position and radius, as well as the camera position.
computeOccludeePoint()
staticcomputeOccludeePoint(occluderBoundingSphere:BoundingSphere,occludeePosition:Cartesian3,positions:Cartesian3[]):any
Computes a point that can be used as the occludee position to the visibility functions. Use a radius of zero for the occludee radius. Typically, a user computes a bounding sphere around an object that is used for visibility; however it is also possible to compute a point that if seen/not seen would also indicate if an object is visible/not visible. This function is better called for objects that do not move relative to the occluder and is large, such as a chunk of terrain. You are better off not calling this and using the object's bounding sphere for objects such as a satellite or ground vehicle.
参数
occluderBoundingSphere
The bounding sphere surrounding the occluder.
occludeePosition
The point where the occludee (bounding sphere of radius 0) is located.
positions
List of altitude points on the horizon near the surface of the occluder.
返回
any
An object containing two attributes: occludeePoint and valid which is a boolean value.
示例
ts
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);computeOccludeePointFromRectangle()
staticcomputeOccludeePointFromRectangle(rectangle:Rectangle,ellipsoid?:Ellipsoid):any
Computes a point that can be used as the occludee position to the visibility functions from a rectangle.
参数
rectangle
The rectangle used to create a bounding sphere.
ellipsoid?
The ellipsoid used to determine positions of the rectangle.
返回
any
An object containing two attributes: occludeePoint and valid which is a boolean value.
isPointVisible()
isPointVisible(
occludee:Cartesian3):boolean
Determines whether or not a point, the <code>occludee</code>, is hidden from view by the occluder.
参数
occludee
The point surrounding the occludee object.
返回
boolean
true if the occludee is visible; otherwise false.
示例
ts
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 trueisBoundingSphereVisible()
isBoundingSphereVisible(
occludee:BoundingSphere):boolean
Determines whether or not a sphere, the <code>occludee</code>, is hidden from view by the occluder.
参数
occludee
The bounding sphere surrounding the occludee object.
返回
boolean
true if the occludee is visible; otherwise false.
示例
ts
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 truecomputeVisibility()
computeVisibility(
occludeeBS:BoundingSphere):Visibility
Determine to what extent an occludee is visible (not visible, partially visible, or fully visible).
参数
occludeeBS
The bounding sphere of the occludee.
返回
Visibility.NONE if the occludee is not visible, Visibility.PARTIAL if the occludee is partially visible, or Visibility.FULL if the occludee is fully visible.
示例
ts
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构造函数
构造函数
new Occluder(
occluderBoundingSphere:BoundingSphere,cameraPosition:Cartesian3):Occluder
参数
occluderBoundingSphere
cameraPosition
返回
Occluder
