Transform

Transform

  • translation : glam::Vec3
  • rotation : glam::Quat
  • scale : glam::Vec3

Description

Describe the position of an entity. If the entity has a parent, the position is relative to its parent position.

  • To place or move an entity, you should set its [Transform].
  • To get the global transform of an entity, you should get its [GlobalTransform].
  • To be displayed, an entity must have both a [Transform] and a [GlobalTransform].
    • You may use the TransformBundle to guarantee this. TransformBundle is now deprecated. [GlobalTransform] is automatically inserted whenever [Transform] is inserted.

[Transform] and [GlobalTransform]

[Transform] is the position of an entity relative to its parent position, or the reference frame if it doesn't have a Parent.

[GlobalTransform] is the position of an entity relative to the reference frame.

[GlobalTransform] is updated from [Transform] by systems in the system set TransformPropagate.

This system runs during PostUpdate. If you update the [Transform] of an entity during this set or after, you will notice a 1 frame lag before the [GlobalTransform] is updated.

Examples

Functions

FunctionSummary
back(_self) Equivalent to [`local_z()`][Transform::local_z]
clone(_self)No Documentation 🚧
compute_affine(_self) Returns the 3d affine transformation matrix from this transforms translation, rotation, and scale.
compute_matrix(_self) Returns the 3d affine transformation matrix from this transforms translation, rotation, and scale.
down(_self) Equivalent to [`-local_y()`][Transform::local_y]
eq(_self, other)No Documentation 🚧
forward(_self) Equivalent to [`-local_z()`][Transform::local_z]
from_isometry(iso) Creates a new [`Transform`] that is equivalent to the given [isometry]. [isometry]: Isometry3d
from_matrix(world_from_local) Extracts the translation, rotation, and scale from `matrix`. It must be a 3d affine transformation
from_rotation(rotation) Creates a new [`Transform`], with `rotation`. Translation will be 0 and scale 1 on all axes.
from_scale(scale) Creates a new [`Transform`], with `scale`. Translation will be 0 and rotation 0 on all axes.
from_translation(translation) Creates a new [`Transform`], with `translation`. Rotation will be 0 and scale 1 on all axes.
from_xyz(x, y, z) Creates a new [`Transform`] at the position `(x, y, z)`. In 2d, the `z` component is used for z-ordering elements: higher `z`-value will be in front of lower `z`-value.
is_finite(_self) Returns `true` if, and only if, translation, rotation and scale all are finite. If any of them con
left(_self) Equivalent to [`-local_x()`][Transform::local_x()]
local_x(_self) Get the unit vector in the local `X` direction.
local_y(_self) Get the unit vector in the local `Y` direction.
local_z(_self) Get the unit vector in the local `Z` direction.
mul(_self, value)No Documentation 🚧
mul-1(arg0, arg1)No Documentation 🚧
mul-2(arg0, arg1)No Documentation 🚧
mul_transform(_self, transform) Multiplies `self` with `transform` component by component, returning the resulting [`Transform`]
right(_self) Equivalent to [`local_x()`][Transform::local_x()]
rotate(_self, rotation) Rotates this [`Transform`] by the given rotation. If this [`Transform`] has a parent, the `rotation`
rotate_around(_self, point, rotation) Rotates this [`Transform`] around a `point` in space. If this [`Transform`] has a parent, the `point`
rotate_axis(_self, axis, angle) Rotates this [`Transform`] around the given `axis` by `angle` (in radians). If this [`Transform`]
rotate_local(_self, rotation) Rotates this [`Transform`] by the given `rotation`. The `rotation` is relative to this [`Transform
rotate_local_axis(_self, axis, angle) Rotates this [`Transform`] around its local `axis` by `angle` (in radians).
rotate_local_x(_self, angle) Rotates this [`Transform`] around its local `X` axis by `angle` (in radians).
rotate_local_y(_self, angle) Rotates this [`Transform`] around its local `Y` axis by `angle` (in radians).
rotate_local_z(_self, angle) Rotates this [`Transform`] around its local `Z` axis by `angle` (in radians).
rotate_x(_self, angle) Rotates this [`Transform`] around the `X` axis by `angle` (in radians). If this [`Transform`] has
rotate_y(_self, angle) Rotates this [`Transform`] around the `Y` axis by `angle` (in radians). If this [`Transform`] has
rotate_z(_self, angle) Rotates this [`Transform`] around the `Z` axis by `angle` (in radians). If this [`Transform`] has
to_isometry(_self) Get the [isometry] defined by this transform's rotation and translation, ignoring scale. [isometry
transform_point(_self, point) Transforms the given `point`, applying scale, rotation and translation. If this [`Transform`] has an ancestor entity with a [`Transform`]
translate_around(_self, point, rotation) Translates this [`Transform`] around a `point` in space. If this [`Transform`] has a parent, the `point`
up(_self) Equivalent to [`local_y()`][Transform::local_y]
with_rotation(_self, rotation) Returns this [`Transform`] with a new rotation.
with_scale(_self, scale) Returns this [`Transform`] with a new scale.
with_translation(_self, translation) Returns this [`Transform`] with a new translation.