ClippingPolygonCollection

new Cesium.ClippingPolygonCollection(options)

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.
参数名称 类型 描述信息
options object 可选 Object with the following properties:
参数名称 类型 默认值 描述信息
polygons Array.<ClippingPolygon> [] 可选 An array of ClippingPolygon objects used to selectively disable rendering on the inside of each polygon.
enabled boolean true 可选 Determines whether the clipping polygons are active.
inverse boolean false 可选 If true, a region will be clipped if it is outside of every polygon in the collection. Otherwise, a region will only be clipped if it is on the inside of any polygon.
使用示例:
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 ]
});

成员(属性)

Returns the number of polygons in this collection. This is commonly used with ClippingPolygonCollection#get to iterate over all the polygons in the collection.
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.
默认值: 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.
默认值: Event()

方法

static Cesium.ClippingPolygonCollection.isSupported(scene)boolean

Function for checking if the context will allow clipping polygons, which require floating point textures.
参数名称 类型 描述信息
scene Scene | object The scene that will contain clipped objects and clipping textures.
返回值:
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.
参数名称 类型 描述信息
polygon ClippingPolygon The ClippingPolygon to add to the collection.
返回值:
The added ClippingPolygon.
使用示例:
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
}));
参考:
Checks whether this collection contains a ClippingPolygon equal to the given ClippingPolygon.
参数名称 类型 描述信息
polygon ClippingPolygon The ClippingPolygon to check for.
返回值:
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 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.
使用示例:
clippingPolygons = clippingPolygons && clippingPolygons.destroy();
参考:
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.
参数名称 类型 描述信息
index number The zero-based index of the polygon.
返回值:
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 isDestroyed will result in a DeveloperError exception.
返回值:
true if this object was destroyed; otherwise, false.
参考:
Removes the first occurrence of the given ClippingPolygon from the collection.
参数名称 类型 描述信息
polygon ClippingPolygon
返回值:
true if the polygon was removed; false if the polygon was not found in the collection.
参考:
Removes all polygons from the collection.
参考: