Is there a way to specify the color of an ellipsoid in CZML? I've tried different snippets, some work and some don't:
let redEllipsoid = viewer.entities.add({
"name": "red 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.RED.withAlpha(0.5),
"outline": true,
"outlineColor": Cesium.Color.BLACK
}
});
Another working snippet is:
let redEllipsoid = viewer.entities.add({
"name": "red ellipsoid",
"position": {
x: -2083516.9683773473,
y: -4679655.730028949,
z: 4270821.855106338
},
"ellipsoid": {
"radii": {
x: 200000,
y: 200000,
z: 300000
},
"material": Cesium.Color.RED.withAlpha(0.5),
"outline": true,
"outlineColor": {
red: 0,
green: 0,
blue: 0,
alpha: 1
}
}
});
Unfortunately, these following snippets do not work and result in an ellipsoid with the default white color:
let redEllipsoid = viewer.entities.add({
"name": "red ellipsoid",
"position": {
x: -2083516.9683773473,
y: -4679655.730028949,
z: 4270821.855106338
},
"ellipsoid": {
"radii": {
x: 200000,
y: 200000,
z: 300000
},
"material": {
"solidColor": {
"color": {
"rgba": [1, 0, 0, 0.5]
}
}
},
"outline": true,
"outlineColor": {
red: 0,
green: 0,
blue: 0,
alpha: 1
}
}
});
I'm confused by this issue as well, especially since entering Cesium.Color.RED.withAlpha(0.5)
into the console after Cesium has loaded returns
ne {red: 1, green: 0, blue: 0, alpha: 0.5}
. It seems like using the static member should be sufficient...
You can refer to the CZML documentation for more information on the "material"
type. It appears that specifying it via CZML might require additional processing instead of being set directly.
For detailed answers, you can check out the Ellipsoid
page, Material
page, SolidColorMaterial
page, Color
page, and optionally the RgbaValue
page within the CZML documentation.