一,颜色格式 
const line2= new Cesium.Primitive({
            geometryInstances: new Cesium.GeometryInstance({
                geometry: new Cesium.PolylineGeometry({
                    // positions: Cesium.Cartesian3.fromDegreesArrayHeights(positionArray),
                    positions: Cesium.Cartesian3.fromDegreesArrayHeights([positions[positions.length-2].lon,positions[positions.length-2].lat,positions[positions.length-2].height,
                        positions[positions.length-1].lon,positions[positions.length-1].lat,positions[positions.length-1].height]),
                    width: 5.0,
                    vertexFormat: Cesium.PolylineColorAppearance.VERTEX_FORMAT,
                    arcType: Cesium.ArcType.NONE,
                }),
                attributes: {
                    // color: Cesium.ColorGeometryInstanceAttribute.fromColor(
                    //     Cesium.Color.BLUE
                    // ),
      //rgb/255,转换
                    // color: Cesium.ColorGeometryInstanceAttribute.fromColor(
                    //     new Cesium.Color(0, 1, 0.0, 0.2)
                    //   ),
                    //   color: Cesium.ColorGeometryInstanceAttribute.fromColor(
                    //     Cesium.Color.fromCssColorString('#ffff00')
                    // ),
      //rgba,a也是0到255
                    // color: Cesium.ColorGeometryInstanceAttribute.fromColor(
                    //     Cesium.Color.fromBytes(255, 0, 0, 200)
                    // ),
                    color: Cesium.ColorGeometryInstanceAttribute.fromColor(
                        Cesium.Color.fromCssColorString( "rgba(255, 255, 255, 0.75)")
                    ),
                   
                },
            }),
            appearance: new Cesium.PolylineColorAppearance(),
        })

 二:

1,设置球的基础色,默认颜色是  Cesium.Color.BLUE

// 方式一
viewer.scene.globe.baseColor = new Cesium.Color(0, 0, 0, 0);

// 方式二(推荐)
viewer.scene.globe.baseColor = Cesium.Color.TRANSPARENT;

2,设置球的地下色,默认是 Cesium.Color.BLACK

// 方式一
viewer.scene.globe.undergroundColor= new Cesium.Color(0, 0, 0, 0.5);

// 方式二(推荐)
viewer.scene.globe.undergroundColor= Cesium.Color.BLACK.withAlpha(0.5);

3,如果 Cesium.LabelGraphics 对象,改变字体颜色的透明度,

通过 getValue 方法获取颜色,返回的就是 Cesium.Color 对象。但请看第 6 行则可以直接设置,这是因为 undergroundColor 返回的就是 Cesium.Color 对象。

// 设置字体填充透明度
label.fillColor = label.fillColor.getValue().withAlpha(a0.5);
// 设置字体外边框透明度
label.outlineColor= label.outlineColor.getValue().withAlpha(a0.5);
// 设置球地下颜色的透明度
globe.viewer.scene.globe.undergroundColor.withAlpha(0.5)

 

Posted on 2023-02-23 17:23  博客sl  阅读(862)  评论(0编辑  收藏  举报