Skip to main content

Interface: TransformManager

TransformManager is used to add transform components to entities.

A Transform component gives an entity a position and orientation in space in the coordinate space of its parent transform. The TransformManager takes care of computing the world-space transform of each component (i.e. its transform relative to the root).

Extends​

  • PointerHolder

Properties​

isValid​

readonly isValid: boolean

Get if the refernce to the native pointer is still valid and strong.

If this is false, this object has been manually released with release() and all other methods on this object will throw an Error.

Inherited from​

PointerHolder.isValid

Defined in​

src/types/PointerHolder.ts:37

Methods​

commitLocalTransformTransaction()​

commitLocalTransformTransaction(): void

Commits the currently open local transform transaction. When this returns, calls to getWorldTransform() will return the proper value.

Returns​

void

Attention​

failing to call this method when done updating the local transform will cause a lot of rendering problems. The system never closes the transaction automatically.

Note​

If the local transform transaction is not open, this is a no-op.

(), ()

Defined in​

src/types/TransformManager.ts:83


createIdentityMatrix()​

createIdentityMatrix(): Mat4

Creates a new identity matrix.

Returns​

Mat4

Defined in​

src/types/TransformManager.ts:99


getTransform()​

getTransform(entity): Mat4

Returns the local transform of a transform component.

Parameters​

• entity: Entity

Returns​

Mat4

The local transform of the component (i.e. relative to the parent). This always returns the value set by setTransform(). ()

Defined in​

src/types/TransformManager.ts:46


getWorldTransform()​

getWorldTransform(entity): Mat4

Return the world transform of a transform component.

Parameters​

• entity: Entity

Returns​

Mat4

The world transform of the component (i.e. relative to the root). This is the composition of this component's local transform with its parent's world transform. ()

Defined in​

src/types/TransformManager.ts:55


openLocalTransformTransaction()​

openLocalTransformTransaction(): void

Opens a local transform transaction. During a transaction, getWorldTransform() can return an invalid transform until commitLocalTransformTransaction() is called. However, setTransform() will perform significantly better and in constant time.

This is useful when updating many transforms and the transform hierarchy is deep (say more than 4 or 5 levels).

Returns​

void

Note​

If the local transform transaction is already open, this is a no-op.

(), ()

Defined in​

src/types/TransformManager.ts:69


release()​

release(): void

Manually release this reference to the native pointer. This will ensure that JS will no longer hold a strong reference, and memory can be safely cleaned up.

If the native pointer is still referenced elsewhere in native code, the underlying memory will not be deleted unless the other references are also released.

If this is not called, the memory will only be cleaned once the JS gabage collector decides to delete this object, which might be at any point in the future.

Calling release() is not required as the GC will destroy this object eventually anyways, but it is recommended to optimize memory usage.

After manually releasing a pointer, all future methods on this object will throw an Error.

Returns​

void

Inherited from​

PointerHolder.release

Defined in​

src/types/PointerHolder.ts:30


setEntityPosition()​

setEntityPosition(entity, position, multiplyCurrent): void

Sets the position of an entity.

Parameters​

• entity: Entity

• position: Float3

• multiplyCurrent: boolean

If true, the new position will be multiplied with the current transform.

Returns​

void

Defined in​

src/types/TransformManager.ts:111


setEntityRotation()​

setEntityRotation(entity, angleRadians, axis, multiplyCurrent): void

Sets the rotation of an entity.

Parameters​

• entity: Entity

• angleRadians: number

• axis: Float3

• multiplyCurrent: boolean

If true, the new rotation will be multiplied with the current transform.

Returns​

void

Defined in​

src/types/TransformManager.ts:117


setEntityScale()​

setEntityScale(entity, scale, multiplyCurrent): void

Sets the scale of an entity.

Parameters​

• entity: Entity

• scale: Float3

• multiplyCurrent: boolean

If true, the new scale will be multiplied with the current transform.

Returns​

void

Defined in​

src/types/TransformManager.ts:123


setTransform()​

setTransform(entity, transform): void

Sets a local transform of a transform component.

Parameters​

• entity: Entity

• transform: Mat4

Returns​

void

Attention​

This operation can be slow if the hierarchy of transform is too deep, and this will be particularly bad when updating a lot of transforms. In that case, consider using openLocalTransformTransaction() / commitLocalTransformTransaction().

Defined in​

src/types/TransformManager.ts:94


transformToUnitCube()​

transformToUnitCube(rootEntity, boundingBox): void

Transforms the given entity to fit into a unit cube at the origin (0,0,0).

Parameters​

• rootEntity: Entity

• boundingBox: AABB

Returns​

void

Defined in​

src/types/TransformManager.ts:105


updateTransformByRigidBody()​

updateTransformByRigidBody(entity, rigidBody): void

Updates the transform of an entity based on the rigid body's transform.

Parameters​

• entity: Entity

• rigidBody: RigidBody

Returns​

void

Defined in​

src/types/TransformManager.ts:128