Skip to content

luxe API (2025.1.2)


luxe: system/transform.modifier module


Data

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

System

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

no docs found

  • new(world: World)

System.new(world: World) returns System

no docs found

Transform

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 returns unknown

no docs found

Transform.create(entity: Entity, x: Num, y: Num) returns 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) returns None

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

Transform.create(entity: Entity) returns None

Attach a Transform modifier to an entity.

Transform.destroy(entity: Entity) returns None

Detatch a Transform modifier from an entity.

Transform.has(entity: Entity) returns Bool

get whether an entity has an attached Transform.

Transform.get_link(entity: Entity) returns 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) returns 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, reset_local: Bool) returns 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) returns 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: Bool) returns 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) returns 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.

  //get the current jar position
  var pos = Transform.get_pos_world(_jar)
  //unlink the jar from the player first
  Transform.unlink(_jar)
  //set the position for the jar, which now refers 
  //to world space since the jar has no parent
  //this makes the jar stay in the same place
  Transform.set_pos(_jar, pos.x, pos.y, pos.z)

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

Move Transform somewhere else, then look towards target position.

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

Move Transform somewhere else, then look towards target position.

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

Move Transform somewhere else, then look towards target position.

Transform.look_at(entity: Entity, target: Vec, up: Vec, invert: Bool) returns 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) returns 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) returns None

Rotate Transform to look at a position in worldspace.

Transform.set_snap(entity: Entity, x: Num, y: Num, z: Num) returns 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) returns None

Set Transform position to snap at specific intervals.

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

Set local position of a Transform.

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

Set local position of a Transform.

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

Set global position of a Transform.

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

Set global position of a Transform.

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

Set x component of local Transform pos.

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

Set y component of local Transform pos.

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

Set z component of local Transform pos.

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

Set x component of global Transform pos.

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

Set y component of global Transform pos.

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

Set z component of global Transform pos.

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

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

Transform.set_scale(entity: Entity, x: Num, y: Num, z: Num) returns 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(entity: Entity, axis: Vec, from: Num, to: Num, t: Num) returns None

no docs found

Transform.set_rotation_slerp_angle_axis_world(entity: Entity, axis: Vec, from: Num, to: Num, t: Num) returns None

no docs found

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

no docs found

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

no docs found

Transform.set_rotation(entity: Entity, x: Num, y: Num, z: Num, w: Num) returns 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) returns 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) returns 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) returns 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) returns None

Set local rotation as xyz euler angles.

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

Set global rotation as xyz euler angles.

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

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

no docs found

Transform.rotate_angle_axis_slerp_world(entity: Entity, axis: Vec, angle_amount: Num) returns 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) returns 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) returns None

Rotate around an axis in local space.

Transform.rotate_angle_axis(entity: Entity, degrees: Any, x: Num, y: Num, z: Num) returns 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) returns None

Rotate on the spot around an axis in global coordinates.

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

Rotate by euler angles in local space.

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

Rotate by euler angles in global space.

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

Move Transform in local space.

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

Move Transform in local space.

Transform.get_pos(entity: Entity) returns Vec

Get position local space (relative to link Transform).

Transform.get_pos_x(entity: Entity) returns Num

no docs found

Transform.get_pos_y(entity: Entity) returns Num

no docs found

Transform.get_pos_z(entity: Entity) returns Num

no docs found

Transform.get_pos_world(entity: Entity) returns unknown

Get position global space.

Transform.get_pos_world_unsnapped(entity: Entity) returns Vec

Get position global space independently of set_snap settings.

Transform.get_pos_x_world(entity: Entity) returns Num

no docs found

Transform.get_pos_y_world(entity: Entity) returns Num

no docs found

Transform.get_pos_z_world(entity: Entity) returns Num

no docs found

Transform.rotate2D(entity: Entity, degrees: Num) returns 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) returns 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) returns 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) returns 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) returns 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) returns None

Set the local depth (relative to link Transform).

This is technically the same as set_pos_z.

Transform.get_depth2D(entity: Entity) returns 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) returns None

Set the global depth.

This is technically the same as set_pos_z_world.

Transform.get_depth2D_world(entity: Entity) returns Num

Get the global depth.

This is technically the same as get_pos_z_world.

Transform.get_world_matrix(entity: Entity, into_matrix: Floats) returns 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) returns 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) returns 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) returns None

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

Transform.get_euler(entity: Entity) returns Vec

Get local euler angles.

Transform.get_euler_x(entity: Entity) returns Num

no docs found

Transform.get_euler_y(entity: Entity) returns Num

no docs found

Transform.get_euler_z(entity: Entity) returns Num

no docs found

Transform.get_euler_world(entity: Entity) returns Vec

Get global euler angles.

Transform.get_euler_x_world(entity: Entity) returns Num

no docs found

Transform.get_euler_y_world(entity: Entity) returns Num

no docs found

Transform.get_euler_z_world(entity: Entity) returns Num

no docs found

Transform.get_scale(entity: Entity) returns Vec

Get local scale.

Transform.get_scale_x(entity: Entity) returns Num

no docs found

Transform.get_scale_y(entity: Entity) returns Num

no docs found

Transform.get_scale_z(entity: Entity) returns Num

no docs found

Transform.get_scale_world(entity: Entity) returns 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) returns Num

no docs found

Transform.get_scale_y_world(entity: Entity) returns Num

no docs found

Transform.get_scale_z_world(entity: Entity) returns Num

no docs found

Transform.get_right(entity: Entity) returns 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) returns 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) returns 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) returns 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) returns 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) returns 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) returns 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) returns None

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

Transform.rotate_euler_by(entity: Entity, euler: Float3, origin: Float3) returns 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) returns 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) returns 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) returns 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) returns 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) returns 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) returns 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) returns 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) returns Vec

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

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

no docs found

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

no docs found

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

no docs found

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

no docs found

TransformApplyMask

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

no docs found


TransformApplyMask.pos returns unknown

no docs found

TransformApplyMask.scale returns unknown

no docs found

TransformApplyMask.rotation returns unknown

no docs found

TransformApplyMask.modified returns unknown

no docs found

TransformApplyMask.all_modified returns unknown

no docs found