LS.Components.Transform Class
Constructor
LS.Components.Transform
-
object
Parameters:
-
objectObjectto configure from
Item Index
Methods
- applyTransform
- applyTransformMatrix
- configure
- copyFrom
- fromMatrix
- getAncestors
- getFront
- getGlobalMatrix
- getGlobalMatrix
- getGlobalPosition
- getGlobalRotation
- getGlobalRotationMatrix
- getGlobalRotationMatrix
- getGlobalScale
- getGlobalTranslationMatrix
- getGlobalTranslationRotationMatrix
- getLocalMatrixRef
- getMatrix
- getNormalMatrix
- getPosition
- getRight
- getRotation
- getRotation
- getScale
- getTop
- globalToLocal
- identity
- interpolate
- localToGlobal
- lookAt
- orbit
- resetPosition
- resetRotation
- resetScale
- rotate
- rotateGlobal
- rotateQuat
- rotateQuatGlobal
- rotateX
- rotateY
- rotateZ
- scale
- serialize
- setPosition
- setRotation
- setRotationFromEuler
- setScale
- transformPoint
- transformPointGlobal
- transformVector
- transformVectorGlobal
- translate
- translateGlobal
- updateGlobalMatrix
- updateMatrix
Events
Methods
applyTransform
()
Apply a transform to this transform
applyTransformMatrix
-
matrix -
center -
is_global
Applies the transformation using a matrix
Parameters:
-
matrixMat4with the transform
-
centerVec3different pivot [optional] if omited 0,0,0 will be used
-
is_globalBool(optional) tells if the transformation should be applied in global space or local space
configure
-
object
Configure from a serialized object
Parameters:
-
objectObjectwith the serialized info
copyFrom
-
src
Copy the transform from another Transform
Parameters:
-
srcTransform
fromMatrix
-
matrix -
is_global
Configure the transform from a local Matrix (do not tested carefully)
Parameters:
-
matrixMat4the matrix in array format
-
is_globalBooltells if the matrix is in global space [optional]
getAncestors
()
Array
Returns an array with all the ancestors
Returns:
getFront
()
Vec3
returns the [0,0,-1] vector in global space
Returns:
getGlobalMatrix
()
Mat4
Returns a copy of the global matrix of this transform (it updates the matrix automatically)
Returns:
the matrix in array format
getGlobalMatrix
-
out -
fast
Returns a copy of the global matrix of this transform (it updates the matrix automatically)
Parameters:
-
outMat4optional
-
fastBooleanthis flags skips recomputing parents matrices
Returns:
the matrix in array format
getGlobalPosition
-
out
Returns a copy of the global position
Parameters:
-
outVec3[optional] where to store the result, otherwise one vec3 is created and returned
Returns:
the position
getGlobalRotation
()
Quat
Returns a quaternion with all parents rotations
Returns:
Quaternion
getGlobalRotationMatrix
()
Mat4
Returns a Matrix with all parents rotations
Returns:
Matrix rotation
getGlobalRotationMatrix
()
Mat4
Returns the global rotation in quaternion array (a copy)
Returns:
the rotation
getGlobalScale
-
out
Returns a copy of the global scale (this is not correct, there is no global_scale factor, because due to rotations the axis could change)
Parameters:
-
outVec3[optional] where to store the result, otherwise one vec3 is created and returned
Returns:
the scale
getGlobalTranslationMatrix
()
Mat4
Returns the local matrix of this transform without the rotation or scale
Returns:
the matrix in array format
getGlobalTranslationRotationMatrix
()
Mat4
Returns the local matrix of this transform without the scale
Returns:
the matrix in array format
getLocalMatrixRef
()
Mat4
Returns the original local matrix of this transform (it updates the matrix automatically)
Returns:
the matrix in array format
getMatrix
-
out
Returns a copy of the local matrix of this transform (it updates the matrix automatically)
Parameters:
-
outMat4[optional] where to store the result, otherwise one mat4 is created and returned
Returns:
the matrix
getNormalMatrix
()
Mat4
Returns the matrix for the normals in the shader
Returns:
the matrix in array format
getPosition
-
out
Returns a copy of the local position
Parameters:
-
outVec3[optional] where to store the result, otherwise one vec3 is created and returned
Returns:
the position
getRight
()
Vec3
returns the [1,0,0] vector in global space
Returns:
getRotation
-
out
Returns the global rotation in quaternion array (a copy)
Parameters:
-
outQuat[optional] where to store the result, otherwise one quat is created and returned
Returns:
the rotation
getRotation
-
out
Returns the rotation in quaternion array (a copy)
Parameters:
-
outQuat[optional] where to store the result, otherwise one quat is created and returned
Returns:
the rotation
getScale
-
out
Returns the scale (its a copy)
Parameters:
-
outVec3[optional] where to store the result, otherwise one vec3 is created and returned
Returns:
the scale
getTop
()
Vec3
returns the [0,1,0] vector in global space
Returns:
globalToLocal
-
point -
destination
convert from global coordinates to local coordinates If no destination is specified a new vector is created
Parameters:
-
pointVec3 -
destinationVec3(optional)
identity
()
Reset this transform
interpolate
-
a -
b -
factor -
the
This method is static (call it from Transform.interpolate) interpolate the transform between two transforms and stores the result in another Transform
Parameters:
-
aTransform -
bTransform -
factorNumberfrom 0 to 1
-
theTransformdestination
localToGlobal
-
point -
destination
convert from local coordinates to global coordinates (it is the same as transformPointGlobal) If no destination is specified a new vector is created
Parameters:
-
pointVec3 -
destinationVec3(optional)
lookAt
-
position -
target -
up -
in_world
Orients the transform to look from one position to another
Parameters:
-
positionVec3 -
targetVec3 -
upVec3 -
in_worldBooleantells if the values are in world coordinates (otherwise asume its in local coordinates)
orbit
-
angle_in_deg -
axis -
center
Orbits around a point
Parameters:
-
angle_in_degNumber -
axisVec3 -
centerVec3in local coordinates
resetPosition
()
Sets the position to 0,0,0
resetRotation
()
Sets the rotation to identity
resetScale
()
Sets the scale to 1,1,1
rotate
-
angle_in_deg -
axis
rotate object in local space (axis is in local space)
Parameters:
-
angle_in_degNumber -
axisVec3
rotateGlobal
-
angle_in_deg -
axis
rotate object in global space (axis is in global space)
Parameters:
-
angle_in_degNumber -
axisVec3
rotateQuat
-
quaternion
rotate object in local space using a quat
Parameters:
-
quaternionQuat
rotateQuatGlobal
-
quaternion
rotate object in global space using a quat
Parameters:
-
quaternionQuat
rotateX
-
angle_in_deg
rotate object in local space in local X axis
Parameters:
-
angle_in_degNumber
rotateY
-
angle_in_deg
rotate object in local space in local Y axis
Parameters:
-
angle_in_degNumber
rotateZ
-
angle_in_deg
rotate object in local space in local Z axis
Parameters:
-
angle_in_degNumber
scale
-
x -
y -
z
scale the object
Parameters:
-
xNumber -
yNumber -
zNumber
serialize
()
Object
Serialize the object
Returns:
object with the serialized info
setPosition
-
x -
y -
z
sets the position
Parameters:
-
xNumber -
yNumber -
zNumber
setRotation
-
rotation
sets the rotation from a quaternion or from an angle(rad) and axis
Parameters:
-
rotationQuatin quaterion format or angle
setRotationFromEuler
-
src,
Configure the transform rotation from a vec3 Euler angles (heading,attitude,bank)
Parameters:
-
src,Mat4the matrix in array format
setScale
-
x -
y -
z
sets the scale
Parameters:
-
xNumber -
yNumber -
zNumber
transformPoint
-
point -
destination
Multiplies a point by the local matrix (not global) If no destination is specified a new vector is created
Parameters:
-
pointVec3 -
destinationVec3(optional)
transformPointGlobal
-
point -
destination
convert from local coordinates to global coordinates If no destination is specified a new vector is created
Parameters:
-
pointVec3 -
destinationVec3(optional)
transformVector
-
vector -
destination
Applies the transformation to a vector (rotate but not translate) If no destination is specified the transform is applied to vec
Parameters:
-
vectorVec3 -
destinationVec3(optional)
transformVectorGlobal
-
vector -
destination
Applies the transformation to a vector (rotate but not translate) If no destination is specified the transform is applied to vec
Parameters:
-
vectorVec3 -
destinationVec3(optional)
translate
-
x -
y -
z
translates object in local coordinates (using the rotation and the scale)
Parameters:
-
xNumber -
yNumber -
zNumber
translateGlobal
-
x -
y -
z
translates object in local coordinates (adds to the position)
Parameters:
-
xNumber -
yNumber -
zNumber
updateGlobalMatrix
-
fast
updates the global matrix using the parents transformation
Parameters:
-
fastBoolit doesnt recompute parent matrices, just uses the stored one, is faster but could create errors if the parent doesnt have its global matrix update
updateMatrix
()
update the local Matrix to match the position,scale and rotation
Properties
matrix
Mat4
The local matrix transform relative to its parent in mat4 format
matrix
Mat4
The local matrix transform relative to its parent in mat4 format
mustUpdate
Boolean
Force object to update matrices
position
Vec3
The position relative to its parent in vec3 format
position
Vec3
The position relative to its parent in vec3 format
rotation
Quat
The orientation relative to its parent in quaternion format
scaling
Vec3
The scaling relative to its parent in vec3 format (default is [1,1,1])
Events
changed
Fired when the node has changed its transform
