How do you apply an Entity rotation correctly


So I have a simple problem, but it takes me ages to do. I know what I need to do theorically, but not mathematically with Cesium.

I have a airplane in the air at a position P and a rotation based on North East R

I want two represent this airplane using a Entity on a 2d map A using billboard 2d (that always view from top and fixed to north) with the correct rotation, AND on a 3d map B with the correct orientation and position.

in 2D since my camera look always from the top with the default rotation being already north), it is very easy,

const currentRotationInRadian = -0.179
const entity = viewer.entities.add({
    billboard: {
      rotation:  Cesium.Math.toRadians(currentRotationInRadian),
      image: "../images/Cesium_Logo_overlay.png",


In 3D I am struggling a lot to understand how do I make a rotation based on the NORTH/EAST axis.

right now I do a patchy solution where to get North, I remove 90 degree

const currentRotationInRadian = -0.179
    var cart = new Cesium.Cartographic(2.378107989069052, 0.633483064694365, 88.04466);
    var position = Cesium.Ellipsoid.WGS84.cartographicToCartesian(cart);
    var orientation = Cesium.Transforms.headingPitchRollQuaternion(
      new Cesium.HeadingPitchRoll(
         Cesium.Math.toRadians(currentRotationInRadian) - Cesium.Math.PI_OVER_TWO,


but this will not work everywhere in the globe I guess. I do not understand how I can create a referenceFrame from my position to the north/east, and then apply to that frame (that is usually a matrix) a simple headingPitchRoll rotation.

I tried to check like this => Cesium Sandcastle but this use a modelMatrix that is not available in entity, so I need a correct computed quaternion if I want to use entity