Skip to content

@modoki/engine / index / worldToLocal3D

Function: worldToLocal3D()

worldToLocal3D(entityId, worldPos, worldQuat, world?, worldScale?): WorldTransform3D

Convert a WORLD-space pose (position + quaternion + optional scale) back into an entity's LOCAL Transform by inverting its parent's world matrix: local = parentWorld⁻¹ · world. The readback half of the world-transform contract — physics (which poses bodies in world space) writes the stepped world pose back through here so the LOCAL Transform stays correct for a PARENTED body. Root entities: local == world. Returns a SHARED singleton (read immediately). Scale defaults to (1,1,1) — pass the body's world scale if it carries one.

Parameters

entityId

number

worldPos

x

number

y

number

z

number

worldQuat

w

number

x

number

y

number

z

number

world?

World = ...

worldScale?

x

number

y

number

z

number

Returns

WorldTransform3D

Built with Modoki.