# takeoff-3d (vu3mn4td): the takeoff frames projected onto Google 3D Tiles, in TaosEngine

Lane: 3d, Ansel, for BOS-Takeoff-Veillance (8ac6d87f), 2026-10-25. Stephen asked "where's the 3d with projection?", then
"go with taos engine". Code: `artifacts/takeoff-3d/` (`index.html`, `js/app.mjs`, `chrome.js`, `google-tiles.json`,
`engine-lib/`, `vendor/`, `verify/`). The only other file touched: `artifacts/takeoff-player/` got one **3D** link
(`index.html` header, plus a click handler in `js/app.mjs` that carries `?clip=&t=`).

Open: https://stephenguerin.live/agents/8ac6d87f-3192-4fdb-a260-583dbee74291/artifacts/takeoff-3d/index.html?clip=115634&t=20
(orbit start: add `&view=orbit`). WebGPU is required (desktop Chrome or Edge).

## What it does (v0.1.0)

- **Surface:** Google Photorealistic 3D Tiles, streamed directly from the Map Tiles API by TaosEngine's
  `GoogleTilesSource` (`add3DTiles`, unlit, worker decode). If the key file or the root request fails, the page falls back to
  Terrarium DEM + Esri imagery (`addRasterDemTerrain`).
- **Projection:** a TaosEngine `Projector` (perspective, fovY = the 16:9 frame's vertical field from hfov, aspect 16/9) placed
  at the solved eye and oriented by the solved heading, pitch and roll. Its texture is the proxy-960 video, copied on
  every decoded frame (`requestVideoFrameCallback` into an `rgba8unorm-srgb` texture), and **the pose is taken at that frame's
  `mediaTime`**, so pose and picture stay in step while playing, seeking and stepping.
- **Through the camera (`h`):** the view camera is the solved camera. The orange rectangle is the image; the 3D outside it is
  context. **Orbit (`o`, or drag):** drag orbits about the frame's footprint, right- or shift-drag pans, wheel zooms.
- **Frustum:** four rays from the eye to the image corners cast to sea level (the player's `castToSea`, 25 km cap; capped
  edges drawn paler), the footprint ring, and the image rectangle 600 m in front of the eye. **UAL414's ADS-B track** (white,
  red where a clip was recorded) and a marker at the eye.
- **Aircraft:** every other aircraft in the v5k2m8qt build at its interpolated ADS-B position (the player's `posAt`, same
  height rules), a marker of constant screen size and a label: callsign, type, range from UAL414 (quieter beyond 20 km,
  hidden beyond 60 km).
- **Projection controls:** `p` toggles it; the slider sets its opacity (0.5 shows the video over the tiles).
- House chrome: linked redfish-style sheet, logo chip header with the clip selector and a **2D** link back to the player at
  the same time, fullscreen and hide-UI fabs, minimizable Video, Readout and About panels, a slim dock. Keys: space,
  arrows (shift: 30 frames), `h`, `o`, `p`, `l`.

## Reuse, and why 2D and 3D agree

`js/app.mjs` imports `../takeoff-player/js/data.mjs` (clips, poses, rows, `rowAt`, traffic, `posAt`, `GEOID_N`) and
`camera.mjs` (`cameraFrame`, `makeCamera`, `castToSea`) **in place**, so the rows, times, hold-field rule (115459) and pose
convention are the player's, which the player lane checked to the last digit against the solver. The calib.js basis
(fwd/right/up in local ENU) is rotated into ECEF at the eye's own lat/lon, then into the GeoScene's world. Eye height:
ellipsoid h = MSL + N, N = -28.6 m (`?geoid=` overrides it for testing). From skyfox-projection I took the design (projector
plus through-camera plus orbit, the frustum, the keys, the chrome), not its three.js code, after the engine change.

## The engine

TaosEngine clone `C:/Users/steph/Documents/src/taos-engine` at **29850554** (clean). The hosted `/taos/taos-engine.js`
(built from 8c485d87 for incident-viewer) does not export `GoogleTilesSource`, `GeoLineFeature`, `MeshRenderer` or
`TonemapFeature`, so I built my own bundle with the engine's own vite (`engine-lib/entry.ts` = `export *` of the core and
`taos/geo`; config `engine-lib/vite.lib.config.mjs`) into `vendor/` (provenance in `vendor/BUILD.json`). The engine clone
was not modified.

Two engine findings:
1. **`Projector.viewMatrix()` drops roll.** It rebuilds the view from position + forward with world up, ignoring the
   GameObject's rotation about the axis. The page overrides `viewMatrix` on its projector instance with
   `Mat4.lookAt(eye, eye + fwd, solvedUp)`. Worth an upstream fix (use the GameObject's own up).
2. **No occlusion in the projector pass.** It reconstructs world position from the G-buffer depth and samples the image
   wherever the point is inside the frustum; there is no depth map from the projector, and `programId` is declared but not
   implemented. Through the camera this does not matter (what the camera sees is what is lit). In the orbit view the frame also
   lands on surfaces hidden from the camera (backs of buildings, the far side of hills).

## Verified

Own Chrome 155 over CDP (`verify/t3d-cdp.mjs`, non-headless window, `--enable-unsafe-webgpu`; the DevTools MCP browser was
in use by another session), viewport 1600x900. No console errors; the only warning is the engine's ">256 materials".
Screenshots in `artifacts/takeoff-3d/verify/`:
- `115634_t20_through_proj-on.png`, `-off.png`, `-half.png`: through the solved camera at t = 20 s. The projected
  Swampscott shoreline, the pier, the long buildings and the ponds sit on the tiles' own.
- `115634_t20_orbit_drape-frustum.png`: the orbit view, the frame draped on the coast, the frustum, the track and the eye marker.
- `115531_t30_through_from-player-link.png`: opened from the player's new 3D link (Rumney Marsh); the link carried clip and t.
- Playback: after 4 s of play, 115 frames pumped, `mediaT` 23.967 against `currentTime` 23.975 (one frame).

**Residual, measured** (`verify/residual.mjs`): through the camera, projection on (the video) against projection off (the
tiles), UI hidden (`*_clean_proj-on/off.png`); 7x5 patches of 64 px, the shift that maximises the gradient ZNCC within
+-24 px, patches that match trivially (sky, silhouettes) dropped:
- 115634 t 20 s: 12 patches, median **5.1 screen px = 6.5 px at 1920** (about 0.24 deg); median dx, dy = 0, 0.
- 115634 t 50 s: 11 patches, median **4.1 screen px = 5.2 px at 1920**; median dx, dy = 0, 1.
- A few patches reach 20 to 24 px. All are near the frame edges and corners: the cabin window's vignette and frame (projected
  as dark smears), the missing lens-distortion model, and weak texture.
This agrees with the calib lane's independent coast check (median 4.6 to 4.9 px at 1920).

**Geoid finding (for the calib lane).** The solver's tile renders (skyfox-pose `node-io` `Tiles3DSurface`, `geo.mjs
paneCamera`) use `G.NORTE_GEOID` = -35.5 m (EGM96 at the Norte Fire), not Boston's -28.6 m. So the solver saw the tiles from
an eye 6.9 m lower than the eye this page uses. I tested `?geoid=-35.5`: the residual is 6.3 to 7.6 px at 1920 against 5.2 to
6.5, the same within the measurement. It is not visible at 1920, but it may matter for 8K refinement.

## Key and terms

`google-tiles.json` beside the page holds the **maps-browser** key (registry fp 8250c279). It is a browser key and is
**exposed client-side by design**. Its protection should be the referrer restriction, but **as measured now the key has
no restriction**: root.json answers 200 with Referer stephenguerin.live, a foreign Referer, and none. The key registry's
desired referrer list already includes `https://stephenguerin.live/*`. When that restriction is applied in Google Cloud
(by Stephen, or by the key-manager lane `01a14d3b`), this page keeps working. This page is a new deployed copy and should
be added to the registry's list. Google attribution: the Google logo plus the live per-tile data providers
(`tileset.visibleCopyrights`), bottom right, never withdrawn by hide-UI.

## Known issues, next

1. **Occlusion** in the orbit view (above). The fix is a depth pass from the solved camera fed to a custom projector
   program, either an engine change or an app RenderFeature.
2. The window frame and vignette in the video are projected too (dark smears at the image corners). Next: the solver's
   window mask as the projector's alpha.
3. The vendored bundle is the whole engine: 9.3 MB, 3.5 MB gzip. A narrower facade would cut it.
4. Paused frames use the 960 proxy, not the 8K still. Next: on pause, seek to the still's time (n - 0.5 s) and project the
   still, downscaled to 3840.
5. There is no 2D map pane; the takeoff-player has one.
6. WebGPU only (TaosEngine has no WebGL path), so Firefox and older Safari get a message.
7. 115459 f0-f300 are rough poses (the player's caveat applies), and the projection there will slide.
