flyTo one lat/long and lookAt another lat/long

I’ve seen this question asked several times before on this list, and haven’t found an answer.

How do move the camera to a position above a certain lat/long, but look at some other (nearby) lat/long?

I can use:

viewer.camera.flyTo({
destination: Cesium.Ellipsoid.WGS84.cartographicToCartesian(new Cesium.Cartographic(longitude, latitude, height));
})

``

but no matter what I put in for the orientation parameter, the camera seems to rotate inexplicably.

Alternatively (?) I thought I could use:

var offsetVector = new Cesium.Cartesian3(0.0, 0.0, 0.0);
viewer.lookAt(
Cesium.Cartesian3.fromDegrees(longitudeDegrees, latitudeDegrees), offSetVector
);

``

but how would one reasonably calculate the offset vector?

Am I missing something simple?

Hello,

Using camera.lookAt won’t produce a camera flight, but it will let you easily set the camera to look at a position.

The offset parameter can either be a Cartesian3, which specifies the offset in meters, or a HeadingPitchRange, which defines heading and pitch in radians and range in meters.

If you know the Cartesian3 position where the camera should be and the Cartesian3 position of the object at which you are looking, the offset vector should be one of these points subtracted from the other (I believe the camera point - lookAt point)

Best,

Hannah

Hello Hannah,

I tried this, but it won’t work - do you have any tips ?

Rüdiger