# takeoff-player v0.2.0: fixed view (q6k1qlhs)

Lane: player, Ansel, for BOS-Takeoff-Veillance (8ac6d87f), 2026-10-25. Follows [takeoff-player_lcdjhcot.md](takeoff-player_lcdjhcot.md) (v0.1.1).
It is the first live preview of a relevant operating picture: ROP bead 01a173e5, [orientation](https://redfish.acequia.io/guerin/.agents/01a173e5-d532-7488-97b0-d6dd4aafcedc/2026-10-25/notes/rop-orientation_q4w8n2zt.md) §3.
Stephen: *"keeping the view fixed and seeing the scene animate instead of moving with the flying camera."*
Only `artifacts/takeoff-player/` was edited.

Open (Wonderland rotary, Revere, with traffic on the road west of it; exact 8K on pause):
https://stephenguerin.live/agents/8ac6d87f-3192-4fdb-a260-583dbee74291/artifacts/takeoff-player/index.html?fix=115531:16.15&rect=3000,2250,1900,1070
Lynn shore: `?fix=115634:20.15&rect=2000,2300,3200,1800`. Whole frame: `?fix=115531:22.15`.

## What it does

- **fix view** (F) freezes the frame on screen as the reference: its pose and its picture. **fix area** (A, or
  Shift+drag) fixes a rectangle and shows it enlarged. After that, every frame (playing, stepping, seeking) is warped
  into the reference view through the ground. The roads, roofs and shore hold still and the traffic moves.
- **Warp** (`js/fixed.mjs`, `js/warp.mjs`, WebGL2): a 48-cell grid over the visible part of the fixed rect. Each
  vertex is cast through the reference pose to the surface, projected through the current pose, and drawn as a
  textured mesh. The UVs are homogeneous (q·W, W), with W = z_cur / z_ref, so the interpolation is exact for a plane.
  Cells outside the current frame, behind the camera, beyond 20 km or in the cabin-window corners are transparent.
  Behind them is the reference dimmed, or the last seen picture (B).
- **Surface** (`js/surface.mjs`): Terrarium DEM tiles (AWS open data; NED 1/3" here) at z14 over the fixed area,
  fetched on fix, with fixed-point ray casting. Bathymetry is clamped to 0. If the DEM fails (or with `?surface=sea`),
  the surface is sea level.
- **Lock** (K, on by default; `js/lock.mjs`): the warped frame is rendered at 384 px (576 px when paused) and
  compared with the reference. Up to 48 patches, picked by structure-tensor min-eigenvalue on static texture (dark
  window pixels and uncovered cells excluded; water is too flat to be picked). ZNCC on a two-level pyramid,
  sub-pixel by parabola. A RANSAC homography is composed into the warp: pose error over flat ground is a homography,
  and an affine left 2x larger residuals over a 28° view. It falls back to affine, then translation. If fewer than
  35% of the patches agree, the lock holds its last correction ("HOLD"). Paused: 3 iterations. Playing: 1 iteration
  with smoothing α 0.7. Pure JS; opencv.js was not needed.
- **Sources** (`js/posed.mjs`): a *posed image* is { pose, cam, W, H, texture(want) }. Playing uses the 960 proxy.
  Paused uses the exact 8K frame from the frame service (`../../frame/?clip&f&rect&out`), cropped to the window the
  view shows at the scale it shows it. The 1 fps still stands in until that arrives, then the proxy. The reference is
  also an exact frame: a proxy snapshot first, then the 8K crop. The view-dependent rule holds: a crop is never larger
  than the output needs (scale = 95th percentile of screen px per source px over the mesh, snapped to 256 px and to
  fixed scale steps for caching).
- **Overlays in the fixed frame**: ADS-B labels (positions at the current frame's UTC) and the OSM coast are
  projected through the reference pose. The map draws the fixed area's ground outline (dashed white).
- **Readout**: reference frame and time; the current frame, frames and seconds since the fix, source and its
  resolution; ground coverage %; lock residual in 8K px and on screen, fit ±, inliers, model; the correction size;
  GSD of the current frame at the fixed-area centre (cross × along, at 8K and per texel shown), range, surface.
- **URL**: `?fix=<clip>:<t>[&rect=x,y,w,h]` (t = the frame's own time, rect in 8K px of that frame), plus
  `lock=0`, `behind=last|none`, `surface=sea`, `src=proxy` (proxy also when paused), `frames=<frame service base>`.

## Measured (headless Chrome via CDP, 1500x880, `verify/`)

`verify/measure.mjs` measures independently of the page's lock. It runs ZNCC (±40 px) of ~100-380 textured patches of
the fix frame's capture against each later capture of the GL canvas, with nothing drawn behind, and takes the
**median** displacement. Moving cars are a minority of the patches. Full tables: `verify/measurements.txt`.

| run (exact 8K on pause unless noted) | lock on: median px (8K px) | lock off: median px (8K px) |
|---|---|---|
| 115531 Wonderland rect, +1..+6 s | 0.6-2.4 screen (1.2-4.8) | 1.7 → 27.6 screen (3.4 → 55.7) |
| 115531 same, 960 proxy | 0.9-4.8 (1.7-9.7) | 1.7 → 27.2 (3.4 → 54.9) |
| 115634 Lynn shore rect, +1..+6 s | 0.16-0.87 (0.6-2.9) | 0.95 → 10.0 (3.2 → 34.1) |
| 115634 same, 960 proxy | 0.3-1.2 (1.1-4.2) | 0.9 → 9.8 (3.1 → 33.3) |

On the 115531 rect, 1 px 8K is about 0.25 m on the ground (GSD 0.19 × 0.41 m). With the lock, the ground holds to
about 1 m. Without it, the pose alone drifts 14 m in 6 s, which is too much to follow a car. The 75th percentile
with the lock is larger on 115531 (up to 9 screen px): building lean and trees, which the single-homography lock
cannot remove (below). The page's own residual readout agrees with the medians (0.6-2.1 px 8K).

Playing (proxy, real time, software GL in headless Chrome): 238 distinct frames rendered in 8 s of video, so every
frame was warped and locked. Coverage of the Wonderland rect stays at 100% for 5 s and is 83% at +6 s.

Media: `verify/fixed_115531_wonderland_lock_8k.mp4` (exact 8K frames every 0.1 s, real time),
`verify/fixed_115531_wonderland_nolock-vs-lock.mp4` (side by side), `verify/fixed_115531_wonderland_lock.gif`,
and `verify/page_*.png`.

## Findings for the producers

1. **The 960 proxies are re-timed onto a 1/30 s grid.** The frame count is the same, but each frame sits up to half a
   frame (0.016 s) from the original pts that the pose rows carry. On 115531 the proxy is +0.016 s before about f800
   and −0.016 s after. "The row nearest the video time" therefore pairs the picture with the next or previous
   frame's pose about half the time. That is 14-19 px 8K at 115531 (measured: 18.7 px between proxy and exact frame
   at f480, 0.2 px after the fix).
   - The player now maps by index through `data/proxy-pts.json` (each proxy frame's tick, from ffprobe,
     `verify/make-pts.mjs`).
   - takeoff-3d's `rowAt(c, S.mediaT)` has the same half-frame ambiguity, and so does anything else that pairs proxy
     time with pose rows.
2. A fixed view is a pose check over time. The unlocked drift in a fixed area is a direct measure of relative pose
   error. 115531 f480-f660 drifts 55 px 8K in 6 s, about 0.5° (f660 coast and f720 drape anchors, already in the
   calib caveats). 115634 f600-f780 drifts 34 px.

## Known limits

- **Surface is bare earth.** Buildings, bridges and trees lean as the camera moves (visible on the Wonderland towers
  and the plaza roof edges). The lock is one homography per frame, so it registers the ground and leaves the lean.
  The next step is the ROP §3 surface: a DSM from Google 3D Tiles rendered top-down, or a smooth residual field on
  top of the homography.
- **Lock needs static texture.** Over mostly water (Lynn bay) it can hold rather than lock. Surf moves and is
  rejected, but a view that is almost all water has nothing to lock to.
- Exact 8K frames take about 2.2 s each when cold, so paused stepping shows the still and then sharpens.
  Playing is the proxy, so a small fixed area looks soft at play speed.
- Near the horizon (over 20 km), cells drop in steps. The cabin-window mask is a corner superellipse with a darkness
  test. Lens distortion is not modelled, as in v0.1.
- A fixed view belongs to its clip: changing clip unfixes it.

## Toward one page with modes (Stephen: the 2D and 3D pages "should feel like different modes")

This pass shaped the player so that the **shell** is mode-agnostic and a **view** draws the picture.

**Shared state contract (the shell owns it):**
`{ clips, clip, t (media time), frameRow (pose row of the frame on screen, by index), tu (UTC ms), playing,`
`  aoi: { ref: posed image, R: rect in ref px, ground outline } | null, overlays: { labels, coast }, traffic, coastData,`
`  sources: posed images (posed.mjs) }`.
Data loading (`data.mjs`, `proxy-pts.json`, frame service probe), the clock, the timeline, the clip select, the map,
URL state and the overlays all stay in the shell.

**A view answers:**
- `overlayCam()`: the camera overlays project through, and the native-px offset of what it shows.
- `dims()`: the native rect it shows.
- `render(ctx)`: draws the picture for the shell's state.

The views are:
- **video**: the `<video>` and still elements, as v0.1.
- **fixed/ROP**: `FixedView.frame({ T, candidates: [posed images] })`. It never reads the clip, so a fused
  multi-camera ROP (orientation §7) passes several posed sources.
- **map**: Leaflet. Today it is a side pane, and it could become a full-screen view.
- **3D**: see the next section.

**3D as a mode** (from `artifacts/takeoff-3d/js/app.mjs`), roughly 60% of that file moving as is:
- **Becomes the 3D view module** (`views/three-d.mjs`): `initEngine`, `fallbackSurface`, `solvedWorld`,
  `placeSolved`/`placeCamera`/`bindOrbit` (through and orbit), `updateFrustum`, `buildTrack`, `lineBuffer`/`writeLines`,
  `makeMarker`/`updateAircraft`, `updateLabels`, and the projector with `pumpFrame`. It also brings the vendored
  `vendor/taos-engine.js` and `google-tiles.json`.
- **Drops in favour of the shell:**
  - `poseAt`, `seekT`, `stepFrames` and `keepUrl` (use the shell's by-index `frameRow` and URL state).
  - Its own clock, scrub bar and clip select (use the player's timeline and clock).
  - `chrome.js` (the player's chrome already covers fullscreen and hide-UI; keep `minimizable` for its panels).
- **New in the 3D mode:** project the fixed view's AOI outline and the ROP surface into the scene, and feed it the same
  posed-image textures (`posed.mjs`), so pause or zoom uses the frame service there too.
- **Order:**
  1. Move the player's shell into `js/shell.mjs`.
  2. Register the views `video`, `fixed` and `map`.
  3. Load the 3D view lazily on first use: it is a 9 MB bundle and needs WebGPU.
  4. Retire the separate takeoff-3d page to a redirect with `?view=3d`.

## Files

`js/app.mjs` (shell + video view, v0.2.0), `js/fixed.mjs`, `js/warp.mjs`, `js/lock.mjs`, `js/surface.mjs`,
`js/posed.mjs` (new), `data/proxy-pts.json` (new), `index.html`, `styles.css`. Verify: `verify/cdp.mjs` (copied from
takeoff-3d/verify/t3d-cdp.mjs), `verify/run-fixed.mjs` (step and capture), `verify/play-fixed.mjs` (real-time play),
`verify/measure.mjs` (independent residual), `verify/make-pts.mjs`. `camera.mjs` and `data.mjs` are unchanged
(takeoff-3d imports them in place).
