pub struct Camera {Show 14 fields
pub position: Vec3,
pub target: Vec3,
pub up: Vec3,
pub fov: f32,
pub aspect_ratio: f32,
pub near: f32,
pub far: f32,
pub navigation_style: NavigationStyle,
pub projection_mode: ProjectionMode,
pub up_direction: AxisDirection,
pub front_direction: AxisDirection,
pub move_speed: f32,
pub ortho_scale: f32,
pub flight: Option<CameraFlight>,
}Expand description
A 3D camera for viewing the scene.
Fields§
§position: Vec3Camera position in world space.
target: Vec3Point the camera is looking at.
up: Vec3Up vector.
fov: f32Field of view in radians.
aspect_ratio: f32Aspect ratio (width / height).
near: f32Near clipping plane.
far: f32Far clipping plane.
Navigation style.
projection_mode: ProjectionModeProjection mode.
up_direction: AxisDirectionUp direction.
front_direction: AxisDirectionFront direction.
move_speed: f32Movement speed multiplier.
ortho_scale: f32Orthographic scale (used when projection_mode is Orthographic).
flight: Option<CameraFlight>Active camera flight animation (if any).
Implementations§
Source§impl Camera
impl Camera
Sourcepub fn set_aspect_ratio(&mut self, aspect_ratio: f32)
pub fn set_aspect_ratio(&mut self, aspect_ratio: f32)
Sets the aspect ratio.
Sourcepub fn view_matrix(&self) -> Mat4
pub fn view_matrix(&self) -> Mat4
Returns the view matrix.
Sourcepub fn projection_matrix(&self) -> Mat4
pub fn projection_matrix(&self) -> Mat4
Returns the projection matrix.
Sourcepub fn view_projection_matrix(&self) -> Mat4
pub fn view_projection_matrix(&self) -> Mat4
Returns the combined view-projection matrix.
Sourcepub fn camera_up(&self) -> Vec3
pub fn camera_up(&self) -> Vec3
Returns the camera’s local up direction (from the view matrix).
Sourcepub fn orbit_turntable(&mut self, delta_x: f32, delta_y: f32)
pub fn orbit_turntable(&mut self, delta_x: f32, delta_y: f32)
Turntable orbit: yaw around world-space up, pitch around camera-space right, with gimbal-lock protection. Always looks at target.
Matches C++ Polyscope processRotate for NavigateStyle::Turntable:
operates on the view matrix directly, then reconstructs position via
lookAt. This avoids degenerate cross products at the poles that
occur when transforming the camera position in world space.
Sourcepub fn orbit_free(&mut self, delta_x: f32, delta_y: f32)
pub fn orbit_free(&mut self, delta_x: f32, delta_y: f32)
Free orbit: unconstrained rotation using camera-local axes. Both yaw and pitch use the camera’s own coordinate frame.
Matches C++ Polyscope processRotate for NavigateStyle::Free.
Sourcepub fn orbit_arcball(&mut self, start: [f32; 2], end: [f32; 2])
pub fn orbit_arcball(&mut self, start: [f32; 2], end: [f32; 2])
Arcball orbit: maps 2D mouse positions to a virtual sphere for rotation.
start and end are normalized screen coordinates in [-1, 1].
Matches C++ Polyscope processRotate for NavigateStyle::Arcball.
Sourcepub fn mouse_look(&mut self, delta_x: f32, delta_y: f32)
pub fn mouse_look(&mut self, delta_x: f32, delta_y: f32)
First-person mouse look: yaw around world up, pitch around camera right. Unlike orbit modes, this moves the target (look direction) rather than orbiting around a fixed target.
Matches C++ Polyscope processRotate for NavigateStyle::FirstPerson.
Sourcepub fn move_first_person(&mut self, delta: Vec3)
pub fn move_first_person(&mut self, delta: Vec3)
First-person WASD movement in camera-local coordinates.
delta is (right, up, forward) movement in camera space,
pre-scaled by move_speed and delta time by the caller.
Sourcepub fn orbit(&mut self, delta_x: f32, delta_y: f32)
pub fn orbit(&mut self, delta_x: f32, delta_y: f32)
Legacy orbit method — delegates to orbit_turntable.
Sourcepub fn pan(&mut self, delta_x: f32, delta_y: f32)
pub fn pan(&mut self, delta_x: f32, delta_y: f32)
Pans the camera (translates position and target together). For Turntable mode, this moves the orbit center.
Sourcepub fn zoom(&mut self, delta: f32)
pub fn zoom(&mut self, delta: f32)
Zooms the camera (moves toward/away from target for perspective,
adjusts ortho_scale for orthographic).
Sourcepub fn look_at_box(&mut self, min: Vec3, max: Vec3)
pub fn look_at_box(&mut self, min: Vec3, max: Vec3)
Resets the camera to look at the given bounding box.
Sets the navigation style.
Sourcepub fn set_projection_mode(&mut self, mode: ProjectionMode)
pub fn set_projection_mode(&mut self, mode: ProjectionMode)
Sets the projection mode.
Sourcepub fn set_up_direction(&mut self, direction: AxisDirection)
pub fn set_up_direction(&mut self, direction: AxisDirection)
Sets the up direction and updates both the up vector and front direction. The front direction is automatically derived using right-hand coordinate conventions.
Sourcepub fn set_move_speed(&mut self, speed: f32)
pub fn set_move_speed(&mut self, speed: f32)
Sets the movement speed.
Sourcepub fn set_ortho_scale(&mut self, scale: f32)
pub fn set_ortho_scale(&mut self, scale: f32)
Sets the orthographic scale.
Sourcepub fn start_flight_to(
&mut self,
target_view: Mat4,
target_fov: f32,
duration_secs: f32,
)
pub fn start_flight_to( &mut self, target_view: Mat4, target_fov: f32, duration_secs: f32, )
Starts a smooth animated flight to the given view matrix and FOV.
The target_view is a 4x4 view matrix (world-to-eye). The target_fov
is in radians. duration_secs controls the flight length (C++ Polyscope
default is 0.4 seconds).
Sourcepub fn update_flight(&mut self)
pub fn update_flight(&mut self)
Updates the camera flight animation. Call once per frame.
When the flight completes, the camera is set exactly to the target
position and self.flight is cleared.
Sourcepub fn cancel_flight(&mut self)
pub fn cancel_flight(&mut self)
Cancels any active camera flight animation.
Sourcepub fn is_in_flight(&self) -> bool
pub fn is_in_flight(&self) -> bool
Returns whether a camera flight animation is currently active.
Sourcepub fn fov_degrees(&self) -> f32
pub fn fov_degrees(&self) -> f32
Returns FOV in degrees.
Sourcepub fn set_fov_degrees(&mut self, degrees: f32)
pub fn set_fov_degrees(&mut self, degrees: f32)
Sets FOV from degrees.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Camera
impl RefUnwindSafe for Camera
impl Send for Camera
impl Sync for Camera
impl Unpin for Camera
impl UnsafeUnpin for Camera
impl UnwindSafe for Camera
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().