convertRotationTo

@MainThread
fun convertRotationTo(rotation: Quat, targetEntity: Entity?): Quat

Converts a rotation relative to the current entity to a targetEntity.

Attention: "relative to" an Entity is different from "in the local coordinate system/space of" the Entity. You may use the converted result to place an entity when you need a rotation in that entity's local coordinate space. In this case, the proper targetEntity should be the parent of the entity to place. For example, if entityA and entityB are in different coordinate spaces, and rotationA is relative to entityA, pass entityB's parent as targetEntity when placing entityB with rotationA.

entityB.components.get<TransformComponent>()?.quaternion = entityA.convertRotationTo(rotationA,
entityB.getParent())

Return

The converted rotation relative to targetEntity, or relative to the current entity's SpatialContainer when targetEntity is null.

Parameters

rotation

The rotation relative to the current entity.

targetEntity

The target entity to which the rotation will be converted. If null, the rotation is converted relative to the SpatialContainer where the current entity is placed.