# ClippingGeometry

#### new Cesium.ClippingGeometry(viewer)
MapGIS/Scene/ClippingGeometry.js 89

几何体裁剪
几何体裁剪可以裁剪出凹多边形形状
模型的剖切封边功能同时支持对几何体裁剪做封边，但对凹多边形形状的封边效果支持不好。

Name | Type | Description
--- | --- | ---
`viewer` | Viewer |

##### Example:

    var geometryClipper = new Cesium.ClippingGeometry(viewer);
    var geometryOption = {
        type: Cesium.ClippingGeometryType.BOX,
        dimensions: new Cesium.Cartesian3(1000.0, 1000.0, 1000.0)
    }
    geometryClipper.addClipGeometry({
        geometry: geometryOption,
        position: Cesium.Cartesian3.fromDegrees(113.0538, 30.001, -400.0)
    });
    // 给M3D添加几何体裁剪
    M3DSet.geometryClipper = geometryClipper;
    // 给地形添加几何体裁剪
    viewer.scene.globe.geometryClipper = geometryClipper;

### Members

#### readonly clippingGeometry : Geometry|Model
MapGIS/Scene/ClippingGeometry.js 145

裁剪几何

#### inverse : Boolean
MapGIS/Scene/ClippingGeometry.js 156

反转裁剪几何区域
只对模型裁剪有效，对地形裁剪无效

### Methods

#### addClipGeometry(options) → Geometry|Model
MapGIS/Scene/ClippingGeometry.js 638

添加一个裁剪几何体

Name | Type | Description
--- | --- | ---
`options` | Object | 裁剪几何体参数
Name | Type | Description
--- | --- | ---
`geometry` | Object | String | 裁剪几何体 裁剪几何体支持内置几何类型`ClippingGeometryType`和外部的glb类型
`position` | Cartesian3 | optional 设置裁剪几何体的位置 `ClippingGeometryType.POLYLINEVOLUMEANIMATION`, `ClippingGeometryType.POLYLINEVOLUME`, `ClippingGeometryType.POLYGON`, `ClippingGeometryType.CORRIDOR` 这几种类型，由于其顶点数据是世界坐标，所以此属性不会起作用。

##### Returns:

##### Example:

    // 1. 圆台、圆锥、圆柱几何体
    var geometryOption = {
        type: Cesium.ClippingGeometryType.CYLINDER,
        length: 1000,
        topRadius: 500,
        bottomRadius: 500,
        slices: 128
    }
    geometryClipper.addClipGeometry({
        geometry: geometryOption,
        position: Cesium.Cartesian3.fromDegrees(113.0538, 30.001, -400.0)
    });

    // 2. 盒子几何体
    var geometryOption = {
        type: Cesium.ClippingGeometryType.BOX,
        dimensions: new Cesium.Cartesian3(1000.0, 1000.0, 1000.0)
    }
    geometryClipper.addClipGeometry({
        geometry: geometryOption,
        position: Cesium.Cartesian3.fromDegrees(113.0538, 30.001, -400.0)
    });

    // 3. 椭球、球几何体
    var geometryOption = {
        type: Cesium.ClippingGeometryType.ELLIPSOID,
        radii: new Cesium.Cartesian3(1000, 500, 500)
    }
    geometryClipper.addClipGeometry({
        geometry: geometryOption,
        position: Cesium.Cartesian3.fromDegrees(113.0538, 30.001, -400.0)
    });

    // 4. 通道几何体
    var positions = Cesium.Cartesian3.fromDegreesArray([113.05, 30, 113.0538, 30.05])
    var geometryOption = {
        type:Cesium.ClippingGeometryType.CORRIDOR,
        cornerType:Cesium.CornerType.MITERED,
        positions: positions,
        extrudedHeight: 500,
        height: -1000,
        width: 1000
    }
    geometryClipper.addClipGeometry({
        geometry: geometryOption
    });

    // 5. 多边形几何体
    var geometryOption = {
        type: Cesium.ClippingGeometryType.POLYGON,
        positions: [
            113.0405, 30.0171,
            113.0426, 30.0172,
            113.0576, 30.0088,
            113.0540, 30.0,
            113.0513, 29.9885
        ],
        height: -1000,
        extrudedHeight: 500
    }
    geometryClipper.addClipGeometry({
        geometry: geometryOption
    });

    // 6. 圆管几何体
    var geometryOption = {
        type: Cesium.ClippingGeometryType.POLYLINEVOLUME,
        radius: 500.0,
        positions: [
            Cesium.Cartesian3.fromDegrees(113.0308, 30.0174, -800.0),
            Cesium.Cartesian3.fromDegrees(113.0513, 30.0174, -800.0),
            Cesium.Cartesian3.fromDegrees(113.0807, 29.99, -800.0)
        ]
    }
    geometryClipper.addClipGeometry({
        geometry: geometryOption
    });

    // 7. 带顶点动画的圆管几何体
    var geometryOption = {
        type: Cesium.ClippingGeometryType.POLYLINEVOLUMEANIMATION,
        radius: 500.0,
        animationDuration: 5,//动画持续时间
        positions: [
            Cesium.Cartesian3.fromDegrees(113.0308, 30.0174, -800.0),
            Cesium.Cartesian3.fromDegrees(113.0513, 30.0174, -800.0),
            Cesium.Cartesian3.fromDegrees(113.0807, 29.99, -800.0)
        ]
    }
    var geometry = geometryClipper.addClipGeometry({
        geometry: geometryOption
    });
    geometry.playAnimation() // 播放顶点动画

    // 8. 外部glb
    var url = "../../SampleData/models/test.glb";
    geometryClipper.addClipGeometry({
        geometry: url,
        position: Cesium.Cartesian3.fromDegrees(113.0538, 30.001, -400.0)
    });