Skip to content

struct

Camera

pub struct Camera {
    pub position: Vec3,
    pub target: Vec3,
    pub fov_deg: f32,
    pub near: f32,
    pub far: f32,
}

A scene's camera: where it is, what it looks at, and its field of view and clipping planes.

Fields

position

pub position: Vec3

Where the camera is.

target

pub target: Vec3

The point it looks at.

fov_deg

pub fov_deg: f32

Vertical field of view, in degrees.

near

pub near: f32

The near clipping plane's distance.

far

pub far: f32

The far clipping plane's distance.

Methods

view

pub fn view(&self) -> Mat4

The view matrix: from the world to the camera.

projection

pub fn projection(&self, aspect: f32) -> Mat4

The perspective projection for a surface of aspect (width / height).

view_projection

pub fn view_projection(&self, aspect: f32) -> Mat4

Projection and view together.

Trait implementations