# @ferret/perspective: API (continued)

### PerspectiveParams

*interface* · `packages/perspective/src/component.ts:6`

```ts
interface PerspectiveParams
```

- `ladder: PerspectiveLevel[]` — the rungs, richest first (see `PerspectiveLevel`); the last must have minPx 0
- `fade?: number` — seconds of the cross-fade between two rungs (default 0.25); 0 switches at once
- `margin?: number` — the ratio by which a size must pass a threshold to cross it (default 0.1)
- `radius?: number` — bounding sphere radius override, metres; default: what the backend measures
- `color?: [number, number, number]` — the mean albedo drawn for the object at the point level, linear rgb (default a mid grey)
- `glint?: number` — the sun's glint on the object at the point level, 0..1 (default 0)
- `loop?: { duration: number; frames: number }` — an animated impostor: the looping clip's length in seconds and the frames baked of it. The frame shown is picked from `clock` (default: the service's own time)
- `clock?: () => number` — the time in seconds of the clip's loop for this entity (e.g. its Animator's clock); default the service's time, so objects without one all walk in step
- `fill?: number` — the share of the bounding sphere's disc that the object's silhouette fills, averaged over the directions (0..1, default 1); the bake measures it. The point level draws a disc of the object's own area, not of its bounding sphere's
- `coherence?: { kind?: string; link?: number; gap?: number }` — Coherent detail: `kind` names what this is compared with (things of one kind at about one distance are drawn alike; default: the things with the same ladder), `link` the metres within which things of the kind stand together as one group with one level (default 0: alone).

### PointInstance

*interface* · `packages/perspective/src/backend.ts:9`

```ts
interface PointInstance
```

One thing drawn as a point this frame.

- `id: string`
- `position: Point3`
- `coverage: number` — the share of its pixel the object covers, 0..1 (below one pixel: the squared size)
- `px: number` — the diameter in pixels of the disc that has the object's own area (its size times the root of its `fill`)
- `alpha: number` — the fade of the point in or out, 0..1
- `color?: Point3` — the mean albedo of the object, linear rgb 0..1 (default a mid grey)
- `glint?: number` — how strongly the sun glints off it, 0..1 (0: never); the flash is strongest when the half vector of the sun and the eye lies along `up`
- `up?: Point3` — the object's up axis in the world, for the glint

### Representation

*interface* · `packages/perspective/src/view.ts:20`

```ts
interface Representation
```

Something a rung draws. Meshes implement it here; the impostor implements it in impostor.ts.

- `setState(state: RepState, mix: number): void`
- `setFrame?(f: number): void` — an animated impostor: show frame `f` of the baked loop (a still atlas ignores it)
- `tint?(color: BABYLON.Color3 | null): void` — debug: tint the representation (null: remove the tint)

### ResolvedBake

*interface* · `packages/perspective/src/bake-spec.ts:32`

```ts
interface ResolvedBake
```

- `views: number`
- `cell: number`
- `mode: OctaMode`
- `hide: string[]`
- `replace: Record<string, string>`
- `radius?: number`
- `maps: BakeMap[]`
- `clips: Record<string, number>`
- `flat?: boolean`

### Rgb

*interface* · `packages/perspective/src/compare.ts:6`

```ts
interface Rgb
```

RGB bytes of a w x h image, three per pixel.

- `data: ArrayLike<number>`
- `width: number`
- `height: number`

### SceneLight

*interface* · `packages/perspective/src/points.ts:62`

```ts
interface SceneLight
```

The scene's light as the impostor and point shaders take it: the hemispheric light as an up and a down colour (mixed by the normal), the directional lights summed as one sun.

- `ambient: Point3` — the mean of up and down: what a surface of any orientation gets
- `ambientUp: Point3`
- `ambientDown: Point3`
- `sun: Point3`
- `toSun: Point3`

### Sphere

*interface* · `packages/perspective/src/projection.ts:57`

```ts
interface Sphere
```

A bounding sphere in world space.

- `centre: Point3`
- `radius: number`

### ViewBlend

*interface* · `packages/perspective/src/octa.ts:38`

```ts
interface ViewBlend
```

- `views: [[number, number], [number, number], [number, number]]` — three views of the grid, each [i, j]
- `weights: [number, number, number]` — their weights; they sum to 1

## Types

### BakeMap

*type* · `packages/perspective/src/bake-spec.ts:9`

```ts
type BakeMap = 'color' | 'normal' | 'orm'
```

### LevelKind

*type* · `packages/perspective/src/select.ts:4`

```ts
type LevelKind = 'full' | 'mesh' | 'impostor' | 'point' | 'none'
```

### OctaMode

*type* · `packages/perspective/src/octa.ts:5`

```ts
type OctaMode = 'sphere' | 'hemisphere'
```

### Point3

*type* · `packages/perspective/src/projection.ts:4`

```ts
type Point3 = [number, number, number]
```

### Recorded

*type* · `packages/perspective/src/backend.ts:47`

```ts
type Recorded = | { call: 'apply'; id: string; from: number; to: number; mix: number } | { call: 'points'; ids: string[] }
```

What a backend call was, for tests.

### RepState

*type* · `packages/perspective/src/view.ts:17`

```ts
type RepState = 'off' | 'on' | 'in' | 'out'
```

How a rung is shown: fully (`on`), fading in, fading out (with the mix 0..1 of the cross-fade), or not at all.

### Variant

*type* · `packages/perspective/src/measure.ts:42`

```ts
type Variant = 'full' | 'mesh' | 'impostor' | 'point' | 'none'
```

## Constants

### AMBIENT_SCALE

*const* · `packages/perspective/src/points.ts:100`

```ts
const AMBIENT_SCALE: 1
```

What a Babylon PBR surface (no environment map) returns of the light it gets, measured on a flat plate of known albedo under each light alone
(tools/perspective/check, calibration of 2026-11-10): the hemispheric light comes back whole (albedo x light), the directional light as albedo x light x
cos / 3 (the Lambert 1/pi, 0.347 measured); the two add.

### BAKE_VERSION

*const* · `packages/perspective/src/bake-spec.ts:7`

```ts
const BAKE_VERSION: 2
```

Bumped when the bake or the atlas format changes: older atlases are then baked again.

### DEFAULT_IMPOSTOR_CELL

*const* · `packages/perspective/src/crowd-chain.ts:16`

```ts
const DEFAULT_IMPOSTOR_CELL: 128
```

the cell of a baked impostor view, pixels (the bake's default, `BakeSpec.cell`)

### DEFAULT_POINT_PX

*const* · `packages/perspective/src/crowd-chain.ts:20`

```ts
const DEFAULT_POINT_PX: 6
```

a figure this many pixels tall or less is a point (the impostor's own floor)

### FULL_SHARE_OF_CELL

*const* · `packages/perspective/src/crowd-chain.ts:18`

```ts
const FULL_SHARE_OF_CELL: number
```

the share of the cell a figure must fill to be shown by the impostor no better than by itself (a figure 120 px tall against the 128 px cell)

### SUN_SCALE

*const* · `packages/perspective/src/points.ts:101`

```ts
const SUN_SCALE: 0.347
```

### VISIBLE_CONTRAST

*const* · `packages/perspective/src/measure.ts:45`

```ts
const VISIBLE_CONTRAST: 4
```

How visible an object has to be for an error in it to count: the object's contrast, in pixels of sky brightness (a black object of 4 px of area has 4).

