Skip to main content

CameraState

Struct CameraState 

Source
pub struct CameraState {
    pub target: Vec3,
    pub distance: f32,
    pub yaw: f32,
    pub pitch: f32,
}
Expand description

Absolute, persistent orbit-camera pose for one scene. World-space — not re-derived from content each frame (see Framing). Defaults to a pleasant three-quarter view of a unit sphere at the origin; fitted re-frames it to data, gestures and programmatic moves mutate it.

Fields§

§target: Vec3

Look-at point in world space.

§distance: f32

Eye distance from target. Multiplicative zoom_by keeps the perceived zoom rate constant at any scale.

§yaw: f32

Azimuth around +Y, radians.

§pitch: f32

Elevation, radians; clamped to ±~85° by orbit.

Implementations§

Source§

impl CameraState

Source

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.

Source

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.

Source

pub fn pan_by(&mut self, delta: Vec3)

Translate the look-at point by a world-space delta (pan).

Source

pub fn fit_distance(radius: f32) -> f32

Distance at which a sphere of radius exactly fills the vertical fov.

Source

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.

Source

pub fn framing(content: Aabb) -> CameraState

Default angles, framed on content. The auto-framed starting pose.

Source

pub fn look_at(&mut self, target: Vec3, distance: f32)

Point the camera at target from distance, keeping orbit angles.

Source

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.

Source

pub fn eye(&self) -> Vec3

World-space eye position implied by the pose.

Source

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

Source§

fn clone(&self) -> CameraState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CameraState

Source§

impl Debug for CameraState

Source§

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

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

impl Default for CameraState

Source§

fn default() -> Self

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

impl PartialEq for CameraState

Source§

fn eq(&self, other: &CameraState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for CameraState

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.