Skip to main content

Camera

Struct Camera 

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

Perspective or orthographic camera for volume rendering.

The camera is defined by:

  • position — the eye point in world space
  • focal_point — the point the camera looks at
  • view_up — the “up” direction hint (orthogonalised internally)
  • clip_range(near, far) clipping distances
  • projectionProjection::Perspective or Projection::Orthographic

Implementations§

Source§

impl Camera

Source

pub fn new_perspective( position: DVec3, focal_point: DVec3, fov_y_deg: f64, ) -> Self

Create a perspective camera with a conventional Y-up configuration.

Source

pub fn new_orthographic( position: DVec3, focal_point: DVec3, parallel_scale: f64, ) -> Self

Create an orthographic camera with a conventional Y-up configuration.

Source

pub fn new(position: DVec3, focal_point: DVec3, view_up: DVec3) -> Self

Build a new camera pointed at focal_point from position with view-up view_up.

The clip range defaults to (0.01, 1000.0) and can be adjusted with Camera::with_clip_range.

Source

pub fn with_clip_range(self, near: f64, far: f64) -> Self

Override the clip range.

Source

pub fn with_projection(self, projection: Projection) -> Self

Override the projection type.

Source

pub fn position(&self) -> DVec3

Camera eye position in world space.

Source

pub fn focal_point(&self) -> DVec3

The point the camera looks at.

Source

pub fn forward(&self) -> DVec3

World-space vector pointing from position to focal point (normalised).

Source

pub fn direction(&self) -> DVec3

Alias for Self::forward, matching the plan terminology.

Source

pub fn right(&self) -> DVec3

Orthogonalised right vector (forward × up).

Source

pub fn right_vector(&self) -> DVec3

Alias for Self::right, matching VTK-style naming.

Source

pub fn view_up_ortho(&self) -> DVec3

Orthogonalised view-up vector.

Source

pub fn clip_range(&self) -> (f64, f64)

The (near, far) clip distances.

Source

pub fn projection(&self) -> &Projection

The current projection type.

Source

pub fn distance(&self) -> f64

Distance from position to focal point.

Source

pub fn view_matrix(&self) -> DMat4

View (world-to-camera) matrix.

Source

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

Projection matrix for the given viewport aspect ratio.

aspect = viewport_width / viewport_height.

Source

pub fn dolly(&mut self, delta: f64)

Move the camera along its forward axis (dolly).

Positive delta moves toward the focal point; negative moves away. The focal point stays fixed.

Source

pub fn zoom(&mut self, factor: f64)

Multiply the distance to the focal point by factor (zoom).

Values < 1.0 move closer; values > 1.0 move farther.

Source

pub fn pan(&mut self, delta: DVec3)

Translate both position and focal point in screen-space (pan).

delta is in world-space units; use right() and up_ortho() to convert from screen pixels.

Source

pub fn pan_view(&mut self, dx: f64, dy: f64)

Translate the camera in its view plane.

dx moves along the camera right vector, dy along the orthogonal up vector.

Source

pub fn azimuth(&mut self, degrees: f64)

Rotate the camera position around the focal point about the world Y axis.

This is a convenience wrapper around Camera::orbit.

Source

pub fn elevation(&mut self, degrees: f64)

Rotate the camera position around the focal point about the camera’s right axis.

This is a convenience wrapper around Camera::orbit.

Source

pub fn roll(&mut self, degrees: f64)

Rotate the view-up vector around the forward axis by degrees.

Source

pub fn orbit(&mut self, angle_h: f64, angle_v: f64)

Orbit position around the focal point by rotating angle_h about the world-space up_axis and angle_v about the camera’s right axis.

Implements an arcball-style rotation matching VTK’s trackball style.

Source

pub fn reset_to_bounds( &mut self, bounds_min: DVec3, bounds_max: DVec3, _aspect: f64, )

Auto-fit the camera so the given world-space bounding box is fully visible.

Sets clip_range conservatively around the box.

Trait Implementations§

Source§

impl Clone for Camera

Source§

fn clone(&self) -> Camera

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 Camera

Source§

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

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

impl Default for Camera

Source§

fn default() -> Self

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

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