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 - projection —
Projection::PerspectiveorProjection::Orthographic
Implementations§
Source§impl Camera
impl Camera
Sourcepub fn new_perspective(
position: DVec3,
focal_point: DVec3,
fov_y_deg: f64,
) -> Self
pub fn new_perspective( position: DVec3, focal_point: DVec3, fov_y_deg: f64, ) -> Self
Create a perspective camera with a conventional Y-up configuration.
Sourcepub fn new_orthographic(
position: DVec3,
focal_point: DVec3,
parallel_scale: f64,
) -> Self
pub fn new_orthographic( position: DVec3, focal_point: DVec3, parallel_scale: f64, ) -> Self
Create an orthographic camera with a conventional Y-up configuration.
Sourcepub fn new(position: DVec3, focal_point: DVec3, view_up: DVec3) -> Self
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.
Sourcepub fn with_clip_range(self, near: f64, far: f64) -> Self
pub fn with_clip_range(self, near: f64, far: f64) -> Self
Override the clip range.
Sourcepub fn with_projection(self, projection: Projection) -> Self
pub fn with_projection(self, projection: Projection) -> Self
Override the projection type.
Sourcepub fn focal_point(&self) -> DVec3
pub fn focal_point(&self) -> DVec3
The point the camera looks at.
Sourcepub fn forward(&self) -> DVec3
pub fn forward(&self) -> DVec3
World-space vector pointing from position to focal point (normalised).
Sourcepub fn direction(&self) -> DVec3
pub fn direction(&self) -> DVec3
Alias for Self::forward, matching the plan terminology.
Sourcepub fn right_vector(&self) -> DVec3
pub fn right_vector(&self) -> DVec3
Alias for Self::right, matching VTK-style naming.
Sourcepub fn view_up_ortho(&self) -> DVec3
pub fn view_up_ortho(&self) -> DVec3
Orthogonalised view-up vector.
Sourcepub fn clip_range(&self) -> (f64, f64)
pub fn clip_range(&self) -> (f64, f64)
The (near, far) clip distances.
Sourcepub fn projection(&self) -> &Projection
pub fn projection(&self) -> &Projection
The current projection type.
Sourcepub fn view_matrix(&self) -> DMat4
pub fn view_matrix(&self) -> DMat4
View (world-to-camera) matrix.
Sourcepub fn projection_matrix(&self, aspect: f64) -> DMat4
pub fn projection_matrix(&self, aspect: f64) -> DMat4
Projection matrix for the given viewport aspect ratio.
aspect = viewport_width / viewport_height.
Sourcepub fn dolly(&mut self, delta: f64)
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.
Sourcepub fn zoom(&mut self, factor: f64)
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.
Sourcepub fn pan(&mut self, delta: DVec3)
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.
Sourcepub fn pan_view(&mut self, dx: f64, dy: f64)
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.
Sourcepub fn azimuth(&mut self, degrees: f64)
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.
Sourcepub fn elevation(&mut self, degrees: f64)
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.
Sourcepub fn roll(&mut self, degrees: f64)
pub fn roll(&mut self, degrees: f64)
Rotate the view-up vector around the forward axis by degrees.
Sourcepub fn orbit(&mut self, angle_h: f64, angle_v: f64)
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.
Sourcepub fn reset_to_bounds(
&mut self,
bounds_min: DVec3,
bounds_max: DVec3,
_aspect: f64,
)
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.