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)
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?
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?');
}
}
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);