Computation of 3DTiles transform to Heading Pitch Roll


I am consuming 3D tiles from Cesium ion server to a non JavaScript environment. To my understanding, once tileset position is set up in cesium ion asset, transform key is added to tileset.json for root. Also my concern right now is with root transform only.

I am able to get the implementation of position and scaling in JS from cesium’s NodeJS code. Here is the code for position :

What I am missing is Rotation values (which are heading, roll and pitch). For reference, these are the values I am looking to get back :

I have tried HeadingPitchRoll.fromQuaternion method as mentioned in Cesium node, but is not what Is shown in the image above. Those HPR are i guess relative to fixed frame, but not to local frame.

Can someone please help on the correct conversion (in nodejs, I can then refer to nodejs implementation and get the same in my non JS env) of those values ?

Hi there,

You’re correct about the reference frames being different. Try Transforms.fixedFrameToHeadingPitchRoll. Also I believe Cesium ion notates rotation in degrees while CesiumJS uses radians. You can convert using Math.toDegrees.

Hi @Gabby_Getz

As you mentioned, I used fixedFrameToHeadingPitchRoll to get the values and then converted the same to Degree too. Values are very close but not exactly the same. Cesium ion’s interface as shown in image above gets the exact same value. I think it might be because of floating point inaccuracy here, but how does cesium gets the exact value back ? How can I replicate the exact value ?

I have updated the code in the same gist, link here again :