pub struct CameraAnimator {
pub momentum_decay: f64,
pub smoothing: f64,
/* private fields */
}Expand description
Drives smooth camera transitions.
Supports three animation modes that may be active simultaneously:
- Fly-to / ease-to – a coordinated multi-property transition (only one may be active at a time; starting one cancels the other).
- Simple targets – independent exponential-smoothed zoom / yaw / pitch targets (useful for scroll-zoom, keyboard rotation).
- Momentum – inertial pan that decays over time.
Call tick every frame with the elapsed dt.
Fields§
§momentum_decay: f64Momentum decay factor per second (0..1, 0 = instant stop).
smoothing: f64Smoothing factor for simple zoom/rotate targets (0 = instant, higher = smoother).
Implementations§
Source§impl CameraAnimator
impl CameraAnimator
Sourcepub fn start_fly_to(&mut self, camera: &mut Camera, options: &FlyToOptions)
pub fn start_fly_to(&mut self, camera: &mut Camera, options: &FlyToOptions)
Start a van Wijk fly-to animation.
This implements the “optimal path” algorithm from van Wijk & Nuij
(2003), matching MapLibre/Mapbox flyTo behavior. The camera
simultaneously interpolates center, zoom, bearing, and pitch along
a zoom-out-then-zoom-in arc.
Cancels any active fly-to, ease-to, simple targets, and momentum.
If the requested transition is degenerate (no change or exceeds
max_duration), a jump_to is performed instead.
Sourcepub fn start_ease_to(&mut self, camera: &mut Camera, options: &EaseToOptions)
pub fn start_ease_to(&mut self, camera: &mut Camera, options: &EaseToOptions)
Start a simple ease-to animation.
Linearly interpolates center, zoom, bearing, and pitch over the specified duration with configurable easing.
Cancels any active fly-to, ease-to, simple targets, and momentum.
Sourcepub fn animate_zoom(&mut self, target_distance: f64)
pub fn animate_zoom(&mut self, target_distance: f64)
Set a zoom animation target (distance in meters).
Non-finite or non-positive distances are ignored.
Sourcepub fn animate_rotate(&mut self, target_yaw: f64, target_pitch: f64)
pub fn animate_rotate(&mut self, target_yaw: f64, target_pitch: f64)
Set rotation animation targets.
Non-finite angles are ignored independently.
Sourcepub fn apply_momentum(&mut self, vx: f64, vy: f64)
pub fn apply_momentum(&mut self, vx: f64, vy: f64)
Apply pan momentum in world meters/second.
Non-finite inputs are ignored.