pub struct Transform2d { /* private fields */ }Expand description
Interpolated world-space translation of a managed visual entity.
Fixed-update code changes the current translation through
Transform2d::set_translation or Transform2d::translate_by. The
runtime snapshots the previous value at a fixed-tick boundary. Render
extraction reads both values but never writes the interpolated result back.
FrameUpdate must treat this component as read-only: Sim;Logic rejects
mutable component access when the FrameUpdate System is prepared.
Standard world-space visual and collider components add a default transform
at the world origin when their spawn bundle does not provide one.
Implementations§
Source§impl Transform2d
impl Transform2d
Sourcepub fn new(translation: Vec2) -> Result<Self, VisualValueError>
pub fn new(translation: Vec2) -> Result<Self, VisualValueError>
Creates a transform snapped to one finite world-space translation.
Sourcepub fn from_xy(x: f32, y: f32) -> Result<Self, VisualValueError>
pub fn from_xy(x: f32, y: f32) -> Result<Self, VisualValueError>
Creates a transform snapped to the finite world-space coordinates (x, y).
This is exactly equivalent to Transform2d::new(Vec2::new(x, y)).
Either non-finite coordinate returns
VisualValueError::InvalidTranslation.
Sourcepub const fn translation(&self) -> Vec2
pub const fn translation(&self) -> Vec2
Returns the current canonical world-space translation.
Sourcepub const fn previous_translation(&self) -> Vec2
pub const fn previous_translation(&self) -> Vec2
Returns the previous committed fixed-tick translation.
Sourcepub fn set_translation(
&mut self,
translation: Vec2,
) -> Result<(), VisualValueError>
pub fn set_translation( &mut self, translation: Vec2, ) -> Result<(), VisualValueError>
Replaces the current translation after finite-value validation.
The previous translation is retained for fixed-step interpolation. Use
Transform2d::teleport when the change must not be interpolated.
FrameUpdate Systems cannot request mutable access to this component in
the first-slice runner.
Sourcepub fn translate_by(&mut self, delta: Vec2) -> Result<(), VisualValueError>
pub fn translate_by(&mut self, delta: Vec2) -> Result<(), VisualValueError>
Applies a finite world-space offset atomically.
An invalid offset or arithmetic overflow leaves the transform unchanged. FrameUpdate Systems cannot request mutable access to this component in the first-slice runner.
Sourcepub fn translated_by(&self, delta: Vec2) -> Result<Self, VisualValueError>
pub fn translated_by(&self, delta: Vec2) -> Result<Self, VisualValueError>
Returns a copy with a finite world-space offset applied atomically.
The source and the returned previous interpolation endpoint remain
unchanged. Validation and arithmetic are exactly those of
Transform2d::translate_by. This is useful for checking a proposed
pose before deciding whether to update the live component.
Trait Implementations§
Source§impl Clone for Transform2d
impl Clone for Transform2d
Source§impl Component for Transform2d
impl Component for Transform2d
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor required for working with relationships in dynamic contexts. Read moreSource§fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
Source§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreimpl Copy for Transform2d
Source§impl Debug for Transform2d
impl Debug for Transform2d
Source§impl Default for Transform2d
impl Default for Transform2d
Source§impl PartialEq for Transform2d
impl PartialEq for Transform2d
impl StructuralPartialEq for Transform2d
Auto Trait Implementations§
impl Freeze for Transform2d
impl RefUnwindSafe for Transform2d
impl Send for Transform2d
impl Sync for Transform2d
impl Unpin for Transform2d
impl UnsafeUnpin for Transform2d
impl UnwindSafe for Transform2d
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§fn get_component_ids(
components: &Components,
) -> impl Iterator<Item = Option<ComponentId>>
fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>
Source§impl<C> BundleFromComponents for Cwhere
C: Component,
impl<C> BundleFromComponents for Cwhere
C: Component,
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn 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.Source§fn 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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
Source§unsafe fn get_components(
ptr: MovingPtr<'_, C>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
) -> <C as DynamicBundle>::Effect
unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
Source§unsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> FromTemplate for T
impl<T> FromTemplate for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.