Specifies a set of clipping polygons. Clipping polygons selectively disable rendering in a region
inside or outside the specified list of
ClippingPolygon
objects for a single glTF model, 3D Tileset, or the globe.
Clipping Polygons are only supported in WebGL 2 contexts.
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
Object with the following properties:
|
Example:
const positions = Cesium.Cartesian3.fromRadiansArray([
-1.3194369277314022,
0.6988062530900625,
-1.31941,
0.69879,
-1.3193955980204217,
0.6988091578771254,
-1.3193931220959367,
0.698743632490865,
-1.3194358224045408,
0.6987471965556998,
]);
const polygon = new Cesium.ClippingPolygon({
positions: positions
});
const polygons = new Cesium.ClippingPolygonCollection({
polygons: [ polygon ]
});
Members
Returns the number of polygons in this collection. This is commonly used with
ClippingPolygonCollection#get
to iterate over all the polygons
in the collection.
polygonAdded : Event
An event triggered when a new clipping polygon is added to the collection. Event handlers
are passed the new polygon and the index at which it was added.
-
Default Value:
Event()
polygonRemoved : Event
An event triggered when a new clipping polygon is removed from the collection. Event handlers
are passed the new polygon and the index from which it was removed.
-
Default Value:
Event()
Methods
Function for checking if the context will allow clipping polygons, which require floating point textures.
Name | Type | Description |
---|---|---|
scene |
Scene | object | The scene that will contain clipped objects and clipping textures. |
Returns:
true
if the context supports clipping polygons.
Adds the specified
ClippingPolygon
to the collection to be used to selectively disable rendering
on the inside of each polygon. Use ClippingPolygonCollection#unionClippingRegions
to modify
how modify the clipping behavior of multiple polygons.
Name | Type | Description |
---|---|---|
polygon |
ClippingPolygon | The ClippingPolygon to add to the collection. |
Returns:
The added ClippingPolygon.
Example:
const polygons = new Cesium.ClippingPolygonCollection();
const positions = Cesium.Cartesian3.fromRadiansArray([
-1.3194369277314022,
0.6988062530900625,
-1.31941,
0.69879,
-1.3193955980204217,
0.6988091578771254,
-1.3193931220959367,
0.698743632490865,
-1.3194358224045408,
0.6987471965556998,
]);
polygons.add(new Cesium.ClippingPolygon({
positions: positions
}));
See:
Checks whether this collection contains a ClippingPolygon equal to the given ClippingPolygon.
Name | Type | Description |
---|---|---|
polygon |
ClippingPolygon | The ClippingPolygon to check for. |
Returns:
true if this collection contains the ClippingPolygon, false otherwise.
Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
release of WebGL resources, instead of relying on the garbage collector to destroy this object.
Once an object is destroyed, it should not be used; calling any function other than
Once an object is destroyed, it should not be used; calling any function other than
isDestroyed
will result in a DeveloperError
exception. Therefore,
assign the return value (undefined
) to the object as done in the example.
Throws:
-
DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
clippingPolygons = clippingPolygons && clippingPolygons.destroy();
See:
Returns the clipping polygon in the collection at the specified index. Indices are zero-based
and increase as polygons are added. Removing a polygon polygon all polygons after
it to the left, changing their indices. This function is commonly used with
ClippingPolygonCollection#length
to iterate over all the polygons
in the collection.
Name | Type | Description |
---|---|---|
index |
number | The zero-based index of the polygon. |
Returns:
The ClippingPolygon at the specified index.
Returns true if this object was destroyed; otherwise, false.
If this object was destroyed, it should not be used; calling any function other than
If this object was destroyed, it should not be used; calling any function other than
isDestroyed
will result in a DeveloperError
exception.
Returns:
true
if this object was destroyed; otherwise, false
.
Removes the first occurrence of the given ClippingPolygon from the collection.
Name | Type | Description |
---|---|---|
polygon |
ClippingPolygon |
Returns:
true
if the polygon was removed; false
if the polygon was not found in the collection.
See:
Removes all polygons from the collection.