Interpolation tutorial - Add Label with elevation to billboard or rendered model

I'm new to Cesium,

I'm just trying to play a bit with the SandCastle tool: Interpolation example.

Is it possible to add a label on the tracked entity displaying the altitude or other informations? Sorry for a so generic question but I don't know really where to start.. I would like just to add an overlay box displaying the altitude when the 3d model or the billboard is clicked during the animation.

any hint on how to achieve this?

thanks,

Martino.

Hello Martino,

You can add a label to the same entity that adds the 3D model. In the interpolation example, add this code to the entity after ‘var entity = viewer.entities.add({’

label: {
    text: new Cesium.CallbackProperty(function(){
        var position = entity.position.getValue(viewer.clock.currentTime);
        var carto = viewer.scene.globe.ellipsoid.cartesianToCartographic(position);
        return 'Altitude: ' + carto.height.toFixed(3);
    }, false),
    verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
    pixelOffset: new Cesium.Cartesian3(0, -10, 0)
},

``

Best,

Hannah

Better to pass through the time parameter that is passed into the callback, rather than getting it from the viewer clock:

new Cesium.CallbackProperty(function(time, result) {

var position = entity.position.getValue(time);

var carto = viewer.scene.globe.ellipsoid.cartesianToCartographic(position);

return 'Altitude: ’ + carto.height.toFixed(3);

}, false)

Super thanks! I'll try it as soon as possible!