I would like an object that rotates to face the camera but does not tilt. I’m using a billboard to place an image of a flag at different locations. I want the flag to rotate to face the camera, but I don’t want the flag to tilt to face the camera. I’d like the flag to always remain perpendicular to the earth’s surface.
I’ve experimented with the alignedAxis property, but I haven’t found a solution with this approach.
Is there a way to prevent billboards from tilting (or locking them so that they are always perpendicular to the earth’s surface)?
Or is there another object I should use for this that will rotate to face the camera?
The alternative solution would be to use a rectangle or polygon entity and apply the image as a material. Each time the camera moves, you can detect it using moveEnd (Camera - Cesium Documentation) event and adjust the heading of the entity so that it faces the camera. Here is a code sample:
// get the camera's heading and add 180 degrees so that the final heading is facing the camera
var heading = scene.camera.heading + CesiumMath.PI_OVER_TWO;
var pitch = 0;
var hpr = new HeadingPitchRoll(heading, pitch, 0);
var orientation = Transforms.headingPitchRollQuaternion(
position, // current position of entity
hpr
);
entity.orientation = hpr;