其他分享
首页 > 其他分享> > cesium-点线面

cesium-点线面

作者:互联网

    let viewer = new Cesium.Viewer('cesiumContainer');
    //平面
    let plane = viewer.entities.add({
        name: '带边框的平面',
        position: Cesium.Cartesian3.fromDegrees(-107.0, 40.0, 300000.0),//经纬度转世界坐标
        plane: {
            show: true,//是否显示
            plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_Z, 0.0), //朝向屏幕
            dimensions: new Cesium.Cartesian2(400000.0, 300000.0), //二维平面
            material: Cesium.Color.BLUE,//材质
            fill: true,//填充
            outline: true,//显示边框
            outlineColor: Cesium.Color.YELLOW,//边框颜色
        }
    });
    //点
    let point = viewer.entities.add({
        name: '点',
        position: Cesium.Cartesian3.fromDegrees(-75.0, 30.0),//经纬度转世界坐标
        point: {
            show: true,
            color: Cesium.Color.GREEN,
            pixelSize: 20,
            outlineColor: Cesium.Color.YELLOW,
            outlineWidth: 3,
        }
    });
    //线
    let line = viewer.entities.add({
        name: '线',
        polyline: {
            positions: Cesium.Cartesian3.fromDegreesArray([-75, 30, -125, 30]),//经纬度数组转世界坐标,带高度的话是fromDegreesArrayHeights
            width: 5,
            material: Cesium.Color.CYAN
        }
    });
    //面
    let polygon = viewer.entities.add({
        name: '面',
        polygon: {
            hierarchy: {//层次
                positions: Cesium.Cartesian3.fromDegreesArray([
                    -99.0,
                    30.0,
                    -85.0,
                    30.0,
                    -85.0,
                    40.0,
                    -99.0,
                    40.0,
                ]),

                holes: [{ //挖洞,可以无限嵌套
                    positions: Cesium.Cartesian3.fromDegreesArray([
                        -97.0,
                        31.0,
                        -97.0,
                        39.0,
                        -87.0,
                        39.0,
                        -87.0,
                        31.0,
                    ]),
                    holes: [ 
                        {
                            positions: Cesium.Cartesian3.fromDegreesArray([
                                -95.0,
                                33.0,
                                -89.0,
                                33.0,
                                -89.0,
                                37.0,
                                -95.0,
                                37.0,
                            ])
                        }]
                }],
            },
            material: Cesium.Color.RED.withAlpha(0.5)
        }
    });

请添加图片描述

标签:entities,Cartesian3,Color,Cesium,viewer,let,cesium,点线面
来源: https://blog.csdn.net/github_38618068/article/details/122607515