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
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) -> Self
pub fn with_view_matrix(self, view_matrix: DMat4) -> Self
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) -> Self
pub fn from_spherical(phi: f64, theta: f64, distance: f64) -> Self
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 Self
pub fn set_spherical( &mut self, phi: f64, theta: f64, distance: f64, target: DVec3, ) -> &mut Self
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 Self
pub fn look_at(&mut self, target: DVec3) -> &mut Self
Set the camera to look at a target point.
Sourcepub fn orbit(&mut self, target: DVec3, total_angle: f64) -> AnimationCell<Self>
pub fn orbit(&mut self, target: DVec3, total_angle: f64) -> AnimationCell<Self>
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 Self
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
impl Alignable for CameraFrame
Source§fn is_aligned(&self, _other: &Self) -> bool
fn is_aligned(&self, _other: &Self) -> bool
Source§fn align_with(&mut self, _other: &mut Self)
fn align_with(&mut self, _other: &mut Self)
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§impl Extract for CameraFrame
impl Extract for CameraFrame
Source§impl Interpolatable for CameraFrame
impl Interpolatable for 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§
§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
§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)§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> 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