How make camera follow tracked entity from behind?

I want make path for camera to follow. I was able to do it and now I have this code:

var viewer = new Cesium.Viewer(‘cesiumContainer’, {

infoBox: false, //Disable InfoBox widget

selectionIndicator: false, //Disable selection indicator

shouldAnimate: true, // Enable animations

terrainProvider: Cesium.createWorldTerrain()

});

var startTime = Cesium.JulianDate.fromDate(new Date());

viewer.clock.startTime = startTime.clone();

viewer.clock.currentTime = startTime.clone();

viewer.clock.multiplier = 1;

var positions = [];

Sandcastle.addDefaultToolbarButton(‘Add location’, function() {

var position = viewer.scene.camera.position;

positions.push(position.clone());

There is an open feature request for having a built-in way to have a camera follow an entity like this: https://github.com/AnalyticalGraphicsInc/cesium/issues/5241

To implement this yourself you’d need to run a camera update function every frame to get the entity’s orientation and set the camera to that orientation (or smoothly tween it if needed). This thread has some sample code for how to get the entity’s orientation: https://groups.google.com/forum/#!msg/cesium-dev/xPOMVgEbids/VlwQuis3CAAJ