Tracked entity - camera direction

I’d like to follow an entity as in this example (when you click on ‘follow aircraft’):

The difference is that I know all of the x,y,z coordinates (of the polyline above the ground) beforehand and I would like the camera to always look in the direction of the next point - as if from the position of the pilot who is piloting this aircraft. I don’t even need a visible aircraft or entity, just want to fly along this polyline facing the next point. I have more troubles implementing this than I expected. Is there any obvious solution that I have missed?

This is a little bit tricky because CesiumJS doesn’t have a “change camera direction without changing camera position” function. The closest thing is camera.lookAtTransform which will allow you to set the camera direction and position at the same time.

One option is to have an entity following the path and then every frame update the camera position to be at the entity and then look in the direction you want. Here’s a Sandcastle example that will do this and keep the camera fixed at the cylinder in the middle, but if you have a way of computing what the next point is given the current time or position, then you should easily be able to swap that in with the cylinder position in this code.

Hope this helps! What kind of project are you working on?