pub struct CameraState {
pub target: Vec3,
pub distance: f32,
pub yaw: f32,
pub pitch: f32,
}Expand description
Fields§
§target: Vec3Look-at point in world space.
distance: f32Eye distance from target. Multiplicative zoom_by
keeps the perceived zoom rate constant at any scale.
yaw: f32Azimuth around +Y, radians.
pitch: f32Elevation, radians; clamped to ±~85° by orbit.
Implementations§
Source§impl CameraState
impl CameraState
Sourcepub fn orbit(&mut self, d_yaw: f32, d_pitch: f32)
pub fn orbit(&mut self, d_yaw: f32, d_pitch: f32)
Orbit by angular deltas (radians). Pitch clamps near the poles so the up vector never degenerates.
Sourcepub fn zoom_by(&mut self, factor: f32)
pub fn zoom_by(&mut self, factor: f32)
Multiply the eye distance by factor, clamped to a sane range.
factor > 1 pulls the camera back. Multiplicative so a scroll notch
covers proportional distance whether near or far.
Sourcepub fn pan_by(&mut self, delta: Vec3)
pub fn pan_by(&mut self, delta: Vec3)
Translate the look-at point by a world-space delta (pan).
Sourcepub fn fit_distance(radius: f32) -> f32
pub fn fit_distance(radius: f32) -> f32
Distance at which a sphere of radius exactly fills the vertical fov.
Sourcepub fn fitted(&self, content: Aabb) -> CameraState
pub fn fitted(&self, content: Aabb) -> CameraState
A copy framed on content: target at the centre and distance
fit to the bounds, preserving the current orbit angles. Empty
bounds leave a unit sphere at the origin. This is the framing
operation Framing::Fit / Auto apply.
Sourcepub fn framing(content: Aabb) -> CameraState
pub fn framing(content: Aabb) -> CameraState
Default angles, framed on content. The auto-framed starting pose.
Sourcepub fn look_at(&mut self, target: Vec3, distance: f32)
pub fn look_at(&mut self, target: Vec3, distance: f32)
Point the camera at target from distance, keeping orbit angles.
Sourcepub fn focused(&self, focus: Focus) -> CameraState
pub fn focused(&self, focus: Focus) -> CameraState
A copy satisfying a Focus request, preserving orbit angles. The
keyed camera springs toward this when the request changes.
Sourcepub fn resolve(&self, view_bounds: Aabb) -> ResolvedCamera
pub fn resolve(&self, view_bounds: Aabb) -> ResolvedCamera
Resolve to a concrete camera. view_bounds is everything that
should stay inside the frustum (content and the reference grid /
axes) — near/far are sized from the eye’s distance to that, not
from the content radius, so geometry larger than the data (a big
grid) is never plane-clipped. The pose is taken as-is; framing
(fitting to data) is applied by the caller before resolving.
Trait Implementations§
Source§impl Clone for CameraState
impl Clone for CameraState
Source§fn clone(&self) -> CameraState
fn clone(&self) -> CameraState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CameraState
impl Debug for CameraState
Source§impl Default for CameraState
impl Default for CameraState
Source§impl PartialEq for CameraState
impl PartialEq for CameraState
Source§fn eq(&self, other: &CameraState) -> bool
fn eq(&self, other: &CameraState) -> bool
self and other values to be equal, and is used by ==.impl Copy for CameraState
impl StructuralPartialEq for CameraState
Auto Trait Implementations§
impl Freeze for CameraState
impl RefUnwindSafe for CameraState
impl Send for CameraState
impl Sync for CameraState
impl Unpin for CameraState
impl UnsafeUnpin for CameraState
impl UnwindSafe for CameraState
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.