How to change camera zoom, heading and pitch while tracking an entity?

I am using following code to animate a polyline and a pin on a given path:

viewer.trackedEntity = entity;

function tick() {



var strt_pos = positions[positions.length-1];

var end_pos = Cesium.Cartesian3.fromDegrees(cods[iterator][0],cods[iterator][1]);

var cart_strt_pos = Cesium.Ellipsoid.WGS84.cartesianToCartographic(strt_pos);

var cart_end_pos = Cesium.Ellipsoid.WGS84.cartesianToCartographic(end_pos);

var geodesic = new Cesium.EllipsoidGeodesic(cart_strt_pos, cart_end_pos, ellipsoid);

var duration = geodesic.surfaceDistance/800;


interpolate(,duration, geodesic);


function interpolate(startTime, duration, geodesic){

var now =;

var t = Math.min(1.0, (now - startTime) / duration);


var cart = geodesic.interpolateUsingFraction(t);

var newpos = Cesium.Ellipsoid.WGS84.cartographicToCartesian(cart);


polyline.positions = positions;

entity.position = newpos;


setTimeout(function() { interpolate(startTime, duration, geodesic); }, 16);





setTimeout(function() { tick(); }, 3000);


As you can see i have set viewer.trackedEntity=entity and enity is actually my pin (Billboard), therefore my camera is following it correctly. But the problem is that i want to change zoom, heading, and pitch of the camera at my wish. I tried different solution but to no avail. The problems i faced are:

  • doesn’t work
  • and even if i set properties of camera using prior to calling tick() function, the camera resets itself to default tracking orientation.
    How should I change camera zoom, heading, pitch and may be roll while tracking entity?