Skip to main content

mln_engine/camera/
frame_projection.rs

1//! Where a frame drew the map, for a host that draws into the frame
2//! depth-tested against it. The renderer computes it
3//! (`crate::render::frame_projection`); it lives here so that layers that a
4//! frame lends its commands to, which get it with them, can name it.
5
6use glam::DMat4;
7pub use mln_gfx::gpu::ClipDepthRange;
8
9/// Where a frame drew the map, and the depth its 3D layers wrote there.
10#[derive(Clone, Copy, Debug, PartialEq)]
11pub struct FrameProjection {
12    /// Takes points of the map's world square, Web Mercator's or a
13    /// registered projection's, x and y from 0 to 1 and z in meters, to
14    /// clip coordinates in `clip_depth_range`'s convention, whose depth
15    /// under the API's default depth range is the depth that the frame's 3D
16    /// layers wrote at the point.
17    pub matrix: DMat4,
18    pub clip_depth_range: ClipDepthRange,
19    /// The distance from the camera to the plane where that depth is 0, in
20    /// pixels at the camera's zoom.
21    pub near_distance: f64,
22    /// The distance to the plane where the depth is `far_depth`.
23    pub far_distance: f64,
24    /// The depth at `far_distance`, below the 2D layers' depths.
25    pub far_depth: f64,
26    /// Whether the frame drew a globe, which `matrix` doesn't describe.
27    pub globe: bool,
28}