Hi Cesium folks,
On my quest to find a good (non-flashing) way to update an image that is overlaid atop a Cesium map I discovered the following bug.
If you set the image of an ImageMaterialProperty to a CallbackProperty that draws into a canvas and returns that canvas as the image, the image updates the first time but then never again.
Here’s a sandcastle example:
(Code)
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var rotation = Cesium.Math.toRadians(30);
function getRotationValue() {
rotation += 0.005;
return rotation;
}
function drawCanvas(time, result) {
var canvas = document.getElementById(“canvas”);
var context = canvas.getContext(‘2d’);
context.clearRect(0, 0, canvas.width, canvas.height); context.font = ‘italic 40pt Calibri’;
context.fillStyle = “white”;
context.fillText(time, 20, 100);
return canvas;
}
viewer.entities.add({
name: ‘Rotating rectangle with rotating texture coordinate’,
rectangle: {
coordinates: Cesium.Rectangle.fromDegrees(-92.0, 30.0, -76.0, 40.0),
material: new Cesium.ImageMaterialProperty({
image: new Cesium.CallbackProperty(drawCanvas, false),
transparent: true
}),
rotation: new Cesium.CallbackProperty(getRotationValue, false),
stRotation: new Cesium.CallbackProperty(getRotationValue, false)
}
});
viewer.zoomTo(viewer.entities);
(HTML)
@import url(../templates/bucket.css); #canvas { position: absolute; left: 0; top: 50px; }Loading...
When you run this you’ll see the canvas at the top, changing like mad, showing the current JulianTime for each callback, happily drawn into the canvas. Below you will see the rotating rectangle containing the canvas, suck back on the time the first callback was made.
It would be wonderful if this pathway worked. I have tried so many ways of putting time-variant images on top of Cesium and they all have drawbacks, mostly flashing. Hope you guys will consider fixing this.
Thanks a ton,
Bryan