Appearance
KBE3D / KBCore / Cesium / ClippingPolygonCollection
类: ClippingPolygonCollection
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.
示例
ts
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 ]
});参数
Object with the following properties:
参数
An array of ClippingPolygon objects used to selectively disable rendering on the inside of each polygon.
参数
Determines whether the clipping polygons are active.
参数
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.
属性
enabled
enabled:
boolean
If true, clipping will be enabled.
inverse
inverse:
boolean
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 inside of any polygon.
polygonAdded
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.
polygonRemoved
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.
length
readonlylength:number
Returns the number of polygons in this collection. This is commonly used with ClippingPolygonCollection#get to iterate over all the polygons in the collection.
方法
isSupported()
staticisSupported(scene:any):boolean
Function for checking if the context will allow clipping polygons, which require floating point textures.
参数
scene
any
The scene that will contain clipped objects and clipping textures.
返回
boolean
true if the context supports clipping polygons.
add()
add(
polygon:ClippingPolygon):ClippingPolygon
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
The ClippingPolygon to add to the collection.
返回
The added ClippingPolygon.
示例
ts
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
}));get()
get(
index:number):ClippingPolygon
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.
contains()
contains(
polygon:ClippingPolygon):boolean
Checks whether this collection contains a ClippingPolygon equal to the given ClippingPolygon.
参数
polygon
The ClippingPolygon to check for.
返回
boolean
true if this collection contains the ClippingPolygon, false otherwise.
remove()
remove(
polygon:ClippingPolygon):boolean
Removes the first occurrence of the given ClippingPolygon from the collection.
参数
polygon
返回
boolean
true if the polygon was removed; false if the polygon was not found in the collection.
removeAll()
removeAll():
void
Removes all polygons from the collection.
返回
void
isDestroyed()
isDestroyed():
boolean
Returns true if this object was destroyed; otherwise, false. <br /><br /> If this object was destroyed, it should not be used; calling any function other than <code>isDestroyed</code> will result in a DeveloperError exception.
返回
boolean
true if this object was destroyed; otherwise, false.
destroy()
destroy():
void
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. <br /><br /> Once an object is destroyed, it should not be used; calling any function other than <code>isDestroyed</code> will result in a DeveloperError exception. Therefore, assign the return value (<code>undefined</code>) to the object as done in the example.
返回
void
示例
ts
clippingPolygons = clippingPolygons && clippingPolygons.destroy();构造函数
构造函数
new ClippingPolygonCollection(
options?: {polygons?:ClippingPolygon[];enabled?:boolean;inverse?:boolean; }):ClippingPolygonCollection
参数
options?
polygons?
enabled?
boolean
inverse?
boolean
返回
ClippingPolygonCollection
