convertTransformFrom

@MainThread
fun convertTransformFrom(transform: Transform, baseEntity: Entity?): Transform

Converts a Transform 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 transform in that entity's local coordinate space. In this case, the proper baseEntity should be the parent of the entity that owns the source transform. For example, if entityA and entityB are in different coordinate spaces, and transformA is relative to entityA, pass entityA as baseEntity when converting transformA into entityB's parent space.

entityB.components.set(TransformComponent(entityB.getParent()
!!.convertTransformFrom(transformA.position, entityA)))

Return

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

Parameters

transform

The Transform relative to baseEntity.

baseEntity

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