zfxcms ^回到顶部

您的当前位置:首页 > web资讯 > 绘制对象-Entity方式

绘制对象-Entity方式

所属分类:   2019-04-23 10:31:24  编辑:admin  浏览次数 887 次

查看第一个例子:
    viewer.entities.add({
        position : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
        point : {
            pixelSize : 10,
            color : Cesium.Color.YELLOW
        }
    });
可以看到entity通过viewer中的entities加载到场景中,entities是entity的集合对象。这是一个最简单的示例,在场景中加一个点,可以看到需要以下属性:
position :点在场景中位置
point:指明该entity对象为point类型,其中大小为10、颜色为黄色。
//box
    viewer.entities.add({
        name: 'Blue box',
        position: Cesium.Cartesian3.fromDegrees(homePOsition[0], homePOsition[1], 0),
        box: {
            dimensions: new Cesium.Cartesian3(400000.0, 300000.0, 500000.0),
            material: Cesium.Color.BLUE
        }
    });
//Circle
    viewer.entities.add({
        position: Cesium.Cartesian3.fromDegrees(111.0, 40.0, 150000.0),
        name: 'Green circle at height',
        ellipse: {
            semiMinorAxis: 300000.0,
            semiMajorAxis: 300000.0,
            height: 200000.0,
            material: Cesium.Color.GREEN
        }
    });
//Ellipse
    viewer.entities.add({
        position: Cesium.Cartesian3.fromDegrees(103.0, 40.0),
        name: 'Red ellipse on surface with outline',
        ellipse: {
            semiMinorAxis: 250000.0,
            semiMajorAxis: 400000.0,
            material: Cesium.Color.RED.withAlpha(0.5),
            outline: true,
            outlineColor: Cesium.Color.RED
        }
    });
        //Corridor
    viewer.entities.add({
        name: 'Red corridor on surface with rounded corners and outline',
        corridor: {
            positions: Cesium.Cartesian3.fromDegreesArray([
            100.0, 40.0,
            105.0, 40.0,
            105.0, 35.0
            ]),
            width: 200000.0,
            material: Cesium.Color.RED.withAlpha(0.5),
            outline: true,
            outlineColor: Cesium.Color.RED
        }
    });
    //Cylinder
    viewer.entities.add({
        name: 'Green cylinder with black outline',
        position: Cesium.Cartesian3.fromDegrees(100.0, 40.0, 200000.0),
        cylinder: {
            length: 400000.0,
            topRadius: 200000.0,
            bottomRadius: 200000.0,
            material: Cesium.Color.GREEN.withAlpha(0.5),
            outline: true,
            outlineColor: Cesium.Color.DARK_GREEN
        }
    });
    //Cone
    viewer.entities.add({
        name: 'Red cone',
        position: Cesium.Cartesian3.fromDegrees(105.0, 40.0, 200000.0),
        cylinder: {
            length: 400000.0,
            topRadius: 0.0,
            bottomRadius: 200000.0,
            material: Cesium.Color.RED
        }
    });
    //Polygon 
    viewer.entities.add({
        name: 'Red polygon on surface',
        polygon: {
            hierarchy: Cesium.Cartesian3.fromDegreesArray([115.0, 37.0,
            115.0, 32.0,
            107.0, 33.0,
            102.0, 31.0,
            102.0, 35.0]),
            material: Cesium.Color.RED
        }
    });
    //polyline
    viewer.entities.add({
        name: 'Red line on the surface',
        polyline: {
            positions: Cesium.Cartesian3.fromDegreesArray([75, 35,
            125, 35]),
            width: 5,
            material: Cesium.Color.RED
        }
    });
    //polylineVolume
    function computeCircle(radius) {
        var positions = [];
        for (var i = 0; i < 360; i++) {
            var radians = Cesium.Math.toRadians(i);
            positions.push(new Cesium.Cartesian2(radius * Math.cos(radians), radius * Math.sin(radians)));
        }
        return positions;
    }
    viewer.entities.add({
        name: 'Red tube with rounded corners',
        polylineVolume: {
            positions: Cesium.Cartesian3.fromDegreesArray([85.0, 32.0,
            85.0, 36.0,
            89.0, 36.0]),
            shape: computeCircle(60000.0),
            material: Cesium.Color.RED
        }
    });
        //rectangle
    viewer.entities.add({
        name: 'Red translucent rectangle with outline',
        rectangle: {
            coordinates: Cesium.Rectangle.fromDegrees(80.0, 20.0, 110.0, 25.0),
            material: Cesium.Color.RED.withAlpha(0.5),
            outline: true,
            outlineColor: Cesium.Color.RED
        }
    });
        //Sphere
    viewer.entities.add({
        name: 'Red sphere with black outline',
        position: Cesium.Cartesian3.fromDegrees(107.0, 40.0, 300000.0),
        ellipsoid: {
            radii: new Cesium.Cartesian3(300000.0, 300000.0, 300000.0),
            material: Cesium.Color.RED.withAlpha(0.5),
            outline: true,
            outlineColor: Cesium.Color.BLACK
        }
    });
        //ellipsoid
    viewer.entities.add({
        name: 'Blue ellipsoid',
        position: Cesium.Cartesian3.fromDegrees(114.0, 40.0, 300000.0),
        ellipsoid: {
            radii: new Cesium.Cartesian3(200000.0, 200000.0, 300000.0),
            material: Cesium.Color.BLUE
        }
    });
        //wall
    viewer.entities.add({
        name: 'Green wall from surface with outline',
        wall: {
            positions: Cesium.Cartesian3.fromDegreesArrayHeights([107.0, 43.0, 100000.0,
            97.0, 43.0, 100000.0,
            97.0, 40.0, 100000.0,
            107.0, 40.0, 100000.0,
            107.0, 43.0, 100000.0]),
            material: Cesium.Color.GREEN
        }
    });


Web文章检索

Web文章目录