Skip to main content

yog_body/
camera.rs

1//! The camera: where the local player's view is and how it turns, changed
2//! by mods each frame (after vanilla placed it).
3
4use crate::math::Vec3;
5
6/// The camera as vanilla placed it this frame.
7#[derive(Debug, Clone, Default, PartialEq)]
8pub struct CameraFrame {
9    /// The entity the camera follows.
10    pub uuid: String,
11    pub partial: f32,
12    /// World position of the camera.
13    pub pos: [f64; 3],
14    /// Degrees.
15    pub yaw: f32,
16    pub pitch: f32,
17    /// Third person (behind or in front).
18    pub detached: bool,
19    /// `entity_flags` bits of the entity.
20    pub flags: u32,
21}
22
23/// What mods change; each handler gets the last one's result and adds to it.
24#[derive(Debug, Clone, Copy, PartialEq)]
25pub struct CameraOut {
26    /// Blocks, along the camera's own axes: right, up, forward.
27    pub local_offset: Vec3,
28    /// Blocks, in the world.
29    pub world_offset: Vec3,
30    /// Degrees added to the view.
31    pub yaw: f32,
32    pub pitch: f32,
33    /// Tilt about the view direction.
34    pub roll: f32,
35    /// Multiplies the field of view.
36    pub fov: f32,
37}
38
39impl Default for CameraOut {
40    fn default() -> Self {
41        Self { local_offset: Vec3::ZERO, world_offset: Vec3::ZERO, yaw: 0.0, pitch: 0.0, roll: 0.0, fov: 1.0 }
42    }
43}