new 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.
Parameters:
| Name | Type | Description |
|---|---|---|
occluderBoundingSphere |
BoundingSphere | The bounding sphere surrounding the occluder. |
cameraPosition |
Cartesian3 | The coordinate of the viewer/camera. |
Throws:
-
DeveloperError :
occluderBoundingSphereis required. -
DeveloperError :
cameraPositionis required.
Example
// Construct an occluder one unit away from the origin with a radius of one. var cameraPosition = new Cartesian3.ZERO; var occluderBoundingSphere = new BoundingSphere(new Cartesian3(0, 0, -1), 1); var occluder = new Occluder(occluderBoundingSphere, cameraPosition);
Source:
Methods
-
getPosition
-
Returns the position of the occluder.
Returns:
Cartesian3 The position of the occluder. -
getVisibility
-
Determine to what extent an occludee is visible (not visible, partially visible, or fully visible).
Parameters:
Name Type Description occludeeBSBoundingSphere Returns:
Enumeration 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.Example
var sphere1 = new BoundingSphere(new Cartesian3(0, 0, -1.5), 0.5); var sphere2 = new BoundingSphere(new Cartesian3(0, 0, -2.5), 0.5); var cameraPosition = new Cartesian3(0, 0, 0); var occluder = new Occluder(sphere1, cameraPosition); occluder.getVisibility(sphere2); //returns Visibility.NONE
- Occluder#isVisible
See:
-
isBoundingSphereVisible
-
Determines whether or not a sphere, the
occludee, is hidden from view by the occluder.Parameters:
Name Type Description occludeeBoundingSphere The bounding sphere surrounding the occludee object. Returns:
booleantrueif the occludee is visible; otherwisefalse.Example
var cameraPosition = new Cartesian3(0, 0, 0); var littleSphere = new BoundingSphere(new Cartesian3(0, 0, -1), 0.25); var occluder = new Occluder(littleSphere, cameraPosition); var bigSphere = new BoundingSphere(new Cartesian3(0, 0, -3), 1); occluder.isBoundingSphereVisible(bigSphere); //returns true
-
isPointVisible
-
Determines whether or not a point, the
occludee, is hidden from view by the occluder.Parameters:
Name Type Description occludeeCartesian3 The point surrounding the occludee object. Returns:
booleantrueif the occludee is visible; otherwisefalse.Example
var cameraPosition = new Cartesian3(0, 0, 0); var littleSphere = new BoundingSphere(new Cartesian3(0, 0, -1), 0.25); var occluder = new Occluder(littleSphere, cameraPosition); var point = new Cartesian3(0, 0, -3); occluder.isPointVisible(point); //returns true
-
<static> computeOccludeePointFromExtent
-
Computes a point that can be used as the occludee position to the visibility functions from an extent.
Parameters:
Name Type Argument Default Description extentExtent The extent used to create a bounding sphere. ellipsoidEllipsoid <optional>
Ellipsoid.WGS84 The ellipsoid used to determine positions of the extent. Throws:
DeveloperError : extent is required.Returns:
Object An object containing two attributes:occludeePointandvalidwhich is a boolean value. -
<static> getOccludeePoint
-
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 occluderBoundingSphereBoundingSphere The bounding sphere surrounding the occluder. occludeePositionCartesian3 The point where the occludee (bounding sphere of radius 0) is located. positionsArray List of altitude points on the horizon near the surface of the occluder. Throws:
-
DeveloperError :
positionsis a required, non-empty array. -
DeveloperError :
occluderBoundingSphereis required.
Returns:
Object An object containing two attributes:occludeePointandvalidwhich is a boolean value.Example
var cameraPosition = new Cartesian3(0, 0, 0); var occluderBoundingSphere = new BoundingSphere(new Cartesian3(0, 0, -8), 2); var occluder = new Occluder(occluderBoundingSphere, cameraPosition); var positions = [new Cartesian3(-0.25, 0, -5.3), new Cartesian3(0.25, 0, -5.3)]; var tileOccluderSphere = BoundingSphere.fromPoints(positions); var occludeePosition = tileOccluderSphere.center; var occludeePt = occluder.getOccludeePoint(occluderBoundingSphere, occludeePosition, positions);
-
-
<static> prototype.getRadius
-
Returns the radius of the occluder.
Returns:
Number The radius of the occluder. -
<static> prototype.setCameraPosition
-
Sets the position of the camera.
Parameters:
Name Type Description cameraPositionCartesian3 The new position of the camera.
