指定一组剪切多边形。剪切多边形有选择地禁用指定列表内部或外部区域的渲染 Specifies a set of clipping polygons. Clipping polygons selectively disable rendering in a region inside or outside the specified list of
ClippingPolygon 单个 glTF 模型、3D Tileset 或地球的对象。仅在 WebGL 2 上下文中支持剪切多边形。 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
如果为 true,将启用剪辑。 If true, clipping will be enabled.
-
默认值: Default Value:
true
如果为 true,则如果某个区域位于集合中每个多边形之外,则该区域将被剪裁。否则,只有在任何多边形内部的区域才会被剪裁。 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.
-
默认值: Default Value:
false
返回此集合中多边形的数量。这通常与 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()
控制用于剪切的有符号距离纹理的分辨率的标量。大于 1.0 的值会提高质量,小于 1.0 的值会降低质量。必须大于 0.0。 A scalar that controls the resolution of the signed distance texture used for clipping. Values greater than 1.0 increase quality, values less than 1.0 decrease it. Must be greater than 0.0.
-
默认值: Default Value:
1.0
方法 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 | 要添加到集合中的 ClippingPolygon。 The ClippingPolygon to add to the collection. |
返回: Returns:
添加的 ClippingPolygon。 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:
检查此集合是否包含等于给定 ClippingPolygon 的 ClippingPolygon。 Checks whether this collection contains a ClippingPolygon equal to the given ClippingPolygon.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
polygon |
ClippingPolygon | 要检查的 ClippingPolygon。 The ClippingPolygon to check for. |
返回: Returns:
如果此集合包含 ClippingPolygon,则为 true,否则为 false。 true if this collection contains the ClippingPolygon, false otherwise.
另见: See:
销毁该对象持有的 WebGL 资源。销毁对象可以确定性地释放 WebGL 资源,而不是依赖垃圾收集器来销毁该对象。 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:
指定索引处的 ClippingPolygon。 The ClippingPolygon at the specified index.
另见: See:
如果该对象被销毁则返回 true;否则为假。 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.
另见: See:
从集合中删除第一次出现的给定 ClippingPolygon。 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.
