# `Camera.fit`

> Contract 2.0.0 · package sha256 `a857eca95b35921109faf997094bb4192f12527d9d0fcd4be7e97f06425bad6e` · generated from `configurator-runtime.d.ts` by `services/onsite-scripter/scripts/build-contract-docs.mjs`; edit the source, not this file.

Method of [`Camera`](Camera.md) · stable · since 2.0.0 · called as `session.camera.fit`

```ts
fit(query?: Query, options?: CameraCommitOptions<C> & CameraMoveOptions & {
  paddingM?: number;
  view?: Pick<CameraView, 'azimuthDeg' | 'polarDeg'>;
}): Promise<Report>;
```

Frames the matches (a view write; as [`set`](Camera.set.md)) inside the part of the element the lens's `insets` leave, with the insets and field of view of the newest [`lens`](Camera.lens.md) write at the fit's call (its target while an eased one runs, never the lens last drawn), keeping the current azimuth and polar unless `view` gives others, which it turns to in the same move. `paddingM` is metres around their bounds. The distance comes from the eight corners of their world bounds box, grown by `paddingM`, seen at the fit's azimuth and polar, as 1.4's `fitToBox` (camera-controls), never from a bounding sphere, so a long, shallow row fills the frame's width. With `paddingM` omitted, the box fills at most the middle 92% of the frame along its limiting axis, a 4% margin each side; `paddingM: 0` is 1.4's exact fit (the box touches the frame), and a `paddingM` given adds no margin beyond it. With the default lens on a portrait element (narrower than tall), the fit frames at a vertical field of view of 45° at most ([`CameraLens.horizontalFovDeg`](CameraLens.horizontalFovDeg.md)). The target lands at the centre of the matches' world bounds box (the union of their boxes), with `focalOffset` zero. Like every view write, the landed view is then clamped to the merged limits ([`CameraLimits`](CameraLimits.md)): the distance to `minDistance` and `maxDistance`, the adaptive product limits included, so a fit on a product or part smaller than about 14 cm stops at the 0.1 m floor, farther out than its box needs: lower `minDistance` with [`limits`](Camera.limits.md) first; the target to [`CameraLimits.target`](CameraLimits.target.md), the angles to the polar and azimuth limits. Through `session` its Report's [`matched`](ReportFields.matched.md) counts the query's matches when the fit starts; a query that matches nothing (a typo, or a model whose scene write is still pending) leaves the camera where it is and records 'target-unmatched' with `didYouMean`, so await the scene write that adds what it frames first.

**Default:** query: role 'product'; paddingM omitted: a 4% margin each side of the frame (`paddingM: 0` frames exactly, as 1.4)

## Options

Through [`Session`](Session.md):

| Option | Type | Default | What it does |
| --- | --- | --- | --- |
| `actor` | `Actor` | the `expectGroup`'s actor when one is given, else 'app' | Who made the write. |
| `durationMs` | `number` | 0 | 0 lands exactly, without damping, before the next frame. |
| `easing` | `Easing \| 'damped'` | 'easeInOut' | The move's time curve: an [`Easing`](Easing.md), or `'damped'`, a critically damped spring with no overshoot, which is 1.x's `transition: true` glide. |
| `expectRevision` | `number` | undefined (no check) | If-match on [`session.revision`](Session.revision.md). |
| `origin` | `string` | null | Your tag, echoed unchanged in [`Report.origin`](ReportFields.origin.md) and `cause.origin`. |
| `paddingM` | `number` | — |  |
| `signal` | `AbortSignal` | undefined | Cancels this call; the member's JSDoc says what an abort does. |
| `view` | `Pick<CameraView, 'azimuthDeg' \| 'polarDeg'>` | the current ones | The azimuth and polar to frame from, reached in the fit's one move (1.4's axis-view fits). |

Refused here (typed `never`, so passing one fails to compile): `dryRun`, `expectGroup`, `supersede`, `undo`.

Through [`Tx`](Tx.md):

| Option | Type | Default | What it does |
| --- | --- | --- | --- |
| `durationMs` | `number` | 0 | 0 lands exactly, without damping, before the next frame. |
| `easing` | `Easing \| 'damped'` | 'easeInOut' | The move's time curve: an [`Easing`](Easing.md), or `'damped'`, a critically damped spring with no overshoot, which is 1.x's `transition: true` glide. |
| `paddingM` | `number` | — |  |
| `signal` | `AbortSignal` | undefined | Cancels this call; the member's JSDoc says what an abort does. |
| `view` | `Pick<CameraView, 'azimuthDeg' \| 'polarDeg'>` | the current ones | The azimuth and polar to frame from, reached in the fit's one move (1.4's axis-view fits). |

Refused here (typed `never`, so passing one fails to compile): `actor`, `checkpoint`, `dryRun`, `expectGroup`, `expectRevision`, `origin`, `supersede`, `undo`.

## Abort (`signal`)

This call is a write (`SignalOption.signal`, [the kinds of call](../read-this-first.md#conventions)).

> A write: before the commit point it rolls back and rejects AbortError; after it, no effect, except that a running camera move stops where the last frame drew it (`CameraMoveOptions`).
>
> Through a `tx` the commit point is the transaction's: aborting a write still loading rejects AbortError and stages nothing (catch it: unobserved, it rolls the transaction back, spec section 6.1, O6); aborting one already staged unstages it, its paths keeping the latest other write to them as after a failed savepoint (O7), and its Promise stays resolved 'staged'.

## Generic-API test (spec 3.1)

| Rule | Result |
| --- | --- |
| 1. Neutral name | pass: `fit` names no product |
| 2. A precedent | not recorded: no ledger row (coverage.json) names this member or its owner |
| 3. Two apps, or labs | pass: 24 apps (fleet cross-check: app-04c2774145, app-37356bf09f, app-378d190f1b, app-4762caacdc, app-4f16d2f6da, app-4fd23bc869, app-510d750508, app-59c5b5751e and 16 more) |
| 4. The cheaper fix first | not recorded per member (Appendix B decides it per need) |
