# How to calculate the current camera "lookAt" parameter?

Dear Cesium Team,

in Cesium we can zoom to one place by using the function camera.lookAt(target, offset, eye, target, up).

My question is how to get or calculate the "lookAt" parameters (such as latitude, longitude, heading, tilt, range ...) from one arbitrary camera position? (assume the altitude value of the target object is 0)

thanks in advance

Zhihang

I look forward to an answer on this one too!

excuse me, could anyone help me to answer this question?

Here is an example of how I’ve been able to capture all the properties of a camera:

var cameraProperties = {

position: camera.position.clone(),

direction: camera.direction.clone(),

up: camera.up.clone(),

right: camera.right.clone(),

transform: camera.transform.clone(),

frustum: camera.frustum.clone()

};

You can actually store that and reset the camera to that location later.

Hi Mike, thanks very much for your response.
However, I need exactly the "LookAt" Parameters. Is it possible to derive the value of those paramters (latitude, longitude, heading, tilt, range ...) from the cameraProperties in your code?

Use what I posted before to get heading and tilt

Then a slight modification to the Google Earth Altitude example will solve your problem I believe

``````var viewer = new Cesium.Viewer('cesiumContainer');
var camera = viewer.camera;
var canvas = viewer.scene.canvas;

function cameraLookingAt() {
var ray = camera.getPickRay(new Cesium.Cartesian2(
Math.round(canvas.clientWidth / 2),
Math.round(canvas.clientHeight / 2)
));

var position = viewer.scene.globe.pick(ray, viewer.scene);
if (Cesium.defined(position)) {
var cartographic = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position);
var height = cartographic.height;
var range = Cesium.Cartesian3.distance(position, camera.position);

alert('Lat/Lon: [' +
Cesium.Math.toDegrees(cartographic.latitude).toFixed(2) + ',' +
Cesium.Math.toDegrees(cartographic.longitude).toFixed(2) + ']'+
' height: ' + height.toFixed(2) +
' range: ' + range.toFixed(2)
);
} else {
console.log('Looking at space?');
}
}
``````

``

Hi Mike,

nice code. it works and solves my problem. thank you very much.

You’re very welcome

Thanks for your replies! It was helpful to me.
But I need to make my camera fly and I am using the code below. I could get longitude, latitude and altitude from cloning the camera position. But I am stuck at finding heading and tilt from the camera parameter clones.

var coords = Cesium.Cartesian3.fromDegrees(longitude, latitude, altitude, Cesium.Ellipsoid.WGS84);

var options = {

destination: coords,

duration: 2,

orientation: {

heading: heading,

pitch: tilt,

roll: 0.3

}

};

camera_v.flyTo(options);

Any help is much appreciated!

Thanks in advance.

You can get the camera’s heading as a property of the camera: https://cesiumjs.org/Cesium/Build/Documentation/Camera.html#heading

This thread also has a code example of syncing two camera’s fully: https://groups.google.com/d/msg/cesium-dev/GNK7GYNfWNI/V_UbRAuxBAAJ