The issue of rotation conversion

Hello, how can I convert rotation in Unity to rotation in Cesium? How do rotations in Cesium and Unity be converted?

Hi @liuwenkai,

it depends on what form you want your rotations in, and what you’re trying to rotate. Currently, there are two methods in CesiumGeoreference that convert a double3 direction between Earth-Centered Earth-Fixed (ECEF) and Unity coordinates:

  • TransformUnityDirectionToEarthCenteredEarthFixed
  • TransformEarthCenteredEarthFixedDirectionToUnity

Additionally, a CesiumGlobeAnchor can interpret an object’s local rotation relative to the globe. There is a rotationEastUpNorth property on a CesiumGlobeAnchor that lets you retrieve the rotation in East-Up-North coordinates. There is also a rotationGlobeFixed property that lets you retrieve the rotation from the game object’s local coordinate system to the ECEF coordinate system.

How to achieve the same effect as the Rotation (East Up North) attribute in the CesiumGlobeAnchor script?

Assuming you know the longitude, latitude, and height of a game object, convert it into the coordinates used by Unity. I want to set the rotation of this game object, using Unity’s Rotation to achieve the same effect as adding the Rotation (East Up North) attribute in the CesiumGlobeAnchor script. Assuming that the Rotation (East Up North) in the CesiumGlobeAnchor script is (45,10,0), how can I convert (45,10,0) to the Rotation in Unity?

There’s no simple way to do what you’re describing without using a GlobeAnchor. You could trace through the source to see how the math works:

If you can’t attach a globe anchor to your object for some reason (we’d be interested in learning why not), you could create a temporary GameObject with no visual representation at the same location with a CesiumGlobeAnchor, set its rotationEastUpNorth, then apply the Transform to the original game object.