CameraFrame

Struct CameraFrame 

Source
pub struct CameraFrame {
    pub pos: DVec3,
    pub up: DVec3,
    pub facing: DVec3,
    pub scale: f64,
    pub fovy: f64,
    pub near: f64,
    pub far: f64,
    pub perspective_blend: f64,
}
Expand description

The data of a camera

The CameraFrame has a CameraFrame::perspective_blend property (default is 0.0), which is used to blend between orthographic and perspective projection.

Fields§

§pos: DVec3

The position

§up: DVec3

The up unit vec

§facing: DVec3

The facing unit vec

§scale: f64

The scaling factor, used in orthographic projection

§fovy: f64

The field of view angle, used in perspective projection

§near: f64

The near pane

§far: f64

The far pane

§perspective_blend: f64

The perspective blend value in [0.0, 1.0]

Implementations§

Source§

impl CameraFrame

Source

pub fn new() -> Self

Create a new CameraFrame at the origin facing to the negative z-axis and use Y as up vector with default projection settings.

Source§

impl CameraFrame

Source

pub fn view_matrix(&self) -> DMat4

The view matrix of the camera

Source

pub fn orthographic_mat(&self, frame_height: f64, aspect_ratio: f64) -> DMat4

Use the given frame size as left, right, bottom, top to construct an orthographic matrix

Source

pub fn perspective_mat(&self, aspect_ratio: f64) -> DMat4

Use the given frame aspect ratio to construct a perspective matrix

Source

pub fn projection_matrix(&self, frame_height: f64, aspect_ratio: f64) -> DMat4

Use the given frame size to construct projection matrix

Source

pub fn view_projection_matrix( &self, frame_height: f64, aspect_ratio: f64, ) -> DMat4

Use the given frame size to construct view projection matrix

Source§

impl CameraFrame

Source

pub fn center_canvas_in_frame( &mut self, center: DVec3, width: f64, height: f64, up: DVec3, normal: DVec3, aspect_ratio: f64, ) -> &mut Self

Center the canvas in the frame when CameraFrame::perspective_blend is 1.0

Trait Implementations§

Source§

impl Alignable for CameraFrame

Source§

fn is_aligned(&self, _other: &Self) -> bool

Checking if two items are aligned
Source§

fn align_with(&mut self, _other: &mut Self)

Aligning two items
Source§

impl Clone for CameraFrame

Source§

fn clone(&self) -> CameraFrame

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CameraFrame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CameraFrame

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Interpolatable for CameraFrame

Source§

fn lerp(&self, target: &Self, t: f64) -> Self

Lerping between values
Source§

impl PartialEq for CameraFrame

Source§

fn eq(&self, other: &CameraFrame) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Primitive for CameraFrame

Source§

fn build_primitives<T: IntoIterator<Item = Self>>(iter: T) -> Primitives

Build primitives
Source§

impl StructuralPartialEq for CameraFrame

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Extract for T
where T: Primitive + Clone,

Source§

type Target = T

The extraction result
Source§

fn extract(&self) -> Vec<<T as Extract>::Target>

Extract a Extract::Target from reference.
Source§

fn extract_to_primitives(&self) -> Primitives

Extract to Primitive from reference.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> With for T

Source§

fn with(self, f: impl Fn(&mut Self)) -> Self
where Self: Sized,

Mutating a value inplace
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Component for T
where T: Debug + Default + Clone + PartialEq,