Camera lookat point

Hi, I'm trying to do something straightforward, with a given lat,lng,height (the camera position), orient the camera to 'lookat' a given point; e.g. another latlng on the ground). Thought this would be simple and perhaps a bit like it is in other 3d APIS where I would position the camera in cartesian space and then construct a lookat matrix to orient the camera. Obviously things are a bit different in Cesium with polar coords but can anyone point me in the right direction? Thanks
A.

Cesium works just like the “other 3d APIS” you describe, what made you think we use polar coordinates? I think what you want is lookAtTransform, but you might also want lookAt or setView, both of which are also documented in that link.

What I'm looking for is this deprecated method 'lookAt' which apparently used to be found here: http://cesiumjs.org/releases/b26/Build/Documentation/CameraController.html

.lookAt(eye, target, up)

Similarly found here:
http://threejs.org/docs/#Reference/Cameras/Camera
https://msdn.microsoft.com/en-us/library/windows/desktop/bb281710(v=vs.85).aspx
https://www.opengl.org/sdk/docs/man2/xhtml/gluLookAt.xml
etc

I assume there's an equivalent in Cesium? Many thanks

Hi,

I’m looking for such a function as well - can anyone help ?

I have two points P1 and P2, P1 should be the camera position and I want to look at P2 with the camera. Has anyone experience how to set the parameters from lookat ?

Rüdiger

Hi @Ruediger_Brand,

The Camera in CesiumJS has a lookAt function here. It takes a target and an offset, such that it will find the target and then offset itself by the amount specified.
https://cesium.com/learn/cesiumjs/ref-doc/Camera.html#lookAt

Hope that helps!

Best,
Janine

But this doen’t work in my opinion ! What is the target and waht is the offset, if I want to set the camera to P1 - in another topic I found that the the offset should be P1-P2. but that doesn’t work.

Hi @Ruediger_Brand,

You defined P1 and P2 as follows in your last response:

I have two points P1 and P2, P1 should be the camera position and I want to look at P2 with the camera. Has anyone experience how to set the parameters from lookat ?

So given this, you actually want P2 to be the target, and P2-P1 to be the offset.

Best,
Janine

ok - i will try this again

ok - I have checked it again, it works but it changes the camera position !

so I think the solution of omar I found now is better

// 'viewer.camera.lookAt' method change camera.heading and camera.pitch