Adapting model orientation to the camera

This is a hard problem to solve I believe. For me at least.

I’ve slightly changed the “plane” example code in the Sandcastle, resulting in this

What I would like to achieve, is to orient the plane so that the cockpit always points towards the camera. But the plane should remain horizontal to the surface of the globe. Is that doable? Help would be deeply appreciated!

Just to confirm my understanding, do you mean the plane should be rotated clockwise or counterclockwise so that the cockpit points towards the camera, while the plane remains tangent to earth’s surface?

If that’s the case, you’ll need to update the orientation of the plane every time the camera moves. This can be accomplished by using a CallbackProperty.

The orientation should be updated by setting the “heading” in the HeadingPitchRoll object. You will need to calculate it based on the current camera position.

Just to confirm my understanding, do you mean the plane should be rotated clockwise or counterclockwise so that the cockpit points towards the camera, while the plane remains tangent to earth’s surface?

That’s correct :+1:

Thanks for the advice on using CallbackProperty and the heading, it’s really appreciated. The hardest part is calculating the updated heading based on the camera position, as you wrote. That part is too hard for me, sadly :confused:

Hopefully someone more experienced with Cesium can solve it?

Using Cartesian3.angleBetween with the current camera position and the plane position may be a good place to start! :slight_smile: