Skip to content
Transform

[Basic Type](../groups/Basic Type.Basic Type.md) / Transform

Transform Class

3D transformation


Transform Composed of translation, rotation, and scaling.

Translation is used to determine the position of the object, rotation is used to determine the orientation of the object, and scale is used to determine the size of the object.

Apply position vector transformation in the following order: scaling ->rotation ->translation, and apply direction vector transformation in the following order: scaling ->rotation

Table of contents

Accessors

position(): Vector
Get position information
rotation(): Rotation
Obtain rotation information
scale(): Vector
Get scale information
identity(): Transform
Get a unit Transform

Methods

clone(): Transform other
Clone a new Transform
fromString(str: string, outer?: Transform): Transform other
Create a Transform from a string
getForwardVector
:-----
getRightVector(): Vector other
Obtain the right vector of Transform
getUpVector(): Vector other
Obtain the upward vector of Transform
inverseTransformDirection(location: Vector): Vector other
Transform from global direction to local direction
inverseTransformPosition(location: Vector): Vector other
Convert world coordinates to local coordinates
lookAt(target: Vector): void other
Facing the direction of target
rotate(axis: Vector, angle: number): void other
Rotate around the specified axis
toString(): string other
Output as a formatted string
transformDirection(location: Vector): Vector other
Transform local direction into world direction
transformPosition(location: Vector): Vector other
Convert local coordinates to world coordinates
fromString(str: string, outer?: Transform): Transform other
Create a Transform from a string

Return a new Transform

new Transform(location, rotation, scale)

Set the Transform with the given Position, Rotation, or Scale values

Parameters

location VectorUsage: Coordinate information
rotation RotationUsage: Rotation information
scale VectorUsage: Zoom information

new Transform(newTransform)

Copy the given Transform

Parameters

newTransform TransformTransform object

Accessors

position

get position(): Vector

set position(v): void

Get position information

Returns

Vector

Set position information

Parameters

vVector

rotation

get rotation(): Rotation

set rotation(v): void

Obtain rotation information

Returns

Rotation

Set rotation information

Parameters

vRotation

scale

get scale(): Vector

set scale(v): void

Get scale information

Returns

Vector

Set scale information

Parameters

vVector

identity

Static get identity(): Transform

Get a unit Transform

Position: (0, 0, 0), Rotation: (0, 0, 0), scale: (1, 1, 1)

Returns

Transform

Methods

clone

clone(): Transform other

Clone a new Transform

Returns

TransformNew data with the same Transform

fromString

fromString(str): void other

Read string data

Parameters

str stringUsage: Read string data range: "0.000000, 0.000000, 0.000000 0.000000, 0.000000, 0.000000 10000000, 10000000, 10000000, 10000000"
outer? TransformUsage: Transform for accepting results default: null

Returns

TransformCreate or read Transform object from string

Parameters

str stringUsage: Read string data range: "0.000000, 0.000000, 0.000000 0.000000, 0.000000, 0.000000 10000000, 10000000, 10000000, 10000000"

Obtain the forward vector of Transform

Returns

VectorTransform The forward direction vector

getRightVector

getRightVector(): Vector other

Obtain the right vector of Transform

Returns

VectorTransform The vector in the right direction

getUpVector

getUpVector(): Vector other

Obtain the upward vector of Transform

Returns

VectorTransform The upward vector

inverseTransformDirection

inverseTransformDirection(location): Vector other

Transform from global direction to local direction

Parameters

location VectorUsage: World Direction

Returns

VectorLocal direction

inverseTransformPosition

inverseTransformPosition(location): Vector other

Convert world coordinates to local coordinates

Parameters

location VectorUsage: world coordinates

Returns

VectorLocal coordinates

lookAt

lookAt(target): void other

Facing the direction of target

Parameters

target VectorUsage: world coordinates

rotate

rotate(axis, angle): void other

Rotate around the specified axis

Parameters

axis VectorUsage: rotate axis
angle numberUsage: rotation angle value
range: unlimited type: floating-point number

toString

toString(): string other

Output as a formatted string

Returns

stringString

transformDirection

transformDirection(location): Vector other

Transform local direction into world direction

Parameters

location VectorUsage: Local direction

Returns

VectorWorld direction

transformPosition

transformPosition(location): Vector other

Convert local coordinates to world coordinates

Parameters

location VectorUsage: local coordinates

Returns

VectorWorld coordinates

fromString

Static fromString(str, outer?): Transform other

Create a Transform from a string

The string format is: 0.000000, 0.000000, 0.000000 | 0.000000, 0.000000, 0.000000 | 1.000000,1.000000,1.000000

If the outer is not empty, return the outer. Otherwise, return a new Transform object. It is recommended to pass in the outer to reduce the new object and the outer cannot be null/undefined

Parameters

str stringUsage: Read string data range: "0.000000, 0.000000, 0.000000 0.000000, 0.000000, 0.000000 10000000, 10000000, 10000000, 10000000"
outer? TransformUsage: Transform for accepting results default: null

Returns

TransformCreate or read Transform object from string