[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 Vector | Usage: Coordinate information |
---|---|
rotation Rotation | Usage: Rotation information |
scale Vector | Usage: Zoom information |
• new Transform(newTransform
)
Copy the given Transform
Parameters
newTransform Transform | Transform object |
---|
Accessors
position
• | • | ||||
---|---|---|---|---|---|
Get position information Returns
| Set position information Parameters
|
rotation
• | • | ||||
---|---|---|---|---|---|
Obtain rotation information Returns
| Set rotation information Parameters
|
scale
• | • | ||||
---|---|---|---|---|---|
Get scale information Returns
| Set scale information Parameters
|
identity
• |
---|
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
Transform | New data with the same Transform |
---|
fromString
• fromString(str
): void
other
Read string data
Parameters
str string | Usage: Read string data range: "0.000000, 0.000000, 0.000000 0.000000, 0.000000, 0.000000 10000000, 10000000, 10000000, 10000000" |
---|---|
outer? Transform | Usage: Transform for accepting results default: null |
Returns
Transform | Create or read Transform object from string |
---|
Parameters
str string | Usage: 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
Vector | Transform The forward direction vector |
---|
getRightVector
• getRightVector(): Vector
other
Obtain the right vector of Transform
Returns
Vector | Transform The vector in the right direction |
---|
getUpVector
• getUpVector(): Vector
other
Obtain the upward vector of Transform
Returns
Vector | Transform The upward vector |
---|
inverseTransformDirection
• inverseTransformDirection(location
): Vector
other
Transform from global direction to local direction
Parameters
location Vector | Usage: World Direction |
---|
Returns
Vector | Local direction |
---|
inverseTransformPosition
• inverseTransformPosition(location
): Vector
other
Convert world coordinates to local coordinates
Parameters
location Vector | Usage: world coordinates |
---|
Returns
Vector | Local coordinates |
---|
lookAt
• lookAt(target
): void
other
Facing the direction of target
Parameters
target Vector | Usage: world coordinates |
---|
rotate
• rotate(axis
, angle
): void
other
Rotate around the specified axis
Parameters
axis Vector | Usage: rotate axis |
---|---|
angle number | Usage: rotation angle value range: unlimited type: floating-point number |
toString
• toString(): string
other
Output as a formatted string
Returns
string | String |
---|
transformDirection
• transformDirection(location
): Vector
other
Transform local direction into world direction
Parameters
location Vector | Usage: Local direction |
---|
Returns
Vector | World direction |
---|
transformPosition
• transformPosition(location
): Vector
other
Convert local coordinates to world coordinates
Parameters
location Vector | Usage: local coordinates |
---|
Returns
Vector | World 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 string | Usage: Read string data range: "0.000000, 0.000000, 0.000000 0.000000, 0.000000, 0.000000 10000000, 10000000, 10000000, 10000000" |
---|---|
outer? Transform | Usage: Transform for accepting results default: null |
Returns
Transform | Create or read Transform object from string |
---|