pub struct CameraFrame {
pub pos: DVec3,
pub up: DVec3,
pub facing: DVec3,
pub near: f64,
pub far: f64,
pub perspective_blend: f64,
pub frame_height: f64,
pub scale: f64,
pub fovy: 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: DVec3The position
up: DVec3The up unit vec
facing: DVec3The facing unit vec
near: f64The near pane
far: f64The far pane
perspective_blend: f64The perspective blend value in [0.0, 1.0]
frame_height: f64Ortho: Top - Bottom
scale: f64Ortho: The scaling factor
fovy: f64Perspective: The field of view angle, used in perspective projection
Implementations§
Source§impl CameraFrame
impl CameraFrame
Sourcepub fn new() -> CameraFrame
pub fn new() -> CameraFrame
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
impl CameraFrame
Sourcepub fn set_view_matrix(&mut self, view_matrix: DMat4)
pub fn set_view_matrix(&mut self, view_matrix: DMat4)
Set the view matrix of the camera.
Sourcepub fn with_view_matrix(self, view_matrix: DMat4) -> CameraFrame
pub fn with_view_matrix(self, view_matrix: DMat4) -> CameraFrame
Set the view matrix of the camera and return the modified Self.
Sourcepub fn view_matrix(&self) -> DMat4
pub fn view_matrix(&self) -> DMat4
The view matrix of the camera
Sourcepub fn orthographic_mat(&self, aspect_ratio: f64) -> DMat4
pub fn orthographic_mat(&self, aspect_ratio: f64) -> DMat4
Use the given frame size as left, right, bottom, top to construct an orthographic matrix
Sourcepub fn perspective_mat(&self, aspect_ratio: f64) -> DMat4
pub fn perspective_mat(&self, aspect_ratio: f64) -> DMat4
Use the given frame aspect ratio to construct a perspective matrix
Sourcepub fn projection_matrix(&self, aspect_ratio: f64) -> DMat4
pub fn projection_matrix(&self, aspect_ratio: f64) -> DMat4
Use the given frame size to construct projection matrix
Sourcepub fn view_projection_matrix(&self, aspect_ratio: f64) -> DMat4
pub fn view_projection_matrix(&self, aspect_ratio: f64) -> DMat4
Use the given frame size to construct view projection matrix
Source§impl CameraFrame
impl CameraFrame
Sourcepub fn from_spherical(phi: f64, theta: f64, distance: f64) -> CameraFrame
pub fn from_spherical(phi: f64, theta: f64, distance: f64) -> CameraFrame
Create a perspective camera positioned using spherical coordinates (Z-up), looking at the origin.
phi: polar angle from +Z axis in radians (0 = straight up along +Z, π/2 = XY plane)theta: azimuth angle in radians (0 = +X direction, π/2 = +Y direction)distance: distance from the origin
Sourcepub fn set_spherical(
&mut self,
phi: f64,
theta: f64,
distance: f64,
target: DVec3,
) -> &mut CameraFrame
pub fn set_spherical( &mut self, phi: f64, theta: f64, distance: f64, target: DVec3, ) -> &mut CameraFrame
Position the camera using spherical coordinates (Z-up) around a target point.
phi: polar angle from +Z axis in radians (0 = straight up along +Z, π/2 = XY plane)theta: azimuth angle in radians (0 = +X direction, π/2 = +Y direction)distance: distance fromtargettarget: the point the camera looks at
Sourcepub fn look_at(&mut self, target: DVec3) -> &mut CameraFrame
pub fn look_at(&mut self, target: DVec3) -> &mut CameraFrame
Set the camera to look at a target point.
Sourcepub fn orbit(
&mut self,
target: DVec3,
total_angle: f64,
) -> AnimationCell<CameraFrame>
pub fn orbit( &mut self, target: DVec3, total_angle: f64, ) -> AnimationCell<CameraFrame>
Create an orbit animation that rotates the camera around target
by total_angle radians in the XY plane (Z-up).
The camera’s current position is used to derive the spherical coordinates (distance, elevation) which are kept constant during the orbit.
§Example
use std::f64::consts::TAU;
let mut cam = CameraFrame::from_spherical(phi, theta, distance);
let r_cam = r.insert(cam.clone());
r.timeline_mut(r_cam).play(
cam.orbit(DVec3::ZERO, TAU)
.with_duration(8.0)
.with_rate_func(linear),
);Source§impl CameraFrame
impl CameraFrame
Sourcepub fn center_canvas_in_frame(
&mut self,
center: DVec3,
width: f64,
height: f64,
up: DVec3,
normal: DVec3,
aspect_ratio: f64,
) -> &mut CameraFrame
pub fn center_canvas_in_frame( &mut self, center: DVec3, width: f64, height: f64, up: DVec3, normal: DVec3, aspect_ratio: f64, ) -> &mut CameraFrame
Center the canvas in the frame when CameraFrame::perspective_blend is 1.0
Trait Implementations§
Source§impl Alignable for CameraFrame
impl Alignable for CameraFrame
Source§fn is_aligned(&self, _other: &CameraFrame) -> bool
fn is_aligned(&self, _other: &CameraFrame) -> bool
Source§fn align_with(&mut self, _other: &mut CameraFrame)
fn align_with(&mut self, _other: &mut CameraFrame)
Source§impl Clone for CameraFrame
impl Clone for CameraFrame
Source§fn clone(&self) -> CameraFrame
fn clone(&self) -> CameraFrame
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CameraFrame
impl Debug for CameraFrame
Source§impl Default for CameraFrame
impl Default for CameraFrame
Source§fn default() -> CameraFrame
fn default() -> CameraFrame
Source§impl Extract for CameraFrame
impl Extract for CameraFrame
Source§fn extract_into(&self, buf: &mut Vec<<CameraFrame as Extract>::Target>)
fn extract_into(&self, buf: &mut Vec<<CameraFrame as Extract>::Target>)
Extract::Target from reference.Source§impl Interpolatable for CameraFrame
impl Interpolatable for CameraFrame
Source§fn lerp(&self, target: &CameraFrame, t: f64) -> CameraFrame
fn lerp(&self, target: &CameraFrame, t: f64) -> CameraFrame
Source§impl PartialEq for CameraFrame
impl PartialEq for CameraFrame
impl StructuralPartialEq for CameraFrame
Auto Trait Implementations§
impl Freeze for CameraFrame
impl RefUnwindSafe for CameraFrame
impl Send for CameraFrame
impl Sync for CameraFrame
impl Unpin for CameraFrame
impl UnwindSafe for CameraFrame
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.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>
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Filterable for T
impl<T> Filterable for T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> FuncAnim for Twhere
T: FuncRequirement + 'static,
impl<T> FuncAnim for Twhere
T: FuncRequirement + 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
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 moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> MorphAnim for Twhere
T: MorphRequirement + 'static,
impl<T> MorphAnim for Twhere
T: MorphRequirement + 'static,
Source§fn morph<F>(&mut self, f: F) -> AnimationCell<T>
fn morph<F>(&mut self, f: F) -> AnimationCell<T>
Morph anim with a func.Source§fn morph_from(&mut self, s: T) -> AnimationCell<T>
fn morph_from(&mut self, s: T) -> AnimationCell<T>
Morph anim from src.Source§fn morph_to(&mut self, d: T) -> AnimationCell<T>
fn morph_to(&mut self, d: T) -> AnimationCell<T>
Morph anim to dst.§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<T> StaticAnim for Twhere
T: StaticAnimRequirement + 'static,
impl<T> StaticAnim for Twhere
T: StaticAnimRequirement + 'static,
Source§fn show(&self) -> AnimationCell<T>
fn show(&self) -> AnimationCell<T>
Source§fn hide(&self) -> AnimationCell<T>
fn hide(&self) -> AnimationCell<T>
Source§impl<T> StrictAs for T
impl<T> StrictAs for T
Source§fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
Source§impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
Source§fn strict_cast_from(src: Src) -> Dst
fn strict_cast_from(src: Src) -> Dst
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more