viewport_lib/runtime/camera_follow.rs
1//! Camera tracking binding for follow-camera behavior.
2
3use crate::interaction::select::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 emits it as a [`super::CameraFollowTarget`] event on
9/// [`super::RuntimeOutput::events`]. The app reads the event by calling
10/// `output.events.read::<CameraFollowTarget>()` and applies the suggestion
11/// however fits the application (typically by setting `camera.center`).
12///
13/// Set via [`super::ViewportRuntime::set_camera_follow`] or
14/// [`super::ViewportRuntime::with_camera_follow`].
15#[derive(Debug, Clone)]
16pub enum CameraFollow {
17 /// Track a scene node.
18 ///
19 /// The suggested center is `node_world_pos + offset`. Orbit camera distance
20 /// and orientation are unaffected; the camera pivots around the moving target.
21 Node {
22 /// Node to follow.
23 id: NodeId,
24 /// World-space offset added to the node's position.
25 offset: glam::Vec3,
26 /// Unused by the runtime itself. Apps may use it to decide whether to
27 /// orient the camera toward the node.
28 look_at: bool,
29 },
30 /// No tracking. The runtime does not emit `CameraFollowTarget`.
31 Free,
32}