Transform
ClassControls the position, rotation, and scale of a SceneObject.
- Available on all platforms
Controls the position, rotation, and scale of a SceneObject. Every SceneObject automatically has a Transform attached.
Index
Properties
Methods
Example
// Move attached Transform 1 unit up
var transform = script.getTransform();
var pos = transform.getWorldPosition();
pos.y += 1;
transform.setWorldPosition(pos);
// Bind to "Frame Updated" to rotate the object every frame
var transform = script.getTransform();
var rotation = transform.getLocalRotation();
var rotateBy = quat.angleAxis(Math.PI*getDeltaTime(), vec3.up());
rotation = rotation.multiply(rotateBy);
transform.setLocalRotation(rotation);
Extends
Properties
back
readonlyback:vec3
Returns the Transform's back directional vector.
down
readonlydown:vec3
Returns the Transform's down directional vector.
forward
readonlyforward:vec3
Returns the Transform's forward directional vector.
left
readonlyleft:vec3
Returns the Transform's left directional vector.
right
readonlyright:vec3
Returns the Transform's right directional vector.
segmentScaleCompensate
segmentScaleCompensate:
boolean
When scaling a parent with segment scale enabled, instead of scaling child objects, it creates position offsets. This setting is used when exporting from certain 3d authoring tools.
Default Value
false
up
readonlyup:vec3
Returns the Transform's up directional vector.
Methods
getInvertedWorldTransform()
getInvertedWorldTransform():
mat4
Returns the Transform's world-to-local transformation matrix.
Returns
getLocalPosition()
getLocalPosition():
vec3
Returns the Transform's position relative to its parent.
Returns
getLocalRotation()
getLocalRotation():
quat
Returns the Transform's rotation relative to its parent.
Returns
getLocalScale()
getLocalScale():
vec3
Returns the Transform's scale relative to its parent.
Returns
getSceneObject()
getSceneObject():
SceneObject
Returns the SceneObject the Transform is attached to.
Returns
getTypeName()
staticgetTypeName():TypeName<Transform>
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<Transform>
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
getWorldPosition()
getWorldPosition():
vec3
Returns the Transform's position relative to the world.
Returns
getWorldRotation()
getWorldRotation():
quat
Returns the Transform's rotation relative to the world.
Returns
getWorldScale()
getWorldScale():
vec3
Returns the Transform's scale relative to the world.
Returns
getWorldTransform()
getWorldTransform():
mat4
Returns the Transform's local-to-world transformation matrix.
Returns
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
setLocalPosition()
setLocalPosition(
pos):void
Sets the Transform's position relative to its parent.
Parameters
| Parameter | Type |
|---|---|
pos | vec3 |
Returns
void
setLocalRotation()
setLocalRotation(
rotation):void
Sets the Transform's rotation relative to its parent.
Parameters
| Parameter | Type |
|---|---|
rotation | quat |
Returns
void
setLocalScale()
setLocalScale(
scale):void
Sets the Transform's scale relative to its parent.
Parameters
| Parameter | Type |
|---|---|
scale | vec3 |
Returns
void
setLocalTransform()
setLocalTransform(
transformMat):void
Sets the Transform's local transformation matrix.
Parameters
| Parameter | Type |
|---|---|
transformMat | mat4 |
Returns
void
Since
Lens Scripting Version 148
setWorldPosition()
setWorldPosition(
pos):void
Sets the Transform's position relative to the world.
Parameters
| Parameter | Type |
|---|---|
pos | vec3 |
Returns
void
setWorldRotation()
setWorldRotation(
rotation):void
Sets the Transform's rotation relative to the world.
Parameters
| Parameter | Type |
|---|---|
rotation | quat |
Returns
void
setWorldScale()
setWorldScale(
scale):void
Sets the Transform's scale relative to the world.
This may produce lossy results when parent objects are rotated, so use setLocalScale() instead if possible.
Parameters
| Parameter | Type |
|---|---|
scale | vec3 |
Returns
void
setWorldTransform()
setWorldTransform(
transformMat):void
Sets the Transform's transformation matrix.
Parameters
| Parameter | Type |
|---|---|
transformMat | mat4 |
Returns
void
Since
Lens Scripting Version 148