API/core/Transform/

Transform

Used to implement transformation related functions.

Hierarchy: Component

constructor 

new Transform(entity: Entity)

Parameters

  • entity

instanceId ReadOnly

instanceId: number = ++EngineObject._instanceIdCounter

Engine unique id.

destroyed 

get destroyed(): boolean

Indicates whether the component is destroyed.

enabled 

get enabled(): boolean

Indicates whether the component is enabled.

set enabled(boolean): void

engine 

get engine(): Engine

The engine which the component's entity belongs to.

entity 

get entity(): Entity

The entitiy which the component belongs to.

localMatrix 

get localMatrix(): Matrix

Local matrix.

remarksNeed to re-assign after modification to ensure that the modification takes effect.

set localMatrix(Matrix): void

lossyWorldScale 

get lossyWorldScale(): Vector3

Local lossy scaling.

remarksThe value obtained may not be correct under certain conditions(for example, the parent node has scaling, and the child node has a rotation), the scaling will be tilted. Vector3 cannot be used to correctly represent the scaling. Must use Matrix3x3.

position 

get position(): Vector3

Local position.

remarksNeed to re-assign after modification to ensure that the modification takes effect.

set position(Vector3): void

rotation 

get rotation(): Vector3

Local rotation, defining the rotation value in degrees. Rotations are performed around the Y axis, the X axis, and the Z axis, in that order.

remarksNeed to re-assign after modification to ensure that the modification takes effect.

set rotation(Vector3): void

rotationQuaternion 

get rotationQuaternion(): Quaternion

Local rotaion, defining the rotation by using a unit quaternion.

remarksNeed to re-assign after modification to ensure that the modification takes effect.

set rotationQuaternion(Quaternion): void

scale 

get scale(): Vector3

Local scaling.

remarksNeed to re-assign after modification to ensure that the modification takes effect.

set scale(Vector3): void

scene 

get scene(): Scene

The scene which the component's entity belongs to.

worldMatrix 

get worldMatrix(): Matrix

World matrix.

remarksNeed to re-assign after modification to ensure that the modification takes effect.

set worldMatrix(Matrix): void

worldPosition 

get worldPosition(): Vector3

World position.

remarksNeed to re-assign after modification to ensure that the modification takes effect.

set worldPosition(Vector3): void

worldRotation 

get worldRotation(): Vector3

World rotation, defining the rotation value in degrees. Rotations are performed around the Y axis, the X axis, and the Z axis, in that order.

remarksNeed to re-assign after modification to ensure that the modification takes effect.

set worldRotation(Vector3): void

worldRotationQuaternion 

get worldRotationQuaternion(): Quaternion

World rotaion, defining the rotation by using a unit quaternion.

remarksNeed to re-assign after modification to ensure that the modification takes effect.

set worldRotationQuaternion(Quaternion): void

destroy 

destroy(): void

Destory this instance.

getWorldForward 

getWorldForward(forward: Vector3): Vector3

Get the forward direction in world space.

Parameters

  • forward

    Forward vector

Returns

Forward vector

getWorldRight 

getWorldRight(right: Vector3): Vector3

Get the right direction in world space.

Parameters

  • right

    Right vector

Returns

Right vector

getWorldUp 

getWorldUp(up: Vector3): Vector3

Get the up direction in world space.

Parameters

  • up

    Up vector

Returns

Up vector

lookAt 

lookAt(worldPosition: Vector3, worldUp: Vector3): void

Rotate and ensure that the world front vector points to the target world position.

Parameters

  • worldPosition

    Target world position

  • optionalworldUp

    Up direciton in world space, defalut is Vector3(0, 1, 0)

registerWorldChangeFlag 

registerWorldChangeFlag(): UpdateFlag

Register world transform change flag.

Returns

Change flag

rotate 

rotate(rotation: Vector3, relativeToLocal: boolean): void

Rotate around the passed Vector3.

Parameters

  • rotation

    Euler angle in degrees

  • optionalrelativeToLocal

    Relative to local space

rotate(x: number, y: number, z: number, relativeToLocal: boolean): void

Rotate around the passed Vector3.

Parameters

  • x

    Rotation along x axis, in degrees

  • y

    Rotation along y axis, in degrees

  • z

    Rotation along z axis, in degrees

  • optionalrelativeToLocal

    Relative to local space

rotateByAxis 

rotateByAxis(axis: Vector3, angle: number, relativeToLocal: boolean): void

Rotate around the specified axis according to the specified angle.

Parameters

  • axis

    Rotate axis

  • angle

    Rotate angle in degrees

  • relativeToLocal

    Relative to local space

setPosition 

setPosition(x: number, y: number, z: number): void

Set local position by X, Y, Z value.

Parameters

  • x

    X coordinate

  • y

    Y coordinate

  • z

    Z coordinate

setRotation 

setRotation(x: number, y: number, z: number): void

Set local rotaion by the X, Y, Z components of the euler angle, unit in degrees. Rotations are performed around the Y axis, the X axis, and the Z axis, in that order.

Parameters

  • x

    The angle of rotation around the X axis

  • y

    The angle of rotation around the Y axis

  • z

    The angle of rotation around the Z axis

setRotationQuaternion 

setRotationQuaternion(x: number, y: number, z: number, w: number): void

Set local rotaion by the X, Y, Z, and W components of the quaternion.

Parameters

  • x

    X component of quaternion

  • y

    Y component of quaternion

  • z

    Z component of quaternion

  • w

    W component of quaternion

setScale 

setScale(x: number, y: number, z: number): void

Set local scaling by scaling values along X, Y, Z axis.

Parameters

  • x

    Scaling along X axis

  • y

    Scaling along Y axis

  • z

    Scaling along Z axis

setWorldPosition 

setWorldPosition(x: number, y: number, z: number): void

Set world position by X, Y, Z value.

Parameters

  • x

    X coordinate

  • y

    Y coordinate

  • z

    Z coordinate

setWorldRotation 

setWorldRotation(x: number, y: number, z: number): void

Set world rotaion by the X, Y, Z components of the euler angle, unit in degrees, Yaw/Pitch/Roll sequence.

Parameters

  • x

    The angle of rotation around the X axis

  • y

    The angle of rotation around the Y axis

  • z

    The angle of rotation around the Z axis

setWorldRotationQuaternion 

setWorldRotationQuaternion(x: number, y: number, z: number, w: number): void

Set local rotaion by the X, Y, Z, and W components of the quaternion.

Parameters

  • x

    X component of quaternion

  • y

    Y component of quaternion

  • z

    Z component of quaternion

  • w

    W component of quaternion

translate 

translate(translation: Vector3, relativeToLocal: boolean): void

Translate along the passed Vector3.

Parameters

  • translation

    Direction and distance of translation

  • optionalrelativeToLocal

    Relative to local space

translate(x: number, y: number, z: number, relativeToLocal: boolean): void

Translate along the passed X, Y, Z value.

Parameters

  • x

    Translate direction and distance along x axis

  • y

    Translate direction and distance along y axis

  • z

    Translate direction and distance along z axis

  • optionalrelativeToLocal

    Relative to local space