Skip to content

luxe: system/transform.modifier


import "luxe: system/transform.modifier" for Data

no docs found

var pos : Double3 = [0, 0, 0]
var rotation : Float3 = [0, 0, 0]
var scale : Float3 = [1, 1, 1]
var link : Link = null
import "luxe: system/transform.modifier" for System

no docs found

System.new(world : World) : System

no docs found

import "luxe: system/transform.modifier" for Transform

A transform modifier defines where a entity is. That includes position, rotation and scale. A Transform can also be linked to another Transform, in which case its values are relative to their link target.

While not all entities need to be “somewhere” locally, a lot of them do, which is when this modifier is used. Other modifiers on the same entity aren’t required to read and react to the Transform, but most do, allowing you to use this to move things (like Sprites, Meshes, Physics shapes, etc…).

Transform.id : unknown

no docs found

Transform.create(entity : Entity, x : Num, y : Num) : None

Attach a Transform modifier to an entity with the given x and y position (with a z of 0)

Transform.create(entity : Entity, x : Num, y : Num, z : Num) : None

Attach a Transform modifier to an entity with the given x, y and z position

Transform.create(entity : Entity) : None

Attach a Transform modifier to an entity.

Transform.create(entity : Entity, link_to : Entity) : None

Attach a Transform modifier to an entity, and link it to another entity.

Transform.destroy(entity : Entity) : None

Detatch a Transform modifier from an entity.

Transform.has(entity : Entity) : Bool

get whether an entity has an attached Transform.

Transform.get_link(entity : Entity) : Entity

Get what entity this entity is linked to. So what entity the position/rotation/scale of this transform are relative to. Linked to entity always has a Transform of its own. In case Transform isn’t linked to anything, returns null and transformations are global.

Transform.get_linked(entity : Entity) : List

Get what entities are linked to this entity (opposite relationship as get_link). Transformation values of linked entities are relative to this entity.

Transform.link(entity : Entity, target_entity : Entity, link_action : TransformLinkAction) : None

Link one Transform to another. The Transform values will now be be relative to the link target, meaning the link target Transform position, rotation and scale all apply to the local position, rotation, scale of this Transform. When using non-uniform scales somewhere in your transform link hierarchy you can get transform deformations that would not be possible with just a single transform.

In other environments, this transform link is often part of the object hierarchy, but here it’s specific to transforms and other hierarchies aren’t bound to follow the same links.

Transform.link(entity : Entity, target_entity : Entity) : None

Link one Transform to another. The Transform values will now be be relative to the link target, meaning the link target Transform position, rotation and scale all apply to the local position, rotation, scale of this Transform. When using non-uniform scales somewhere in your transform link hierarchy you can get transform deformations that would not be possible with just a single transform.

In other environments, this transform link is often part of the object hierarchy, but here it’s specific to transforms and other hierarchies aren’t bound to follow the same links.

Transform.unlink(entity : Entity, reset_local : TransformLinkAction) : None

Unlink a Transform. Local position will be kept (unless reset), so if your parent isnt at the origin, expect the transform to move, or save and reapply the world position.

Transform.unlink(entity : Entity) : None

Unlink a Transform. Local position will be kept, so if your parent isnt at the origin, expect the transform to move, or save and reapply the world position.

Transform.look_at_and_move(entity : Entity, pos : Vec, target : Vec, up : Vec, invert : Bool) : None

Move Transform somewhere else, then look towards target position.

Transform.look_at_and_move(entity : Entity, pos : Vec, target : Vec, up : Vec) : None

Move Transform somewhere else, then look towards target position.

Transform.look_at_and_move(entity : Entity, pos : Vec, target : Vec) : None

Move Transform somewhere else, then look towards target position.

Transform.look_at(entity : Entity, target : Vec, up : Vec, invert : Bool) : None

Rotate Transform to look at a position in worldspace, rotated around that new view axis so the Transform ‘up’ aligns with the up input as closely as possible.

Transform.look_at(entity : Entity, target : Vec, up : Vec) : None

Rotate Transform to look at a position in worldspace, rotated around that new view axis so the Transform ‘up’ aligns with the up input as closely as possible.

Transform.look_at(entity : Entity, target : Vec) : None

Rotate Transform to look at a position in worldspace.

Transform.set_snap(entity : Entity, x : Num, y : Num, z : Num) : None

Set Transform position to snap at specific intervals. (midpoints round away from 0)

var entity = Entity.create(world)
Transform.create(entity)
Transform.set_snap(entity, 2, 2, 2)
Transform.set_pos(entity, 0.5, 1.5, -3)
Log.print(Transform.get_pos(entity)) //[0, 2, -4]

Transform.set_snap(entity : Entity, x : Num, y : Num) : None

Set Transform position to snap at specific intervals.

Transform.set_pos(entity : Entity, x : Num, y : Num, z : Num) : None

Set local position of a Transform.

Transform.set_pos(entity : Entity, x : Num, y : Num) : None

Set local position of a Transform.

Transform.set_pos_world(entity : Entity, x : Num, y : Num, z : Num) : None

Set global position of a Transform.

Transform.set_pos_world(entity : Entity, x : Num, y : Num) : None

Set global position of a Transform.

Transform.set_pos_x(entity : Entity, x : Num) : None

Set x component of local Transform pos.

Transform.set_pos_y(entity : Entity, y : Num) : None

Set y component of local Transform pos.

Transform.set_pos_z(entity : Entity, z : Num) : None

Set z component of local Transform pos.

Transform.set_pos_x_world(entity : Entity, x : Num) : None

Set x component of global Transform pos.

Transform.set_pos_y_world(entity : Entity, y : Num) : None

Set y component of global Transform pos.

Transform.set_pos_z_world(entity : Entity, z : Num) : None

Set z component of global Transform pos.

Transform.set_scale(entity : Entity, x : Num, y : Num) : None

Set x and y scale of a Transform, keeping z scale unchanged.

Transform.set_scale(entity : Entity, x : Num, y : Num, z : Num) : None

Set local scale of a Transform. Setting the scale in a global context isnt available, as link hierarchies with rotations and nonuniform scalings can lead to weird and hard to predict states for that.

Transform.set_rotation_slerp_angle_axis(…)

Section titled “Transform.set_rotation_slerp_angle_axis(…)”
Transform.set_rotation_slerp_angle_axis(entity : Entity, axis : Vec, from : Num, to : Num, t : Num) : None

no docs found

Transform.set_rotation_slerp_angle_axis_world(…)

Section titled “Transform.set_rotation_slerp_angle_axis_world(…)”
Transform.set_rotation_slerp_angle_axis_world(entity : Entity, axis : Vec, from : Num, to : Num, t : Num) : None

no docs found

Transform.set_rotation_slerp(entity : Entity, from : Vec, to : Vec, t : Num) : None

no docs found

Transform.set_rotation_slerp_world(entity : Entity, from : Vec, to : Vec, t : Num) : None

no docs found

Transform.set_rotation(entity : Entity, x : Num, y : Num, z : Num, w : Num) : None

Set local rotation in quaternions.

(Quaternions are how rotations are handled by the engine internally, though it can be hard to understand how to manipulate them, so feel free to stick to euler angles using set_euler(entity, x, y, z).)

Transform.set_rotation_world(entity : Entity, x : Num, y : Num, z : Num, w : Num) : None

Set global rotation in quaternions.

(Quaternions are how rotations are handled by the engine internally, though it can be hard to understand how to manipulate them, so feel free to stick to euler angles using set_euler_world(entity, x, y, z).)

Transform.set_angle_axis(entity : Entity, degrees : Any, x : Num, y : Num, z : Num) : None

Set local rotation as a rotation around an axis.

Rotation direction is left-handed (counter-clockwise when looking in the direction of the axis.)

Transform.set_angle_axis_world(entity : Entity, degrees : Any, x : Num, y : Num, z : Num) : None

Set global rotation as a rotation around an axis.

Rotation direction is left-handed (counter-clockwise when looking in the direction of the axis.)

Transform.set_euler(entity : Entity, x : Num, y : Num, z : Num) : None

Set local rotation as xyz euler angles.

Transform.set_euler_world(entity : Entity, x : Num, y : Num, z : Num) : None

Set global rotation as xyz euler angles.

Transform.set_euler_x(entity : Entity, x : Num) : None

no docs found

Transform.set_euler_y(entity : Entity, y : Num) : None

no docs found

Transform.set_euler_z(entity : Entity, z : Num) : None

no docs found

Transform.set_euler_x_world(entity : Entity, x : Num) : None

no docs found

Transform.set_euler_y_world(entity : Entity, y : Num) : None

no docs found

Transform.set_euler_z_world(entity : Entity, z : Num) : None

no docs found

Transform.rotate_angle_axis_slerp(entity : Entity, axis : Vec, angle_amount : Num) : None

no docs found

Transform.rotate_angle_axis_slerp_world(…)

Section titled “Transform.rotate_angle_axis_slerp_world(…)”
Transform.rotate_angle_axis_slerp_world(entity : Entity, axis : Vec, angle_amount : Num) : None

no docs found

Transform.rotate_around_world(entity : Entity, x : Num, y : Num, z : Num, axis_x : Num, axis_y : Num, axis_z : Num, degrees : Num) : None

Rotate around an axis in world space.

Transform.rotate_around(entity : Entity, x : Num, y : Num, z : Num, axis_x : Num, axis_y : Num, axis_z : Num, degrees : Num) : None

Rotate around an axis in local space.

Transform.rotate_angle_axis(entity : Entity, degrees : Any, x : Num, y : Num, z : Num) : None

Rotate on the spot around an axis in local coordinates.

Transform.rotate_angle_axis_world(entity : Entity, degrees : Any, x : Num, y : Num, z : Num) : None

Rotate on the spot around an axis in global coordinates.

Transform.rotate_euler(entity : Entity, x : Num, y : Num, z : Num) : None

Rotate by euler angles in local space.

Transform.rotate_euler_world(entity : Entity, x : Num, y : Num, z : Num) : None

Rotate by euler angles in global space.

Transform.translate(entity : Entity, x : Num, y : Num, z : Num) : None

Move Transform in local space.

Transform.translate(entity : Entity, x : Num, y : Num) : None

Move Transform in local space.

Transform.get_pos(entity : Entity) : Vec

Get position local space (relative to link Transform).

Transform.get_pos_x(entity : Entity) : Num

no docs found

Transform.get_pos_y(entity : Entity) : Num

no docs found

Transform.get_pos_z(entity : Entity) : Num

no docs found

Transform.get_pos_world(entity : Entity) : unknown

Get position global space.

Transform.get_pos_world_unsnapped(entity : Entity) : Vec

Get position global space independently of set_snap settings.

Transform.get_pos_x_world(entity : Entity) : Num

no docs found

Transform.get_pos_y_world(entity : Entity) : Num

no docs found

Transform.get_pos_z_world(entity : Entity) : Num

no docs found

Transform.rotate2D(entity : Entity, degrees : Num) : None

Rotate the Transform in local space.

This technically rotates around the z axis, since thats the only axis we care about in 2d contexts.

Transform.set_angle2D(entity : Entity, degrees : Num) : None

Set the 2d angle in local space.

This is technically the same as set_euler_z(doesnt touch x or y), since thats the only axis we care about in 2d contexts.

Transform.set_angle2D_world(entity : Entity, degrees : Num) : None

Set the 2d angle in global space.

This is technically the same as set_euler_z(doesnt touch x or y), since thats the only axis we care about in 2d contexts.

Transform.get_angle2D(entity : Entity) : Num

Get the 2d angle in local space.

This is technically the same as get_euler_z, since thats the only axis we care about in 2d contexts.

Transform.get_angle2D_world(entity : Entity) : Num

Get the 2d angle in global space.

This is technically the same as get_euler_z_world, since thats the only axis we care about in 2d contexts.

Transform.set_depth2D(entity : Entity, depth : Num) : None

Set the local depth (relative to link Transform).

This is technically the same as set_pos_z.

Transform.get_depth2D(entity : Entity) : Num

Get the local depth (relative to link Transform).

This is technically the same as get_pos_z.

Transform.set_depth2D_world(entity : Entity, depth : Num) : None

Set the global depth.

This is technically the same as set_pos_z_world.

Transform.get_depth2D_world(entity : Entity) : Num

Get the global depth.

This is technically the same as get_pos_z_world.

Transform.get_world_matrix(entity : Entity, into_matrix : Floats) : None

Get 4x4 world transform matrix (column major array).

var ent = Entity.create(app.world)
Transform.create(ent)
Transform.set_pos(ent, 2, 3, 4)
var matrix = Floats.new(16)
Transform.get_world_matrix(ent, matrix)
//matrix is now [1,0,0,0, 0,1,0,0, 0,0,1,0, 2,3,4,1]

Transform.get_rotation(entity : Entity) : Quat

Get local quaternion rotation.

(Note that quaternions can be unfamiliar and hard to manipulate, so if you’re not familiar with them you might want to use get_euler instead)

Transform.get_rotation_world(entity : Entity) : Quat

Get global quaternion rotation.

(Note that quaternions can be unfamiliar and hard to manipulate, so if you’re not familiar with them you might want to use get_euler_world instead)

Transform.get_rotation_matrix(entity : Entity, into_matrix : Floats) : None

Get 4x4 world rotation matrix (column major array).

Transform.get_euler(entity : Entity) : Vec

Get local euler angles.

Transform.get_euler_x(entity : Entity) : Num

no docs found

Transform.get_euler_y(entity : Entity) : Num

no docs found

Transform.get_euler_z(entity : Entity) : Num

no docs found

Transform.get_euler_world(entity : Entity) : Vec

Get global euler angles.

Transform.get_euler_x_world(entity : Entity) : Num

no docs found

Transform.get_euler_y_world(entity : Entity) : Num

no docs found

Transform.get_euler_z_world(entity : Entity) : Num

no docs found

Transform.get_scale(entity : Entity) : Vec

Get local scale.

Transform.get_scale_x(entity : Entity) : Num

no docs found

Transform.get_scale_y(entity : Entity) : Num

no docs found

Transform.get_scale_z(entity : Entity) : Num

no docs found

Transform.get_scale_world(entity : Entity) : Vec

Get global scale. Note that through rotations and non-uniform scale in the transform link hierarchy, getting an accurate world scale might be impossible, making this lossy.

Transform.get_scale_x_world(entity : Entity) : Num

no docs found

Transform.get_scale_y_world(entity : Entity) : Num

no docs found

Transform.get_scale_z_world(entity : Entity) : Num

no docs found

Transform.get_right(entity : Entity) : Vec

Get the “right” direction of the Transform. Same direction as the red arrow in the translation gizmo in the editor.

Transform.get_forward(entity : Entity) : Vec

Get the “forward” direction of the Transform. Same direction as the green arrow in the translation gizmo in the editor.

Transform.get_up(entity : Entity) : Vec

Get the “up” direction of the Transform. Same direction as the blue arrow in the translation gizmo in the editor.

Transform.sync(entity : Entity) : None

Forces a sync of the Transform. Will trigger listen functions. This usually shouldn’t be needed as Transform sync automatically when updated.

Transform.sync_block(entity : Entity, mask : TransformApplyMask) : None

Forces a sync of the Transform block data. Will trigger block listener functions. This usually shouldn’t be needed as Transform sync automatically when updated.

Transform.sync_world(world : World) : None

Forces a sync of all Transform in a world. Will trigger listen functions. This usually shouldn’t be needed as Transform sync automatically when updated.

Transform.transform_by(entity : Entity, other : Entity) : None

Transform the given entity by another entities transform. e.g set world using the other as a parent

Transform.scale_by(entity : Entity, scale : Float3, origin : Float3) : None

Transform the given entity scale by the value around the given origin

Transform.rotate_euler_by(entity : Entity, euler : Float3, origin : Float3) : None

Transform the given entity rotation around the origin, by euler amount (radians)

Transform.local_vector_to_world(entity : Entity, x : Num, y : Num, z : Num) : Vec

Convert a vector from local space to world space. (applies scale and rotation, but not translation)

Transform.world_vector_to_local(entity : Entity, x : Num, y : Num, z : Num) : Vec

Convert a vector from world space to local space. (applies scale and rotation, but not translation)

Transform.local_dir_to_world(entity : Entity, x : Num, y : Num, z : Num) : Vec

Convert a direction from local space to world space. (applies only rotation, not rotation or translation)

Transform.world_dir_to_local(entity : Entity, x : Num, y : Num, z : Num) : Vec

Convert a direction from world space to local space. (applies only rotation, not rotation or translation)

Transform.local_point_to_world(entity : Entity, x : Num, y : Num, z : Num) : Vec

Convert a point from local space to world space. (applies translation, rotation and scale)

Transform.local_point_to_world(entity : Entity, x : Num, y : Num, z : Num, scaled : Bool) : Vec

Convert a point from local space to world space. (applies translation, rotation and optionally, scale)

Transform.world_point_to_local(entity : Entity, x : Num, y : Num, z : Num) : Vec

Convert a point from world space to local space. (applies translation, rotation and scale)

Transform.world_point_to_local(entity : Entity, x : Num, y : Num, z : Num, scaled : Bool) : Vec

Convert a point from world space to local space. (applies translation, rotation and optionally, scale)

Transform.listen_all(world : World, fn : Fn) : Handle

no docs found

Transform.unlisten_all(world : World, handle : Handle) : None

no docs found

Transform.listen(entity : Entity, fn : Fn) : Handle

no docs found

Transform.unlisten(entity : Entity, handle : Handle) : None

no docs found

import "luxe: system/transform.modifier" for TransformApplyMask

no docs found

TransformApplyMask.pos : unknown

no docs found

TransformApplyMask.scale : unknown

no docs found

TransformApplyMask.rotation : unknown

no docs found

TransformApplyMask.modified : unknown

no docs found

TransformApplyMask.all_modified : unknown

no docs found

import "luxe: system/transform.modifier" for TransformLinkAction

How to preserve or not preserve the transform fields on link/unlink.

TransformLinkAction.reset_local : unknown

Reset fields to 0 position, 0 rotation and 1 scale.

TransformLinkAction.keep_local : unknown

Don’t touch local values at all.

TransformLinkAction.keep_world : unknown

Try preserve the values how they appear in the world after transform hierarchy has been taken into consideration. Note that scale is on a best effort basis on unlink, and currently doesn’t do anything on link.