美文网首页cesium
cesium-点线面

cesium-点线面

作者: 姜治宇 | 来源:发表于2022-01-20 15:21 被阅读0次
        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)
            }
        });
    
    img.png

    相关文章

      网友评论

        本文标题:cesium-点线面

        本文链接:https://www.haomeiwen.com/subject/jqvjhrtx.html