Skip to main content

viewport_lib/runtime/
camera_follow.rs

1//! Camera tracking binding for follow-camera behavior.
2
3use crate::interaction::selection::NodeId;
4
5/// Camera tracking mode for [`super::ViewportRuntime`].
6///
7/// When set, the runtime computes a suggested camera center after each step
8/// and returns it in [`super::RuntimeOutput::camera_follow_target`]. The app
9/// applies the suggestion by setting `camera.center` (for an orbit camera) or
10/// using it however fits the application.
11///
12/// Set via [`super::ViewportRuntime::set_camera_follow`] or
13/// [`super::ViewportRuntime::with_camera_follow`].
14#[derive(Debug, Clone)]
15pub enum CameraFollow {
16    /// Track a scene node.
17    ///
18    /// The suggested center is `node_world_pos + offset`. Orbit camera distance
19    /// and orientation are unaffected; the camera pivots around the moving target.
20    Node {
21        /// Node to follow.
22        id: NodeId,
23        /// World-space offset added to the node's position.
24        offset: glam::Vec3,
25        /// Unused by the runtime itself. Apps may use it to decide whether to
26        /// orient the camera toward the node.
27        look_at: bool,
28    },
29    /// No tracking. The runtime does not set `camera_follow_target`.
30    Free,
31}