pub struct Projection3d { /* private fields */ }Expand description
The 3D projection which can be either perspective or orthographic
Implementations§
Source§impl Projection3d
impl Projection3d
Sourcepub fn perspective(
viewport_width: u16,
viewport_height: u16,
fovy: Rad<f32>,
) -> Self
pub fn perspective( viewport_width: u16, viewport_height: u16, fovy: Rad<f32>, ) -> Self
Create a new 3D perspective projection
§Panics
Viewport width or height is zero:
// panics:
let perspective = Projection3d::perspective (0, 240, math::Deg (90.0).into());If fovy is greater than or equal to $\pi$ radians:
// panics:
let perspective = Projection3d::perspective (320, 240, math::Rad (4.0));If fovy is less than or equal to $0.0$ radians:
// panics:
let perspective = Projection3d::perspective (320, 240, math::Rad (0.0));Sourcepub fn orthographic(
viewport_width: u16,
viewport_height: u16,
zoom: f32,
) -> Self
pub fn orthographic( viewport_width: u16, viewport_height: u16, zoom: f32, ) -> Self
pub const fn viewport_width(&self) -> u16
pub const fn viewport_height(&self) -> u16
Sourcepub const fn as_matrix(&self) -> &Matrix4<f32>
pub const fn as_matrix(&self) -> &Matrix4<f32>
Returns a reference to the underlying projection matrix
pub const fn is_orthographic(&self) -> bool
pub const fn is_perspective(&self) -> bool
Sourcepub fn to_orthographic(&mut self, zoom: f32)
pub fn to_orthographic(&mut self, zoom: f32)
Converts the inner projection type to an Orthographic projection with
the given zoom; if already an orthographic projection this will modify
the zoom
Sourcepub fn to_perspective(&mut self, fovy: Rad<f32>)
pub fn to_perspective(&mut self, fovy: Rad<f32>)
Converts the inner projection type to a Perspective projection with the
given vertical FOV; if already a perspective projection this will modify
the FOV
Sourcepub fn set_viewport_dimensions(
&mut self,
viewport_width: u16,
viewport_height: u16,
)
pub fn set_viewport_dimensions( &mut self, viewport_width: u16, viewport_height: u16, )
Sourcepub fn scale_fovy_or_zoom(&mut self, scale: f32)
pub fn scale_fovy_or_zoom(&mut self, scale: f32)
Multiply the current perspective vertical FOV or orthographic zoom by the given scale factor.
Will not increase vertical FOV greater than $\pi$ radians, nor will it decrease the zoom or vertical FOV to zero.
§Panics
Panics if scale factor is zero or negative:
let mut camera3d = Camera3d::new (320, 240);
camera3d.scale_fovy_or_zoom (-1.0); // panicsTrait Implementations§
Source§impl Clone for Projection3d
impl Clone for Projection3d
Source§fn clone(&self) -> Projection3d
fn clone(&self) -> Projection3d
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Projection3d
impl Debug for Projection3d
Source§impl PartialEq for Projection3d
impl PartialEq for Projection3d
impl StructuralPartialEq for Projection3d
Auto Trait Implementations§
impl Freeze for Projection3d
impl RefUnwindSafe for Projection3d
impl Send for Projection3d
impl Sync for Projection3d
impl Unpin for Projection3d
impl UnwindSafe for Projection3d
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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