Class: Occluder

Occluder

new Occluder(occluderBoundingSphere, cameraPosition)

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.
Parameters:
Name Type Description
occluderBoundingSphere BoundingSphere The bounding sphere surrounding the occluder.
cameraPosition Cartesian3 The coordinate of the viewer/camera.
Source:
Example
// Construct an occluder one unit away from the origin with a radius of one.
var cameraPosition = Cesium.Cartesian3.ZERO;
var occluderBoundingSphere = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, -1), 1);
var occluder = new Cesium.Occluder(occluderBoundingSphere, cameraPosition);

Members

cameraPosition :Cartesian3

The position of the camera.
Type:
Source:

position :Cartesian3

The position of the occluder.
Type:
Source:

radius :Number

The radius of the occluder.
Type:
  • Number
Source:

Methods

(static) computeOccludeePoint(occluderBoundingSphere, occludeePosition, positions) → {Object}

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.
Parameters:
Name Type Description
occluderBoundingSphere BoundingSphere The bounding sphere surrounding the occluder.
occludeePosition Cartesian3 The point where the occludee (bounding sphere of radius 0) is located.
positions Array.<Cartesian3> List of altitude points on the horizon near the surface of the occluder.
Source:
Throws:
  • positions must contain at least one element.
    Type
    DeveloperError
  • occludeePosition must have a value other than occluderBoundingSphere.center.
    Type
    DeveloperError
Returns:
An object containing two attributes: occludeePoint and valid which is a boolean value.
Type
Object
Example
var cameraPosition = new Cesium.Cartesian3(0, 0, 0);
var occluderBoundingSphere = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, -8), 2);
var occluder = new Cesium.Occluder(occluderBoundingSphere, cameraPosition);
var positions = [new Cesium.Cartesian3(-0.25, 0, -5.3), new Cesium.Cartesian3(0.25, 0, -5.3)];
var tileOccluderSphere = Cesium.BoundingSphere.fromPoints(positions);
var occludeePosition = tileOccluderSphere.center;
var occludeePt = Cesium.Occluder.computeOccludeePoint(occluderBoundingSphere, occludeePosition, positions);

(static) computeOccludeePointFromRectangle(rectangle, ellipsoidopt) → {Object}

Computes a point that can be used as the occludee position to the visibility functions from an rectangle.
Parameters:
Name Type Attributes Default Description
rectangle Rectangle The rectangle used to create a bounding sphere.
ellipsoid Ellipsoid <optional>
Ellipsoid.WGS84 The ellipsoid used to determine positions of the rectangle.
Source:
Returns:
An object containing two attributes: occludeePoint and valid which is a boolean value.
Type
Object

(static) fromBoundingSphere(occluderBoundingSphere, cameraPosition, resultopt) → {Occluder}

Creates an occluder from a bounding sphere and the camera position.
Parameters:
Name Type Attributes Description
occluderBoundingSphere BoundingSphere The bounding sphere surrounding the occluder.
cameraPosition Cartesian3 The coordinate of the viewer/camera.
result Occluder <optional>
The object onto which to store the result.
Source:
Returns:
The occluder derived from an object's position and radius, as well as the camera position.
Type
Occluder

computeVisibility(occludeeBS) → {Number}

Determine to what extent an occludee is visible (not visible, partially visible, or fully visible).
Parameters:
Name Type Description
occludeeBS BoundingSphere The bounding sphere of the occludee.
Source:
See:
  • Occluder#isVisible
Returns:
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.
Type
Number
Example
var sphere1 = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, -1.5), 0.5);
var sphere2 = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, -2.5), 0.5);
var cameraPosition = new Cesium.Cartesian3(0, 0, 0);
var occluder = new Cesium.Occluder(sphere1, cameraPosition);
occluder.computeVisibility(sphere2); //returns Visibility.NONE

isBoundingSphereVisible(occludee) → {Boolean}

Determines whether or not a sphere, the occludee, is hidden from view by the occluder.
Parameters:
Name Type Description
occludee BoundingSphere The bounding sphere surrounding the occludee object.
Source:
See:
Returns:
true if the occludee is visible; otherwise false.
Type
Boolean
Example
var cameraPosition = new Cesium.Cartesian3(0, 0, 0);
var littleSphere = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, -1), 0.25);
var occluder = new Cesium.Occluder(littleSphere, cameraPosition);
var bigSphere = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, -3), 1);
occluder.isBoundingSphereVisible(bigSphere); //returns true

isPointVisible(occludee) → {Boolean}

Determines whether or not a point, the occludee, is hidden from view by the occluder.
Parameters:
Name Type Description
occludee Cartesian3 The point surrounding the occludee object.
Source:
See:
Returns:
true if the occludee is visible; otherwise false.
Type
Boolean
Example
var cameraPosition = new Cesium.Cartesian3(0, 0, 0);
var littleSphere = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, -1), 0.25);
var occluder = new Cesium.Occluder(littleSphere, cameraPosition);
var point = new Cesium.Cartesian3(0, 0, -3);
occluder.isPointVisible(point); //returns true