指定一组裁剪多边形。裁剪多边形会选择性地禁用单个 glTF 模型、3D Tileset 或地球上、位于
ClippingPolygon 对象指定列表内部或外部的区域的渲染。
裁剪多边形仅在 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 相等的 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:
从集合中移除所有多边形。
