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

**URL:** <https://community.cesium.com/t/how-to-change-camera-zoom-heading-and-pitch-while-tracking-an-entity/5182>\
**Category:** CesiumJS\
**Created:** [February 19, 2017, 6:09am UTC](https://community.cesium.com/t/how-to-change-camera-zoom-heading-and-pitch-while-tracking-an-entity/5182 "2017-02-19T06:09:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qandeel\_Abbassi](https://avatars.discourse-cdn.com/v4/letter/q/d9b06d/32.png) [@Qandeel\_Abbassi](https://community.cesium.com/u/Qandeel_Abbassi)\
**Post date:** [February 19, 2017, 6:09am UTC](https://community.cesium.com/t/how-to-change-camera-zoom-heading-and-pitch-while-tracking-an-entity/5182/1 "2017-02-19T06:09:59Z")

</div>

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

viewer.trackedEntity = entity;

function tick() {

iterator++;

console.log(“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;

duration\*=1000.0;

interpolate(performance.now(),duration, geodesic);

}

function interpolate(startTime, duration, geodesic){

var now = performance.now();

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

console.log(“intr”);

var cart = geodesic.interpolateUsingFraction(t);

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

positions.push(newpos);

polyline.positions = positions;

entity.position = newpos;

if(t\<1){

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

}else{

tick();

}

}

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:

- _viewer.camera.zoomOut()_ doesn’t work
- and even if i set properties of camera using _viewer.camera.setView_ 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?
