Struct bevy::transform::components::GlobalTransform
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
impl GlobalTransform
impl GlobalTransform
pub const IDENTITY: GlobalTransform = Self(Affine3A::IDENTITY)
pub const IDENTITY: GlobalTransform = Self(Affine3A::IDENTITY)
An identity GlobalTransform
that maps all points in space to themselves.
pub fn compute_matrix(&self) -> Mat4
pub fn compute_matrix(&self) -> Mat4
Returns the 3d affine transformation matrix as a Mat4
.
pub 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.
pub 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.
pub fn translation(&self) -> Vec3
pub fn translation(&self) -> Vec3
Get the translation as a Vec3
.
pub fn translation_mut(&mut self) -> &mut Vec3A
pub fn translation_mut(&mut self) -> &mut Vec3A
Mutably access the internal translation.
pub fn translation_vec3a(&self) -> Vec3A
pub fn translation_vec3a(&self) -> Vec3A
Get the translation as a Vec3A
.
pub 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
.
pub 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
.
pub fn mul_transform(&self, transform: Transform) -> GlobalTransform
pub fn mul_transform(&self, transform: Transform) -> GlobalTransform
Multiplies self
with transform
component by component, returning the
resulting GlobalTransform
Trait Implementations
impl Clone for GlobalTransform
impl Clone for GlobalTransform
fn 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 moreimpl Component for GlobalTransformwhere
GlobalTransform: 'static + Send + Sync,
impl Component for GlobalTransformwhere
GlobalTransform: 'static + Send + Sync,
type Storage = TableStorage
impl Debug for GlobalTransform
impl Debug for GlobalTransform
impl Default for GlobalTransform
impl Default for GlobalTransform
fn default() -> GlobalTransform
fn default() -> GlobalTransform
impl From<Affine3A> for GlobalTransform
impl From<Affine3A> for GlobalTransform
fn from(affine: Affine3A) -> GlobalTransform
fn from(affine: Affine3A) -> GlobalTransform
impl 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.
fn from(transform: GlobalTransform) -> Transform
fn from(transform: GlobalTransform) -> Transform
impl From<Mat4> for GlobalTransform
impl From<Mat4> for GlobalTransform
fn from(matrix: Mat4) -> GlobalTransform
fn from(matrix: Mat4) -> GlobalTransform
impl From<Transform> for GlobalTransform
impl From<Transform> for GlobalTransform
fn from(transform: Transform) -> GlobalTransform
fn from(transform: Transform) -> GlobalTransform
impl FromReflect for GlobalTransformwhere
Affine3A: FromReflect,
impl FromReflect for GlobalTransformwhere
Affine3A: FromReflect,
fn from_reflect(reflect: &(dyn Reflect + 'static)) -> Option<GlobalTransform>
fn from_reflect(reflect: &(dyn Reflect + 'static)) -> Option<GlobalTransform>
Self
from a reflected value.impl GetTypeRegistration for GlobalTransform
impl GetTypeRegistration for GlobalTransform
impl Mul<GlobalTransform> for GlobalTransform
impl Mul<GlobalTransform> for GlobalTransform
type Output = GlobalTransform
type Output = GlobalTransform
*
operator.fn mul(
self,
global_transform: GlobalTransform
) -> <GlobalTransform as Mul<GlobalTransform>>::Output
fn mul(
self,
global_transform: GlobalTransform
) -> <GlobalTransform as Mul<GlobalTransform>>::Output
*
operation. Read moreimpl Mul<Transform> for GlobalTransform
impl Mul<Transform> for GlobalTransform
type Output = GlobalTransform
type Output = GlobalTransform
*
operator.impl Mul<Vec3> for GlobalTransform
impl Mul<Vec3> for GlobalTransform
impl PartialEq<GlobalTransform> for GlobalTransform
impl PartialEq<GlobalTransform> for GlobalTransform
fn eq(&self, other: &GlobalTransform) -> bool
fn eq(&self, other: &GlobalTransform) -> bool
impl Reflect for GlobalTransform
impl Reflect for GlobalTransform
fn get_type_info(&self) -> &'static TypeInfo
fn get_type_info(&self) -> &'static TypeInfo
fn into_any(
self: Box<GlobalTransform, Global>
) -> Box<dyn Any + 'static, Global>
fn into_any(
self: Box<GlobalTransform, Global>
) -> Box<dyn Any + 'static, Global>
Box<dyn Any>
.fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut dyn Any
.fn into_reflect(
self: Box<GlobalTransform, Global>
) -> Box<dyn Reflect + 'static, Global>
fn into_reflect(
self: Box<GlobalTransform, Global>
) -> Box<dyn Reflect + 'static, Global>
fn as_reflect(&self) -> &(dyn Reflect + 'static)
fn as_reflect(&self) -> &(dyn Reflect + 'static)
fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
fn clone_value(&self) -> Box<dyn Reflect + 'static, Global>
fn clone_value(&self) -> Box<dyn Reflect + 'static, Global>
Reflect
trait object. Read morefn set(
&mut self,
value: Box<dyn Reflect + 'static, Global>
) -> Result<(), Box<dyn Reflect + 'static, Global>>
fn set(
&mut self,
value: Box<dyn Reflect + 'static, Global>
) -> Result<(), Box<dyn Reflect + 'static, Global>>
fn apply(&mut self, value: &(dyn Reflect + 'static))
fn apply(&mut self, value: &(dyn Reflect + 'static))
fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_owned(self: Box<GlobalTransform, Global>) -> ReflectOwned
fn reflect_owned(self: Box<GlobalTransform, Global>) -> ReflectOwned
fn reflect_partial_eq(&self, value: &(dyn Reflect + 'static)) -> Option<bool>
fn reflect_partial_eq(&self, value: &(dyn Reflect + 'static)) -> Option<bool>
fn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
fn serializable(&self) -> Option<Serializable<'_>>
fn serializable(&self) -> Option<Serializable<'_>>
impl TupleStruct for GlobalTransform
impl TupleStruct for GlobalTransform
fn field_mut(&mut self, index: usize) -> Option<&mut (dyn Reflect + 'static)>
fn field_mut(&mut self, index: usize) -> Option<&mut (dyn Reflect + 'static)>
index
as a &mut dyn Reflect
. Read morefn iter_fields(&self) -> TupleStructFieldIter<'_>ⓘ
fn iter_fields(&self) -> TupleStructFieldIter<'_>ⓘ
fn clone_dynamic(&self) -> DynamicTupleStruct
fn clone_dynamic(&self) -> DynamicTupleStruct
DynamicTupleStruct
.impl 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
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist. Read moresourceimpl<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
impl<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 moreimpl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given Worldimpl<T> GetPath for Twhere
T: Reflect,
impl<T> GetPath for Twhere
T: Reflect,
fn 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 morefn 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 morefn 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
.fn 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