How to move camera in the direction of moving entity ignoring minor position changes?

I have been using "viewer.trackedEntity = entity" till now to make the camera follow a moving entity which follows a particular route/polyline. It works fine as long the route is smooth. However, when there are sharp frequent changes in route the camera starts to give jerky feeling which ruins the look and feel. To avoid that jerky feeling i am trying to implement my own camera animation logic and here's what I am trying to achieve:
1) To move the camera only along the major direction vector. To understand this better you can see this drawing:
2) To rotate the camera to align with current segment if there is major heading change.

Can someone point me in the right direction? What camera functions will come in handy while developing this kind of animation? If you have any rough sketch about how this can be achieved then it would be really helpful. Thanks!

Hi John,

A good follow camera is something we’ve wanted to include as part of base Cesium, see Issue #5241, but unfortunately we haven’t have the time to tackle it. I’ll bump the issue with this requests. In the meantime, you may need to write your own, and there’s a minimal example in that linked issue. Take a look at the Camera Tutorial for how to get started modifying the camera yourself.