Skip to main content

CameraController

Struct CameraController 

Source
pub struct CameraController;
Expand description

Stateless helper that maps InputEvents to camera mutations.

All methods are associated functions (no self) because the controller carries no state – it is a pure function namespace. The actual state lives in Camera and CameraConstraints.

Implementations§

Source§

impl CameraController

Source

pub fn zoom( camera: &mut Camera, factor: f64, cursor_x: Option<f64>, cursor_y: Option<f64>, constraints: &CameraConstraints, )

Zoom by a multiplicative factor (>1 zooms in, <1 zooms out).

Non-finite, zero, and negative factors are silently ignored.

Source

pub fn rotate( camera: &mut Camera, delta_yaw: f64, delta_pitch: f64, constraints: &CameraConstraints, )

Rotate the camera by delta yaw and delta pitch (radians).

Pitch is clamped to CameraConstraints; yaw wraps freely (normalized to [-?, ?] by the setter).

Source

pub fn pan( camera: &mut Camera, dx: f64, dy: f64, cursor_x: Option<f64>, cursor_y: Option<f64>, )

Pan the camera by a screen-space pixel delta.

Source

pub fn handle_event( camera: &mut Camera, event: InputEvent, constraints: &CameraConstraints, )

Dispatch an InputEvent to the appropriate handler.

Touch events are ignored here — they should be routed through the GestureRecognizer first, which produces derived Pan/Zoom/Rotate events.

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