一、颜色全透明
例如:设置球的基础色,默认颜色是 Cesium.Color.BLUE
// 方式一
viewer.scene.globe.baseColor = new Cesium.Color(0, 0, 0, 0);
// 方式二(推荐)
viewer.scene.globe.baseColor = Cesium.Color.TRANSPARENT;
二、颜色半透明
例如:设置球的地下色,默认是 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);
小技巧:如果 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)
三、从 CSS 颜色值转换
// Color {red: 1, green: 0, blue: 0, alpha: 1}
Cesium.Color.fromCssColorString('#ff0000')
四、其它颜色
此处 查看 Cesium.Color