# `ExRatatui.ThreeD.Camera`
[🔗](https://github.com/mcass19/ex_ratatui/blob/v0.13.0/lib/ex_ratatui/three_d/camera.ex#L1)

A perspective camera looking at a target.

The camera is plain data; `orbit/3` and `zoom/2` are pure helpers that return a
new camera, so an application drives them from key events and keeps the result
in its own state.

## Fields

  * `:position` - `{x, y, z}` eye position
  * `:target` - `{x, y, z}` look-at point
  * `:up` - `{x, y, z}` up vector (defaults to `+Y`)
  * `:fov` - vertical field of view in radians (defaults to `pi/4`)
  * `:near` - near clip plane (defaults to `0.1`)
  * `:far` - far clip plane (defaults to `100.0`)

## Examples

    iex> %ExRatatui.ThreeD.Camera{}
    %ExRatatui.ThreeD.Camera{
      position: {0.0, 2.0, 5.0},
      target: {0.0, 0.0, 0.0},
      up: {0.0, 1.0, 0.0},
      fov: 0.7853981633974483,
      near: 0.1,
      far: 100.0
    }

    iex> cam = %ExRatatui.ThreeD.Camera{position: {0.0, 0.0, 5.0}}
    iex> ExRatatui.ThreeD.Camera.zoom(cam, -2.0).position
    {0.0, 0.0, 3.0}

# `t`

```elixir
@type t() :: %ExRatatui.ThreeD.Camera{
  far: float(),
  fov: float(),
  near: float(),
  position: vec3(),
  target: vec3(),
  up: vec3()
}
```

# `vec3`

```elixir
@type vec3() :: {number(), number(), number()}
```

# `orbit`

```elixir
@spec orbit(t(), number(), number()) :: t()
```

Orbit the camera around its target by `yaw` and `pitch` deltas (radians).

Pitch is clamped to avoid gimbal lock at the poles.

# `zoom`

```elixir
@spec zoom(t(), number()) :: t()
```

Move the camera toward or away from its target along the view direction.

A positive `delta` moves farther; the distance is clamped to a small minimum.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
