指定一组裁剪多边形。裁剪多边形选择性地禁用渲染,
在
ClippingPolygon 对象列表的内部或外部区域对单个 glTF 模型、3D Tileset 或地球体禁用渲染。
裁剪多边形仅在 WebGL 2 上下文中受支持。
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
具有以下属性的对象:
|
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,裁剪将启用。
-
Default Value:
true
如果为 true,当区域位于集合中所有多边形外部时将被裁剪。
否则,仅当区域位于任何多边形内部时才会被裁剪。
-
Default Value:
false
返回此集合中多边形的数量。这通常与
ClippingPolygonCollection#get 一起使用以遍历集合中的所有多边形。
polygonAdded : Event
当向集合添加新裁剪多边形时触发的事件。事件处理程序
将接收新多边形及其添加的索引。
-
Default Value:
Event()
polygonRemoved : Event
当从集合中移除裁剪多边形时触发的事件。事件处理程序
将接收被移除的多边形及其被移除的索引。
-
Default Value:
Event()
控制用于裁剪的有符号距离纹理分辨率的标量。
大于 1.0 的值提高质量,小于 1.0 的值降低质量。必须大于 0.0。
-
Default Value:
1.0
Methods
检查上下文是否允许裁剪多边形(需要浮点纹理)。
| Name | Type | Description |
|---|---|---|
scene |
Scene | object | 将包含被裁剪对象和裁剪纹理的场景。 |
Returns:
如果上下文支持裁剪多边形则返回
true。
将指定的
ClippingPolygon 添加到集合中,用于选择性地禁用
每个多边形内部的渲染。使用 ClippingPolygonCollection#unionClippingRegions 修改
多个多边形的裁剪行为。
| Name | Type | Description |
|---|---|---|
polygon |
ClippingPolygon | 要添加到集合的 ClippingPolygon。 |
Returns:
添加的 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 相等的裁剪多边形。
| Name | Type | Description |
|---|---|---|
polygon |
ClippingPolygon | 要检查的 ClippingPolygon。 |
Returns:
如果此集合包含 ClippingPolygon 则返回 true,否则返回 false。
销毁此对象持有的 WebGL 资源。销毁对象允许确定性
释放 WebGL 资源,而不是依赖垃圾回收器来销毁此对象。
对象销毁后不应再使用;调用除
对象销毁后不应再使用;调用除
isDestroyed 之外的任何函数都将导致 DeveloperError 异常。因此,
如示例所示,将返回值(undefined)赋给该对象。
Throws:
-
DeveloperError : 此对象已被销毁,即调用了 destroy()。
Example:
clippingPolygons = clippingPolygons && clippingPolygons.destroy();
See:
返回集合中指定索引处的裁剪多边形。索引从零开始
随着添加多边形而增加。移除多边形会将其后的所有多边形左移,
更改它们的索引。此函数通常与
ClippingPolygonCollection#length 一起使用以遍历集合中的所有多边形。
| Name | Type | Description |
|---|---|---|
index |
number | 多边形的从零开始的索引。 |
Returns:
指定索引处的 ClippingPolygon。
Returns:
如果此对象已被销毁则返回
true;否则返回 false。
从集合中移除给定 ClippingPolygon 的第一次出现。
| Name | Type | Description |
|---|---|---|
polygon |
ClippingPolygon |
Returns:
如果多边形被移除则返回
true;如果在集合中未找到多边形则返回 false。
See:
从集合中移除所有多边形。
