convertRotationFrom

@MainThread
fun convertRotationFrom(rotation: Quat, baseEntity: Entity?): Quat

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

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 baseEntity should be the parent of the entity that owns the source rotation. For example, if entityA and entityB are in different coordinate spaces, and rotationA is relative to entityA, pass entityA as baseEntity when converting rotationA into entityB's parent space.

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

Return

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

Parameters

rotation

The rotation relative to baseEntity.

baseEntity

The base entity from which the rotation will be converted. If null, the rotation is converted from the SpatialContainer where the current entity is placed.