Struct bevy_transform::components::GlobalTransform
source · pub struct GlobalTransform(_);
Expand description
Describe the position of an entity relative to the reference frame.
- To place or move an entity, you should set its
Transform
. - To get the global transform of an entity, you should get its
GlobalTransform
. - For transform hierarchies to work correctly, you must have both a
Transform
and aGlobalTransform
.- You may use the
TransformBundle
to guarantee this.
- You may use the
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
in the system
transform_propagate_system
.
This system runs in stage CoreStage::PostUpdate
. If you
update the Transform
of an entity in this stage or after, you will notice a 1 frame lag
before the GlobalTransform
is updated.
Examples
Implementations
sourceimpl GlobalTransform
impl GlobalTransform
sourcepub const IDENTITY: Self = _
pub const IDENTITY: Self = _
An identity GlobalTransform
that maps all points in space to themselves.
sourcepub fn compute_matrix(&self) -> Mat4
pub fn compute_matrix(&self) -> Mat4
Returns the 3d affine transformation matrix as a Mat4
.
sourcepub fn compute_transform(&self) -> Transform
pub fn compute_transform(&self) -> Transform
Returns the transformation as a Transform
.
The transform is expected to be non-degenerate and without shearing, or the output will be invalid.
sourcepub fn to_scale_rotation_translation(&self) -> (Vec3, Quat, Vec3)
pub fn to_scale_rotation_translation(&self) -> (Vec3, Quat, Vec3)
Extracts scale
, rotation
and translation
from self
.
The transform is expected to be non-degenerate and without shearing, or the output will be invalid.
sourcepub fn translation(&self) -> Vec3
pub fn translation(&self) -> Vec3
Get the translation as a Vec3
.
sourcepub fn translation_mut(&mut self) -> &mut Vec3A
pub fn translation_mut(&mut self) -> &mut Vec3A
Mutably access the internal translation.
sourcepub fn translation_vec3a(&self) -> Vec3A
pub fn translation_vec3a(&self) -> Vec3A
Get the translation as a Vec3A
.
sourcepub fn radius_vec3a(&self, extents: Vec3A) -> f32
pub fn radius_vec3a(&self, extents: Vec3A) -> f32
Get an upper bound of the radius from the given extents
.
sourcepub fn transform_point(&self, point: Vec3) -> Vec3
pub fn transform_point(&self, point: Vec3) -> Vec3
Transforms the given point
, applying shear, scale, rotation and translation.
This moves point
into the local space of this GlobalTransform
.
sourcepub fn mul_transform(&self, transform: Transform) -> Self
pub fn mul_transform(&self, transform: Transform) -> Self
Multiplies self
with transform
component by component, returning the
resulting GlobalTransform
Trait Implementations
sourceimpl Clone for GlobalTransform
impl Clone for GlobalTransform
sourcefn clone(&self) -> GlobalTransform
fn clone(&self) -> GlobalTransform
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Component for GlobalTransformwhere
Self: Send + Sync + 'static,
impl Component for GlobalTransformwhere
Self: Send + Sync + 'static,
type Storage = TableStorage
sourceimpl Debug for GlobalTransform
impl Debug for GlobalTransform
sourceimpl Default for GlobalTransform
impl Default for GlobalTransform
sourceimpl From<Affine3A> for GlobalTransform
impl From<Affine3A> for GlobalTransform
sourceimpl From<GlobalTransform> for Transform
impl From<GlobalTransform> for Transform
The transform is expected to be non-degenerate and without shearing, or the output will be invalid.
sourcefn from(transform: GlobalTransform) -> Self
fn from(transform: GlobalTransform) -> Self
sourceimpl From<Mat4> for GlobalTransform
impl From<Mat4> for GlobalTransform
sourceimpl From<Transform> for GlobalTransform
impl From<Transform> for GlobalTransform
sourceimpl FromReflect for GlobalTransformwhere
Affine3A: FromReflect,
impl FromReflect for GlobalTransformwhere
Affine3A: FromReflect,
sourcefn from_reflect(reflect: &dyn Reflect) -> Option<Self>
fn from_reflect(reflect: &dyn Reflect) -> Option<Self>
Self
from a reflected value.sourceimpl GetTypeRegistration for GlobalTransform
impl GetTypeRegistration for GlobalTransform
sourceimpl Mul<GlobalTransform> for GlobalTransform
impl Mul<GlobalTransform> for GlobalTransform
type Output = GlobalTransform
type Output = GlobalTransform
*
operator.sourcefn mul(self, global_transform: GlobalTransform) -> Self::Output
fn mul(self, global_transform: GlobalTransform) -> Self::Output
*
operation. Read moresourceimpl Mul<Transform> for GlobalTransform
impl Mul<Transform> for GlobalTransform
sourceimpl Mul<Vec3> for GlobalTransform
impl Mul<Vec3> for GlobalTransform
sourceimpl PartialEq<GlobalTransform> for GlobalTransform
impl PartialEq<GlobalTransform> for GlobalTransform
sourcefn eq(&self, other: &GlobalTransform) -> bool
fn eq(&self, other: &GlobalTransform) -> bool
sourceimpl Reflect for GlobalTransform
impl Reflect for GlobalTransform
sourcefn get_type_info(&self) -> &'static TypeInfo
fn get_type_info(&self) -> &'static TypeInfo
sourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
&mut dyn Any
.sourcefn into_reflect(self: Box<Self>) -> Box<dyn Reflect>
fn into_reflect(self: Box<Self>) -> Box<dyn Reflect>
sourcefn as_reflect(&self) -> &dyn Reflect
fn as_reflect(&self) -> &dyn Reflect
sourcefn as_reflect_mut(&mut self) -> &mut dyn Reflect
fn as_reflect_mut(&mut self) -> &mut dyn Reflect
sourcefn clone_value(&self) -> Box<dyn Reflect>
fn clone_value(&self) -> Box<dyn Reflect>
Reflect
trait object. Read moresourcefn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>
fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>
sourcefn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
sourcefn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
sourcefn reflect_owned(self: Box<Self>) -> ReflectOwned
fn reflect_owned(self: Box<Self>) -> ReflectOwned
sourcefn reflect_partial_eq(&self, value: &dyn Reflect) -> Option<bool>
fn reflect_partial_eq(&self, value: &dyn Reflect) -> Option<bool>
sourcefn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
sourcefn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
sourcefn serializable(&self) -> Option<Serializable<'_>>
fn serializable(&self) -> Option<Serializable<'_>>
sourceimpl TupleStruct for GlobalTransform
impl TupleStruct for GlobalTransform
sourcefn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>
fn field_mut(&mut self, index: usize) -> Option<&mut dyn Reflect>
index
as a &mut dyn Reflect
. Read moresourcefn iter_fields(&self) -> TupleStructFieldIter<'_>
fn iter_fields(&self) -> TupleStructFieldIter<'_>
sourcefn clone_dynamic(&self) -> DynamicTupleStruct
fn clone_dynamic(&self) -> DynamicTupleStruct
DynamicTupleStruct
.sourceimpl Typed for GlobalTransform
impl Typed for GlobalTransform
impl Copy for GlobalTransform
impl StructuralPartialEq for GlobalTransform
Auto Trait Implementations
impl RefUnwindSafe for GlobalTransform
impl Send for GlobalTransform
impl Sync for GlobalTransform
impl Unpin for GlobalTransform
impl UnwindSafe for GlobalTransform
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids(
components: &mut Components,
storages: &mut Storages,
ids: &mut impl FnMut(ComponentId)
)
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> Cwhere
F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a>,
fn get_components(self, func: &mut impl FnMut(OwningPtr<'_>))
impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read morefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read morefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read morefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read moresourceimpl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
sourcefn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given Worldsourceimpl<T> GetPath for Twhere
T: Reflect,
impl<T> GetPath for Twhere
T: Reflect,
sourcefn path<'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
fn path<'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
path
. Read moresourcefn path_mut<'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
fn path_mut<'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
path
. Read moresourcefn get_path<T, 'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r T, ReflectPathError<'p>>where
T: Reflect,
fn get_path<T, 'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r T, ReflectPathError<'p>>where
T: Reflect,
path
.sourcefn get_path_mut<T, 'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut T, ReflectPathError<'p>>where
T: Reflect,
fn get_path_mut<T, 'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut T, ReflectPathError<'p>>where
T: Reflect,
path
. Read more