pub enum Projection {
Perspective {
fov_y: f32,
aspect: f32,
near: f32,
far: f32,
},
Orthographic {
height: f32,
aspect: f32,
near: f32,
far: f32,
},
}Expand description
How a camera maps view space to clip space.
Orthographic projection is offered as a first-class choice because it is often the physically correct one: parallel lines stay parallel and distances compare across the image.
Variants§
Perspective
Perspective projection with a vertical field of view in radians.
Fields
Orthographic
Orthographic projection with an explicit vertical extent.
Implementations§
Source§impl Projection
impl Projection
Sourcepub fn fit_near_far(&mut self, eye: Vec3, bound: &BoundingSphere)
pub fn fit_near_far(&mut self, eye: Vec3, bound: &BoundingSphere)
Refits the near and far planes to a world-space bounding sphere seen
from eye looking toward the sphere. Called on camera change so the
depth range always brackets the scene tightly.
Sourcepub fn set_aspect(&mut self, new_aspect: f32)
pub fn set_aspect(&mut self, new_aspect: f32)
Updates the aspect ratio, preserving everything else.
Trait Implementations§
Source§impl Clone for Projection
impl Clone for Projection
impl Copy for Projection
Source§impl Debug for Projection
impl Debug for Projection
Source§impl<'de> Deserialize<'de> for Projection
impl<'de> Deserialize<'de> for Projection
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for Projection
impl PartialEq for Projection
Source§impl Serialize for Projection
impl Serialize for Projection
impl StructuralPartialEq for Projection
Auto Trait Implementations§
impl Freeze for Projection
impl RefUnwindSafe for Projection
impl Send for Projection
impl Sync for Projection
impl Unpin for Projection
impl UnsafeUnpin for Projection
impl UnwindSafe for Projection
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> 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> 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 more