Where a picture is taken from: a position, a facing, and a projection.
The world is right-handed with z up. yaw turns about z, 0 facing +x and
:math.pi() / 2 facing +y; pitch above zero looks up; roll above zero tips the
picture clockwise. A :perspective camera sees fov radians across; an
:orthographic one sees extent world units across, the same at every distance.
Cauldron3D.Camera.first_person({0.0, 0.0, 56.0}, yaw, pitch)
Cauldron3D.Camera.follow(target, yaw, distance: 120.0, height: 40.0)
Cauldron3D.Camera.side(target, extent: 640.0)
Cauldron3D.Camera.top_down(target, extent: 1024.0)
Summary
Functions
The camera's axes in the world: {forward, right, up}, each of length one.
A perspective camera at position looking along yaw and pitch. Takes new/1's options.
A perspective camera behind target, facing along yaw and looking down at it.
The direction yaw and pitch face, of length one.
A camera from options: :position, :yaw, :pitch, :roll, :projection, :fov,
:extent and :near, each defaulting as the struct does.
An orthographic camera looking across the world at target from the -y side, as a
side-scroller sees it. :extent (default 512.0) is how wide the view is; :distance
(default 4096.0) how far back it stands.
An orthographic camera looking straight down at target, +y at the top of the
picture. :extent (default 512.0) is how wide the view is; :distance (default
4096.0) how high it hangs.
Types
@type projection() :: :perspective | :orthographic
@type t() :: %Cauldron3D.Camera{ extent: float(), fov: float(), near: float(), pitch: float(), position: Cauldron3D.Vec.t(), projection: projection(), roll: float(), yaw: float() }
Functions
@spec basis(t()) :: {Cauldron3D.Vec.t(), Cauldron3D.Vec.t(), Cauldron3D.Vec.t()}
The camera's axes in the world: {forward, right, up}, each of length one.
@spec first_person(Cauldron3D.Vec.t(), number(), number(), keyword()) :: t()
A perspective camera at position looking along yaw and pitch. Takes new/1's options.
@spec follow(Cauldron3D.Vec.t(), number(), keyword()) :: t()
A perspective camera behind target, facing along yaw and looking down at it.
Options
:distance— how far behind, default 128.0:height— how far above the target the camera sits, default 48.0:look_height— the height above the target the camera aims at, default 0.0- anything
new/1takes
@spec forward(number(), number()) :: Cauldron3D.Vec.t()
The direction yaw and pitch face, of length one.
A camera from options: :position, :yaw, :pitch, :roll, :projection, :fov,
:extent and :near, each defaulting as the struct does.
@spec side(Cauldron3D.Vec.t(), keyword()) :: t()
An orthographic camera looking across the world at target from the -y side, as a
side-scroller sees it. :extent (default 512.0) is how wide the view is; :distance
(default 4096.0) how far back it stands.
@spec top_down(Cauldron3D.Vec.t(), keyword()) :: t()
An orthographic camera looking straight down at target, +y at the top of the
picture. :extent (default 512.0) is how wide the view is; :distance (default
4096.0) how high it hangs.