I’ve have a Cesium map where I loaded some data from a GeoJsonDataSource
.
For every shape loaded, I’m applying the following:
const loaded = await datasource.load(figure, {
stroke: Cesium.Color.LIGHTBLUE,
fill: Cesium.Color.RED.withAlpha(0.5),
strokeWidth: 3,
});
Later in the application, I want to change the color of the shapes based on some inputs (as an example: when hovering on the shape).
The only (TS friendly) way of doing this I found is like the following:
const currentColor = entity.polygon.material as Cesium.ColorMaterialProperty;
const color = currentColor.color.getValue(Cesium.JulianDate.now()) as Cesium.Color;
color.alpha = 0.8;
entity.polygon.material = new Cesium.ColorMaterialProperty(color);
It works, but there is a “blink effect” which is very annoying: the shape with the initial color disappear for a moment, then it’s replaced by a new one with the new color.
It seems like that the whole feature is repainted from scratch.
I’m wondering what I’m doing wrong. Where I can find an example on how to do this in a performant way? The only similar example I found is in this discussion, but API seems not compatible.