# `<camera>`

[Canonical page](https://nothing.graphics/docs/format/reference/camera) · [Page source on GitHub](https://github.com/gridaco/nothing/blob/main/ncf/docs/reference/camera.md)

Define a named view that the scene may select.

## Examples

[Download the complete .nothing source](https://nothing.graphics/format/camera-cuts/source.nothing) · [Source on GitHub](https://github.com/gridaco/nothing/blob/main/ncf/conformance/cameras/index.nothing)

Rendered with ncf-preview at 100 × 80.

Bound resources

- [ncf/conformance/cameras/child.nothing](https://nothing.graphics/format/camera-cuts/child.nothing)

- [Frame 11 · Wide](https://nothing.graphics/format/camera-cuts/11.webp). The red marker sits near (32, 22). The red square inside the referenced child scene is already framed before placement.
- [Frame 12 · Tracking](https://nothing.graphics/format/camera-cuts/12.webp). A held key cuts to the 2× zoom of the tracking camera. The red marker moves to (44, 44).
- [Frame 24 · Rolled](https://nothing.graphics/format/camera-cuts/24.webp). The next held key cuts to a rolled view. The red marker appears at (32, 58).

```xml
<scene width="100" height="80" frame-rate="24" background="#101820FF" camera="wide">
  <camera id="wide"/>
  <camera id="tracking" center-x="30" center-y="20" zoom="2">
    <animate attributeName="center-x" fill="freeze">
      <key frame="0" value="30" ease="linear"/>
      <key frame="24" value="40"/>
    </animate>
  </camera>
  <camera id="rolled" roll="90"/>
  <camera id="beyond" center-x="110"/>
  <animate attributeName="camera" fill="freeze">
    <key frame="0" value="wide" ease="hold"/>
    <key frame="12" value="tracking" ease="hold"/>
    <key frame="24" value="rolled" ease="hold"/>
    <key frame="36" value="wide" ease="hold"/>
    <key frame="48" value="beyond"/>
  </animate>
  <shape>
    <rect anchor-u="0" anchor-v="0" offset-x="30" offset-y="20" width="4" height="4"/>
    <fill><paint><solid color="#E93434FF"/></paint></fill>
  </shape>
  <shape>
    <rect anchor-u="0" anchor-v="0" offset-x="108" offset-y="38" width="4" height="4"/>
    <fill><paint><solid color="#45CF80FF"/></paint></fill>
  </shape>
  <sequence href="child.nothing" begin="0f" dur="49f" source-start="0s"
            translate-x="70" translate-y="12"/>
</scene>
```



<!-- Generated by ncf/tools/reference/generate.mjs. -->

A Level 1 camera frames the composition in its viewport. Name it with an ID and select it on the scene. Center, zoom, and roll can be animated independently of the artwork.

## Syntax [#syntax]

### Cut to a tracking view [#cut-to-a-tracking-view]

The scene’s held camera track selects tracking at frame 12. By then the horizontal center has reached 35. The red marker covers (44, 44) in the sampled viewport.

```xml
<camera id="tracking" center-x="30" center-y="20" zoom="2">
  <animate attributeName="center-x" fill="freeze">
    <key frame="0" value="30" ease="linear"/>
    <key frame="24" value="40"/>
  </animate>
</camera>
```

[Complete .nothing source](https://github.com/gridaco/nothing/blob/main/ncf/conformance/cameras/index.nothing) · [Sample checks](https://github.com/gridaco/nothing/blob/main/ncf/conformance/README.md#camera-cuts)

## Usage context [#usage-context]

Allowed parents are [`<scene>`](https://nothing.graphics/docs/format/reference/scene).

The perspective trial proposes additional authoring fields separately from Level 1. Its focus behavior has been ratified under the [perspective optics contract](https://nothing.graphics/docs/format/spec/perspective-camera-optics). A trial scene may not mix 2D and spatial cameras. The linked RFC also discusses orthographic projection, which is outside this trial.

## Attributes [#attributes]

[Property animation](https://nothing.graphics/docs/format/spec/animation#property-types-and-exceptions)

### `id` [#id]

**Value** `Nonempty ASCII letters, digits, underscores, or hyphens` · **Required** · **Keys** Static

Case-sensitive name unique among the scene's cameras.

### `center-x` [#center-x]

**Value** scene units · **If omitted** `viewport center x` · **Keys** Scalar

Scene x coordinate framed at viewport center by a 2D camera.

### `center-y` [#center-y]

**Value** scene units · **If omitted** `viewport center y` · **Keys** Scalar

Scene y coordinate framed at viewport center by a 2D camera.

### `zoom` [#zoom]

**Value** factor · **If omitted** `1` · **Keys** Scalar

Strictly positive 2D magnification. A value of 2 doubles distances from the framed center.

### `roll` [#roll]

**Value** degrees · **If omitted** `0` · **Keys** Scalar

Clockwise rotation of the camera axes. At positive 90 degrees in 2D, a point right of the camera center appears above viewport center.

### `projection` [#projection]

**Value** `2d`, `perspective` · **If omitted** `2d` · **Keys** Static

Spatial trial. Select the trial projection profile. Cut between named cameras with held scene selector keys. [Proposed projection selection](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-cameras.md#scene-and-camera-selection)

### `position-x` [#position-x]

**Value** scene units · **If omitted** `half the viewport width` · **Keys** Scalar

Spatial trial. Horizontal coordinate of the perspective optical center. [Proposed spatial camera fields](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-cameras.md#camera-fields)

### `position-y` [#position-y]

**Value** scene units · **If omitted** `half the viewport height` · **Keys** Scalar

Spatial trial. Vertical coordinate of the perspective optical center. [Proposed spatial camera fields](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-cameras.md#camera-fields)

### `position-z` [#position-z]

**Value** scene units · **If omitted** `1000` · **Keys** Scalar

Spatial trial. Depth coordinate of the perspective optical center. [Proposed spatial camera fields](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-cameras.md#camera-fields)

### `rotate-x` [#rotate-x]

**Value** degrees · **If omitted** `0` · **Keys** Scalar

Spatial trial. Perspective camera orientation about the x axis. [Proposed spatial camera fields](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-cameras.md#camera-fields)

### `rotate-y` [#rotate-y]

**Value** degrees · **If omitted** `0` · **Keys** Scalar

Spatial trial. Perspective camera orientation about the y axis. [Proposed spatial camera fields](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-cameras.md#camera-fields)

### `clip-near` [#clip-near]

**Value** scene units · **If omitted** `0.1` · **Keys** Scalar

Spatial trial. Positive inclusive minimum axial depth. It must be below clip-far. [Proposed spatial camera fields](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-cameras.md#camera-fields)

### `clip-far` [#clip-far]

**Value** scene units · **If omitted** `100000` · **Keys** Scalar

Spatial trial. Positive inclusive maximum axial depth. It must exceed clip-near. [Proposed spatial camera fields](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-cameras.md#camera-fields)

### `focal-length-mm` [#focal-length-mm]

**Value** millimeters · **If omitted** `50` · **Keys** Scalar

Spatial trial. Positive effective focal length for the rectilinear perspective lens. [Proposed spatial camera fields](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-cameras.md#camera-fields)

### `sensor-width-mm` [#sensor-width-mm]

**Value** millimeters · **If omitted** `36` · **Keys** Scalar

Spatial trial. Positive active width of the perspective sensor. [Proposed spatial camera fields](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-cameras.md#camera-fields)

### `f-stop` [#f-stop]

**Value** dimensionless f-number · **If omitted** `0` · **Keys** Scalar with held transitions at zero

Spatial trial. Positive lens f-number or zero for pinhole rendering. A segment between zero and a positive value requires hold. [Proposed focus settings](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-camera-focus.md#proposed-authoring-inputs)

### `focus-distance` [#focus-distance]

**Value** scene units · **If omitted** `1000` · **Keys** Scalar

Spatial trial. Positive axial distance from the optical center to the focus plane. [Proposed focus settings](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-camera-focus.md#proposed-authoring-inputs)

## Children [#children]

| Elements                                                              | Cardinality  | Declared by | Role and source order                                                                                                                                                                                                |
| --------------------------------------------------------------------- | ------------ | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`<animate>`](https://nothing.graphics/docs/format/reference/animate) | Zero or more | Animation   | A track targets one keyable property on this owner. For equal first-key times, the later track in document order wins. [Evaluating animation tracks](https://nothing.graphics/docs/format/spec/animation#evaluation) |

## Specifications [#specifications]

* [2D cameras](https://nothing.graphics/docs/format/spec/spatial#cameras)
* [Proposed projection selection](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-cameras.md#scene-and-camera-selection)
* [Proposed spatial camera fields](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-cameras.md#camera-fields)
* [Proposed focus settings](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-camera-focus.md#proposed-authoring-inputs)
* [Evaluating animation tracks](https://nothing.graphics/docs/format/spec/animation#evaluation)
