pub struct Camera {
pub fov: f32,
pub near: f32,
pub far: f32,
pub yaw: f32,
pub pitch: f32,
pub exposure: f32,
pub primary: bool,
pub projection: ProjectionMode,
}Fields§
§fov: f32§near: f32§far: f32§yaw: f32§pitch: f32§exposure: f32§primary: bool§projection: ProjectionModePerspective (default) or orthographic projection. #[serde(default)] keeps
scenes saved before this field was added loading as perspective.
Implementations§
Source§impl Camera
impl Camera
pub fn new( fov: f32, near: f32, far: f32, yaw: f32, pitch: f32, primary: bool, ) -> Camera
Sourcepub fn toggle_projection(&mut self, distance: f32)
pub fn toggle_projection(&mut self, distance: f32)
Toggles between perspective and orthographic projection. When switching to
orthographic, the vertical extent is chosen so the framing roughly matches
the current perspective fov at the given distance from the camera.
Sourcepub fn sanitize_angles(&mut self)
pub fn sanitize_angles(&mut self)
Fazla birikmeyi önlemek icin acilari temizler (yaw mod TAU, pitch clamp)
pub fn get_projection(&self, aspect: f32) -> Mat4
pub fn get_view(&self, position: Vec3) -> Mat4
pub fn get_front(&self) -> Vec3
pub fn get_right(&self) -> Vec3
Sourcepub fn screen_to_ray(
&self,
screen: (f32, f32),
viewport: (f32, f32),
world_pos: Vec3,
) -> Ray
pub fn screen_to_ray( &self, screen: (f32, f32), viewport: (f32, f32), world_pos: Vec3, ) -> Ray
Build a world-space picking ray from a screen/cursor pixel through this
camera — the engine’s screen→world unproject (à la Bevy’s
Camera::viewport_to_world). Combine with PhysicsWorld::raycast (or a
plane intersection) to pick / drag the object under the cursor.
screen— cursor position in pixels, origin top-left (matchesgizmo_core’sInput::mouse_position).viewport— framebuffer size in the same pixels (e.g.WindowInfo).world_pos— the camera’s world position (itsTransform.position, since the view matrix takes the position separately).
The heavy lifting (NDC → world via the inverse view-projection, with
singular-matrix / degenerate-direction guards) is gizmo_math::Ray::from_ndc.
Trait Implementations§
Source§impl Component for Camera
impl Component for Camera
fn storage_type() -> StorageType
impl Copy for Camera
Source§impl<'de> Deserialize<'de> for Camera
impl<'de> Deserialize<'de> for Camera
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Camera, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Camera, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Camera
impl Serialize for Camera
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Camera
Auto Trait Implementations§
impl Freeze for Camera
impl RefUnwindSafe for Camera
impl Send for Camera
impl Sync for Camera
impl Unpin for Camera
impl UnsafeUnpin for Camera
impl UnwindSafe for Camera
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<T> BundleExt for Twhere
T: Bundle,
impl<T> BundleExt for Twhere
T: Bundle,
fn with<C>(self, component: C) -> DynamicBundle<Self, C>where
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> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more