pub struct ActiveCamera2d { /* private fields */ }Expand description
The only active world camera, with a fixed-step-interpolated center.
FixedUpdate code changes the canonical center through
ActiveCamera2d::set_center or ActiveCamera2d::pan_by. The runtime
retains the previous center and extraction presents an interpolated copy of
the wrapped Sim;Engine camera. Zoom, rotation, and projection remain the
static values supplied at construction in this slice.
FrameUpdate Systems cannot request mutable access to this component.
Extraction also fails when a World contains zero or more than one enabled
ActiveCamera2d. This component intentionally denotes the fixed-owned
active camera and does not add a Transform2d; its wrapped camera center
is the sole position source. A future frame-driven camera must use a
distinct camera source instead of changing this component’s ownership at
runtime.
Implementations§
Source§impl ActiveCamera2d
impl ActiveCamera2d
Sourcepub const fn new(camera: Camera2d) -> Self
pub const fn new(camera: Camera2d) -> Self
Marks a validated Sim;Engine camera as active and snaps its history.
Sourcepub fn centered(zoom: f32) -> Result<Self, Camera2dError>
pub fn centered(zoom: f32) -> Result<Self, Camera2dError>
Creates an active camera centered at the world origin.
zoom is logical screen pixels per world unit and must be finite and
positive. Validation is delegated to Camera2d::new. Use
ActiveCamera2d::new when the initial center is not the origin.
Sourcepub const fn camera(&self) -> Camera2d
pub const fn camera(&self) -> Camera2d
Returns the current canonical Sim;Engine camera value.
During a partial fixed interval this can differ from the presentation
camera returned by crate::ExtractedFrame::camera.
Sourcepub fn previous_center(&self) -> Vec2
pub fn previous_center(&self) -> Vec2
Returns the previous center endpoint retained for interpolation.
Sourcepub fn set_center(&mut self, center: Vec2) -> Result<(), Camera2dError>
pub fn set_center(&mut self, center: Vec2) -> Result<(), Camera2dError>
Replaces the canonical center after Sim;Engine validation.
The previous center is retained for fixed-step interpolation. Use
ActiveCamera2d::teleport_center when the change must be immediate.
Sourcepub fn pan_by(&mut self, delta: Vec2) -> Result<(), Camera2dError>
pub fn pan_by(&mut self, delta: Vec2) -> Result<(), Camera2dError>
Applies a validated world-space offset to the canonical center.
Sourcepub fn teleport_center(&mut self, center: Vec2) -> Result<(), Camera2dError>
pub fn teleport_center(&mut self, center: Vec2) -> Result<(), Camera2dError>
Replaces both center interpolation endpoints with one validated value.
Trait Implementations§
Source§impl Clone for ActiveCamera2d
impl Clone for ActiveCamera2d
Source§impl Component for ActiveCamera2d
impl Component for ActiveCamera2d
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 ActiveCamera2d
Source§impl Debug for ActiveCamera2d
impl Debug for ActiveCamera2d
Source§impl PartialEq for ActiveCamera2d
impl PartialEq for ActiveCamera2d
impl StructuralPartialEq for ActiveCamera2d
Auto Trait Implementations§
impl Freeze for ActiveCamera2d
impl RefUnwindSafe for ActiveCamera2d
impl Send for ActiveCamera2d
impl Sync for ActiveCamera2d
impl Unpin for ActiveCamera2d
impl UnsafeUnpin for ActiveCamera2d
impl UnwindSafe for ActiveCamera2d
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.