---
title: Camera
description: Type alias for scene cameras returned by `perspectiveCamera()` and `orthographicCamera()`. Use it when storing a camera without caring which helper produced it.
---

# Camera



## Import

```ts
import type { Camera } from "vgpu/scene";
```

## Signature

```ts
type Camera = import("vgpu/scene").SceneCamera;
```

## Parameters

| Param  | Type          | Required | Default | Notes                                               |
| ------ | ------------- | -------- | ------- | --------------------------------------------------- |
| Camera | `SceneCamera` | ✔        | —       | Alias that keeps helper and consumer types in sync. |

**Returns:** Not a callable; this alias ensures `perspectiveCamera()` and `orthographicCamera()` share the same contract.

**Throws:** None.

## Examples

```ts
import type { Camera } from "vgpu/scene";
import { perspectiveCamera } from "vgpu/scene";

const camera: Camera = perspectiveCamera({
  fov: 60,
  aspect: 16 / 9,
  position: [0, 2, 4],
  target: [0, 0, 0],
});
```

## Notes

* Prefer the `Camera` alias when storing values in state containers so switching between perspective and orthographic helpers stays type-safe.
* **See also:** `SceneCamera`, `perspectiveCamera`, `orthographicCamera`.

***

# SceneCamera

Common contract of stateful camera nodes: column-major matrices plus the camera position, exposed as stable `Float32Array` identities that are updated in place by `set()` / `lookAt()`.

## Import

```ts
import type { SceneCamera } from "vgpu/scene";
```

## Signature

```ts
interface SceneCamera {
  readonly viewProjection: Float32Array;
  readonly viewProjectionMatrix: Float32Array;
  readonly position: Float32Array;
  readonly view: Float32Array;
  readonly projection: Float32Array;
  readonly worldPosition: Float32Array;
}
```

## Parameters

| Field                | Type           | Required | Default | Notes                                                                       |
| -------------------- | -------------- | -------- | ------- | --------------------------------------------------------------------------- |
| viewProjection       | `Float32Array` | ✔        | —       | Column-major projection × view matrix. Bind this to your WGSL uniforms.     |
| viewProjectionMatrix | `Float32Array` | ✔        | —       | Alias of `viewProjection`, kept for naming continuity.                      |
| position             | `Float32Array` | ✔        | —       | Local position (world position for unparented cameras). Mutate via `set()`. |
| view                 | `Float32Array` | ✔        | —       | Inverse of the camera node's world matrix.                                  |
| projection           | `Float32Array` | ✔        | —       | Projection matrix derived from the camera's parameters.                     |
| worldPosition        | `Float32Array` | ✔        | —       | World position used for specular highlights or parallax.                    |

**Returns:** Not a callable — the interface describes what camera helpers return.

**Throws:** None.

## Examples

```ts
import { perspectiveCamera } from "vgpu/scene";

const camera = perspectiveCamera({
  fov: 50,
  aspect: 4 / 3,
  position: [2, 2, 4],
  target: [0, 0, 0],
});

void camera.viewProjection;
```

## Notes

* Cameras are scene nodes: update them in place with `set()` / `lookAt()` instead of recreating them.
* `viewProjectionMatrix` is a duplicate reference so existing consumer code keeps working.
* **See also:** `Camera`, `CameraVec3`, `perspectiveCamera`, `SceneNode`.

***

# CameraVec3

Input-friendly vector type accepted by camera helpers. Accepts tuple literals or typed arrays; helpers always clone into a `Float32Array`.

## Import

```ts
import type { CameraVec3 } from "vgpu/scene";
```

## Signature

```ts
type CameraVec3 = readonly [number, number, number] | Float32Array;
```

## Parameters

| Param            | Type                                | Required | Default | Notes                                                                  |
| ---------------- | ----------------------------------- | -------- | ------- | ---------------------------------------------------------------------- |
| tuple form       | `readonly [number, number, number]` | ✔        | —       | Pass literal XYZ coordinates without allocations.                      |
| typed array form | `Float32Array`                      | ✔        | —       | Use when positions already live in typed arrays (e.g. math libraries). |

**Returns:** Not a callable — this is the accepted input type for camera helpers.

**Throws:** None.

## Examples

```ts
import type { CameraVec3 } from "vgpu/scene";

const orbitPos: CameraVec3 = new Float32Array([0, 3, 5]);
```

## Notes

* Helpers clone the input, so mutating the original array after the call does not affect the camera.
* **See also:** `perspectiveCamera`, `orthographicCamera`.

***

# Vec3

Type-only re-export of the `Vec3` alias from `wgpu-matrix`. Used internally by low-level camera helpers.

## Import

```ts
import type { Vec3 } from "vgpu/scene";
```

## Signature

```ts
type Vec3 = Float32Array;
```

## Parameters

| Param | Type           | Required | Default | Notes                                                                              |
| ----- | -------------- | -------- | ------- | ---------------------------------------------------------------------------------- |
| Vec3  | `Float32Array` | ✔        | —       | Column vector used by low-level helpers; provided for users wiring math utilities. |

**Returns:** Not a callable.

**Throws:** None.

## Examples

```ts
import type { Vec3 } from "vgpu/scene";

const up: Vec3 = new Float32Array([0, 1, 0]);
```

## Notes

* Prefer `CameraVec3` when calling public helpers; `Vec3` is useful when interoperating with `@vgpu/wgsl` math utilities.
* **See also:** `Mat4`, `CameraVec3`.

***

# Mat4

Type-only re-export of the column-major 4×4 matrix type from `wgpu-matrix`. Helpful when authoring math utilities that feed into scene helpers.

## Import

```ts
import type { Mat4 } from "vgpu/scene";
```

## Signature

```ts
type Mat4 = Float32Array;
```

## Parameters

| Param | Type           | Required | Default | Notes                                              |
| ----- | -------------- | -------- | ------- | -------------------------------------------------- |
| Mat4  | `Float32Array` | ✔        | —       | Column-major 4×4 matrix used across scene helpers. |

**Returns:** Not a callable.

**Throws:** None.

## Examples

```ts
import type { Mat4 } from "vgpu/scene";

const identity: Mat4 = new Float32Array([
  1, 0, 0, 0,
  0, 1, 0, 0,
  0, 0, 1, 0,
  0, 0, 0, 1,
]);
```

## Notes

* Use these aliases when building custom math helpers so your APIs stay aligned with vgpu’s scene entrypoints.
* **See also:** `Vec3`, `SceneCamera`.


---

For a semantic overview of all documentation, see [/sitemap.md](/sitemap.md)

For an index of all available documentation, see [/llms.txt](/llms.txt)

For agent-facing discovery, including API and MCP surfaces, see [/agents.md](/agents.md)