一,颜色格式
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)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!