pub struct Camera { /* private fields */ }Expand description
Semantic camera value.
Composes a Transform (placement) with lens parameters (projection shape).
get_view_matrix derives from the transform’s position and forward direction.
get_projection_matrix uses the lens parameters with Vulkan clip-space
conventions (reversed-Y, depth [0, 1]).
Donor: oa::Camera / oa::FnCamera.
Implementations§
Source§impl Camera
impl Camera
Sourcepub fn new_perspective(
position: Vec3,
target: Vec3,
fov_y: f32,
aspect: f32,
near: f32,
far: f32,
) -> Self
pub fn new_perspective( position: Vec3, target: Vec3, fov_y: f32, aspect: f32, near: f32, far: f32, ) -> Self
Create a perspective camera.
fov_y is in degrees. near and far must be finite, positive, and
near < far. aspect must be finite and positive.
Sourcepub fn new_orthographic(width: f32, height: f32, near: f32, far: f32) -> Self
pub fn new_orthographic(width: f32, height: f32, near: f32, far: f32) -> Self
Create an orthographic camera.
Sourcepub fn transform_mut(&mut self) -> &mut Transform
pub fn transform_mut(&mut self) -> &mut Transform
Return a mutable reference to the placement transform.
Sourcepub fn set_position(&mut self, position: Vec3)
pub fn set_position(&mut self, position: Vec3)
Set the camera position.
Sourcepub const fn projection(&self) -> CameraProjection
pub const fn projection(&self) -> CameraProjection
Return the current projection kind.
Sourcepub fn effective_fov_y(&self) -> f32
pub fn effective_fov_y(&self) -> f32
Return the effective vertical field of view in degrees, applying zoom.
Matches donor getEffectiveFovY: fov_y / zoom clamped to (0°, 180°).
Sourcepub fn set_perspective(&mut self, fov_y: f32, aspect: f32, near: f32, far: f32)
pub fn set_perspective(&mut self, fov_y: f32, aspect: f32, near: f32, far: f32)
Set perspective projection parameters.
Sourcepub fn set_orthographic(&mut self, width: f32, height: f32, near: f32, far: f32)
pub fn set_orthographic(&mut self, width: f32, height: f32, near: f32, far: f32)
Set orthographic projection parameters.
Sourcepub fn set_aspect(&mut self, aspect: f32)
pub fn set_aspect(&mut self, aspect: f32)
Set aspect ratio without changing other perspective parameters.
Sourcepub fn fit_to_window(&mut self, window_width: f32, window_height: f32)
pub fn fit_to_window(&mut self, window_width: f32, window_height: f32)
Adjust aspect ratio and orthographic extent to match a window size.
Sourcepub fn get_view_matrix(&self) -> Mat4
pub fn get_view_matrix(&self) -> Mat4
Compute the row-vector view matrix from the placement transform.
The camera faces its local -Z axis (OA convention). Returns an identity view when the forward vector is degenerate.
Sourcepub fn get_projection_matrix(&self) -> Mat4
pub fn get_projection_matrix(&self) -> Mat4
Compute the row-vector projection matrix in Vulkan clip space.
Perspective: reversed-Y (NDC Y points down) and Vulkan depth [0, 1]. Orthographic: likewise.
Sourcepub fn get_view_projection_matrix(&self) -> Mat4
pub fn get_view_projection_matrix(&self) -> Mat4
Compute the combined view-projection matrix.
Sourcepub fn set_orbit_target(&mut self, target: Vec3)
pub fn set_orbit_target(&mut self, target: Vec3)
Set the orbit pivot.
Sourcepub fn set_orbit_distance(&mut self, distance: f32)
pub fn set_orbit_distance(&mut self, distance: f32)
Set the orbit radius without changing the pivot or angles.
Sourcepub fn orbit_yaw_pitch(&mut self, yaw_delta: f32, pitch_delta: f32)
pub fn orbit_yaw_pitch(&mut self, yaw_delta: f32, pitch_delta: f32)
Apply incremental yaw (around world Y) and pitch (around local right) deltas.
Sourcepub fn orbit_set_yaw_pitch(&mut self, yaw: f32, pitch: f32)
pub fn orbit_set_yaw_pitch(&mut self, yaw: f32, pitch: f32)
Set absolute yaw and pitch around the orbit pivot.