Skip to main content

Camera3D

Struct Camera3D 

Source
pub struct Camera3D { /* private fields */ }
Expand description

3D perspective camera supporting free-fly, third-person follow, yaw/pitch orbit, and frustum culling.

Implementations§

Source§

impl Camera3D

Orientation, movement, and view-projection helpers for Camera3D.

Source

pub fn forward(&self) -> Vec3

Returns the unit forward look vector derived from (yaw, pitch).

§Arguments
  • &Self - Camera reference.
§Returns
  • Vec3 - Forward unit vector.
Source

pub fn right(&self) -> Vec3

Returns the unit right vector orthogonal to forward() and world up.

§Arguments
  • &Self - Camera reference.
§Returns
  • Vec3 - Right unit vector.
Source

pub fn focal_length_to_fov_deg( focal_length_mm: f32, sensor_height_mm: f32, ) -> f32

Converts a physical camera focal length and full-frame sensor height in millimeters to vertical FOV degrees.

§Arguments
  • f32 - Lens focal length in millimeters (e.g., 24.0, 35.0, 50.0, 85.0).
  • f32 - Camera sensor height in millimeters (24.0 for 35mm full-frame).
§Returns
  • f32 - Vertical field of view in degrees clamped to [12.0, 120.0].
Source

pub fn from_lens( position: Vec3, yaw: f32, pitch: f32, focal_length_mm: f32, ) -> Self

Constructs a physically based 35mm full-frame Camera3D using lens focal length in millimeters.

§Arguments
  • Vec3 - World-space eye position.
  • f32 - Horizontal yaw angle in radians.
  • f32 - Vertical pitch angle in radians.
  • f32 - Lens focal length in millimeters.
§Returns
  • Self - Physically configured perspective camera.
Source

pub fn ev100(aperture_fstop: f32, shutter_seconds: f32, iso: f32) -> f32

Computes physical exposure value EV100 from lens aperture (f-stop), shutter speed (seconds), and ISO.

§Arguments
  • f32 - Aperture f-number (e.g., 2.8, 4.0, 8.0).
  • f32 - Shutter exposure time in seconds (e.g., 1.0 / 125.0).
  • f32 - Sensor ISO sensitivity (e.g., 100.0).
§Returns
  • f32 - Physical exposure value EV100.
Source

pub fn exposure_scale_from_ev100(ev100: f32) -> f32

Converts an EV100 exposure value into a linear HDR scene exposure multiplier.

§Arguments
  • f32 - Physical exposure value EV100.
§Returns
  • f32 - Linear exposure multiplier clamped to [0.05, 8.0].
Source

pub fn look_at(&mut self, target: Vec3)

Orients this camera’s yaw and pitch to aim directly at target.

§Arguments
  • &Self - Mutable camera reference.
  • Vec3 - World-space look target.
Source

pub fn lerp(self, other: Self, alpha: f32) -> Self

Linearly interpolates camera position, shortest-arc yaw, pitch, and lens parameters between self and other.

§Arguments
  • Self - Previous fixed-step 3D camera state.
  • Self - Current fixed-step 3D camera state.
  • f32 - Normalized interpolation factor in [0.0, 1.0].
§Returns
  • Self - Interpolated 3D camera.
Source

pub fn view_projection(&self, aspect: f32) -> Mat4

Computes the combined projection * view matrix for viewport aspect.

§Arguments
  • &Self - Camera reference.
  • f32 - Viewport aspect ratio width / height.
§Returns
  • Mat4 - View-projection matrix.
Source§

impl Camera3D

Source

pub fn get_position(&self) -> Vec3

Source

pub fn get_mut_position(&mut self) -> &mut Vec3

Source

pub fn set_position(&mut self, val: Vec3) -> &mut Self

Source

pub fn get_yaw(&self) -> f32

Source

pub fn get_mut_yaw(&mut self) -> &mut f32

Source

pub fn set_yaw(&mut self, val: f32) -> &mut Self

Source

pub fn get_pitch(&self) -> f32

Source

pub fn get_mut_pitch(&mut self) -> &mut f32

Source

pub fn set_pitch(&mut self, val: f32) -> &mut Self

Source

pub fn get_fov_deg(&self) -> f32

Source

pub fn get_mut_fov_deg(&mut self) -> &mut f32

Source

pub fn set_fov_deg(&mut self, val: f32) -> &mut Self

Source

pub fn get_near(&self) -> f32

Source

pub fn get_mut_near(&mut self) -> &mut f32

Source

pub fn set_near(&mut self, val: f32) -> &mut Self

Source

pub fn get_far(&self) -> f32

Source

pub fn get_mut_far(&mut self) -> &mut f32

Source

pub fn set_far(&mut self, val: f32) -> &mut Self

Trait Implementations§

Source§

impl Clone for Camera3D

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Camera3D

Source§

impl Debug for Camera3D

Source§

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

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

impl Default for Camera3D

Default 3D camera framing an open-world street boulevard.

Source§

fn default() -> Self

Creates a default street-level perspective camera.

§Returns
  • Self - Default Camera3D.
Source§

impl PartialEq for Camera3D

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Camera3D

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.