Hi there! Thank you so much for Cesium. I’m trying to use a CallbackProperty with the eyeOffset of a billboard. The following code does pretty much what I want in Sandcastle. (It’s just an example to convey the idea – I’m not actually using eyeOffset to make the billboard appear and disappear; I’m keeping the billboard always visible above the terrain, per Matthew Amanto’s suggestion in the second reply to this post. But I didn’t want to clutter up my Sandcastle example with code to make the billboard click-and-draggable, when that’s not quite my issue.)
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var eyeCallback = new Cesium.CallbackProperty(function(time, result) {
var s = Math.floor(time.secondsOfDay) % 2;
if (s) {
return new Cesium.Cartesian3(0, 0, -10);
} else {
return new Cesium.Cartesian3(0, 0, -1000000000000000000000000);
}
}, false);
var bill = viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
billboard : {
image : ‘…/images/Cesium_Logo_overlay.png’,
eyeOffset: eyeCallback
},
});
``
The problem I’ve encountered is that my billboards must be in a BillboardCollection, and I can’t figure out how to get the CallbackProperty to work in this case:
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var eyeCallback = new Cesium.CallbackProperty(function(time, result) { var s = Math.floor(time.secondsOfDay) % 2; if (s) { return new Cesium.Cartesian3(0, 0, -10); } else { return new Cesium.Cartesian3(0, 0, -1000000000000000000000000); } }, false);
var collection = new Cesium.BillboardCollection();
var bill = collection.add({
position : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
image : ‘…/images/Cesium_Logo_overlay.png’,
eyeOffset: eyeCallback
});
viewer.scene.primitives.add(collection);
``
I can modify the eyeOffset property here by hand (setting eyeOffset :
new Cesium.Cartesian3(0, 0, -1000000000000000000000000)
makes it disappear behind the camera, as it should), but with the code as-is, eyeCallback never gets called at all. Any thoughts? I feel as though I must be missing something obvious… The solution I’ve hacked together for now is just a setInterval function that updates the eyeOffset every interval based on the current camera and billboard positions. This works, but it’s flickery, and just feels messy.
I’m using Cesium version 1.15 (sorry, haha! To be updated soon, I think. Could this be the problem?) with Firefox.