pub struct Camera3D {
pub transform: NodeTransform,
pub fov: f32,
pub is_active: bool,
pub priority: i32,
pub exposure: f32,
/* private fields */
}Expand description
A 3D camera that can be use in a 3d environment.
Fields§
§transform: NodeTransformthe NodeTransform of the camera (every node has this)
fov: f32the field of view of the camera in radians
is_active: bool§priority: i32§exposure: f32Implementations§
Source§impl Camera3D
impl Camera3D
Sourcepub fn rotate_camera(&mut self, offset: impl Into<Vec3>, sensitivity: f32)
pub fn rotate_camera(&mut self, offset: impl Into<Vec3>, sensitivity: f32)
rotate the camera while keeping the roll at 0
§Arguments
offset- The offset to rotate the camera by a 3d vectorsensitivity- The sensitivity of the rotation
Sourcepub fn set_position(&mut self, position: impl Into<Vec3>)
pub fn set_position(&mut self, position: impl Into<Vec3>)
pub fn far_plane(&self) -> f32
pub fn near_plane(&self) -> f32
Sourcepub fn get_position(&self, parent_transform: NodeTransform) -> Vec3
pub fn get_position(&self, parent_transform: NodeTransform) -> Vec3
Sourcepub fn set_orientation_vector(
&mut self,
orientation: impl Into<Vec3>,
) -> &mut Camera3D
pub fn set_orientation_vector( &mut self, orientation: impl Into<Vec3>, ) -> &mut Camera3D
set the orientation vector of the camera
§Arguments
orientation- The new orientation vector of the camera
Sourcepub fn get_orientation_vector(&self) -> Vec3
pub fn get_orientation_vector(&self) -> Vec3
Sourcepub fn get_orientation_angles(&self) -> Vec3
pub fn get_orientation_angles(&self) -> Vec3
Sourcepub fn set_orientation_angles(&mut self, angles: impl Into<Vec3>)
pub fn set_orientation_angles(&mut self, angles: impl Into<Vec3>)
set the orientation angles of the camera
§Arguments
angles- The new orientation angles of the camera
Sourcepub fn get_view_matrix(&self) -> Mat4
pub fn get_view_matrix(&self) -> Mat4
Sourcepub fn get_projection_matrix(&self, aspect_ratio: f32) -> Mat4
pub fn get_projection_matrix(&self, aspect_ratio: f32) -> Mat4
Sourcepub fn get_projection_matrix_with_planes(
&self,
aspect_ratio: f32,
near: f32,
far: f32,
) -> Mat4
pub fn get_projection_matrix_with_planes( &self, aspect_ratio: f32, near: f32, far: f32, ) -> Mat4
useful for shadow mapping
Sourcepub fn get_vp_matrix(&self, aspect_ratio: f32) -> Mat4
pub fn get_vp_matrix(&self, aspect_ratio: f32) -> Mat4
pub fn get_buffer_data(&self, aspect_ratio: f32) -> Camera3DBufferData
Sourcepub fn free_look(sensitivity: f32) -> impl Fn(EventCtx<'_, Update, Camera3D>)
pub fn free_look(sensitivity: f32) -> impl Fn(EventCtx<'_, Update, Camera3D>)
allows the mouse to rotate the camera in a first person way.
this returns a function that can be used as a event_callback
uses camera.sensitivity to factor the look speed. add this function to the update callback to enable the camera to move with the mouse.
Sourcepub fn free_fly(
speed: f32,
sensitivity: f32,
) -> impl Fn(EventCtx<'_, Update, Camera3D>)
pub fn free_fly( speed: f32, sensitivity: f32, ) -> impl Fn(EventCtx<'_, Update, Camera3D>)
take input for the camera and implement basic free cam movement
this returns a function that can be used as a event_callback
§Arguments
input_manager- The input manager to get input fromdelta_time- The time between frames
Trait Implementations§
Source§impl Node for Camera3D
impl Node for Camera3D
Source§fn get_transform(&mut self) -> &mut NodeTransform
fn get_transform(&mut self) -> &mut NodeTransform
gets the transform of the node. Read more
Auto Trait Implementations§
impl Freeze for Camera3D
impl RefUnwindSafe for Camera3D
impl Send for Camera3D
impl Sync for Camera3D
impl Unpin for Camera3D
impl UnsafeUnpin for Camera3D
impl UnwindSafe for Camera3D
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
Mutably borrows from an owned value. Read more
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&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> 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>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn 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>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which 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)
Converts
&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)
Converts
&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> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
Converts
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>
Converts
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> SendSync for T
impl<T> SendSync for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.