Skip to main content

OrbitCamera

Struct OrbitCamera 

Source
pub struct OrbitCamera { /* private fields */ }
Expand description

A third-person camera that orbits a smoothly following focus point.

Implementations§

Source§

impl OrbitCamera

Source

pub fn new(target: Vector<f32>) -> Self

Creates a camera looking at target from the default yaw.

Source

pub fn facing(target: Vector<f32>, yaw: f32, config: CameraConfig) -> Self

Creates a camera looking at target from yaw, with config.

Source

pub fn config(&self) -> &CameraConfig

Returns the configuration.

Source

pub fn set_config(&mut self, config: CameraConfig)

Replaces the configuration. The next follow eases the camera toward the new distance.

Source

pub fn rotate(&mut self, delta: [f32; 2])

Rotates the camera by [yaw, pitch] deltas in radians. Pitch is clamped to the configured range.

Source

pub fn yaw(&self) -> f32

Current yaw in radians.

Source

pub fn set_yaw(&mut self, yaw: f32)

Sets the yaw directly in radians. Use this when the consumer drives the orientation absolutely (spherical coordinates, snap-to-step yaw) instead of through rotate deltas.

Source

pub fn pitch(&self) -> f32

Current pitch in radians.

Source

pub fn set_pitch(&mut self, pitch: f32)

Sets the pitch directly in radians, clamped to the configured range.

Source

pub fn focus(&self) -> Vector<f32>

Current focus point.

Source

pub fn set_focus(&mut self, focus: Vector<f32>)

Sets the focus point directly, bypassing the easing in follow. Use this when the consumer drives the look-at target itself (cutscenes, custom focus logic).

Source

pub fn distance(&self) -> f32

Current orbit distance from the focus point to the eye.

Source

pub fn set_distance(&mut self, distance: f32)

Sets the orbit distance directly, bypassing the easing in follow. Use this to drive the distance from a custom model (absolute zoom, aim modes) or a custom clip pass.

Source

pub fn zoom(&mut self, amount: f32)

Zooms by amount. Positive zooms in. Clamped to the configured range.

Source

pub fn follow(&mut self, target: Vector<f32>, timestep: f32)

Eases the focus point toward target and the orbit distance toward its pitch-derived goal, frame-rate independently over timestep seconds.

Source

pub fn clip<C: Clip>(&mut self, world: &C)

Pulls the camera in if world blocks the line of sight from the focus point to the eye.

Source

pub fn eye(&self) -> Vector<f32>

Current eye position.

Source

pub fn eye_at(&self, distance: f32) -> Vector<f32>

Eye position the camera would have at an arbitrary orbit distance, using the current yaw, pitch and focus. Useful for custom clip passes that probe a candidate distance before committing it via set_distance.

Source

pub fn steer_toward( &mut self, look_direction: Vector<f32>, strength: f32, timestep: f32, )

Eases the yaw toward look_direction (projected onto the ground plane), frame-rate independently. Useful for lock-on steering. strength controls how fast.

Source

pub fn forward_xz(&self) -> Vector<f32>

Forward direction projected onto the ground plane.

Source

pub fn right_xz(&self) -> Vector<f32>

Right direction projected onto the ground plane.

Source

pub fn basis(&self) -> MovementBasis

The horizontal movement basis for character input.

Source

pub fn view(&self) -> ViewParameters

The parameters needed to build a view-projection matrix.

Trait Implementations§

Source§

impl Clone for OrbitCamera

Source§

fn clone(&self) -> OrbitCamera

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 OrbitCamera

Source§

impl Debug for OrbitCamera

Source§

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

Formats the value using the given formatter. Read more

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<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> 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.