T-014: Viewer shows the sim and opens checkpoints
Goal
The viewer displays a real world from crates/sim, live or loaded from a checkpoint, native
and in the browser.
Scope
- Replace the placeholder data with the sim's read-only view. Draw cells as spheres coloured by their colour and opacity, with bonds optional. No art direction yet.
- Run the sim inside the viewer: play, pause, single step, speed control.
- Open a checkpoint or a run folder natively. In the browser, open a checkpoint by URL parameter or by dropping a file on the page.
- Continue simulating from the loaded checkpoint at whatever speed the device manages. Show steps per second.
viewer --screenshotaccepts a checkpoint, a camera position and a step count, so any agent can get a picture of any world.
Done when
- ☐ A checkpoint written by
runneron this machine opens in the deployed web viewer and keeps running. Screenshot indocs/media/T-014/. - ☐
docs/VIEWER.mdupdated.
Notes from T-002
- The renderer only sees the
WorldSourceinterface incrates/viewer/src/source.rs. Implement it over the sim's read-only view. - T-002 removed the viewer's dependency on
crates/sim. Add it back here. - Phones: already handled by T-049 (pixel ratio cap, simpler spheres, automatic quality,
?diag=1and?bench=1). Keep all of that working. Seedocs/VIEWER.md. - Use
node scripts/webfps.mjsto check the deployed viewer.scripts/webshot.shcannot capture it.
Added 2026-12-02
- The sim core is merged. Read
docs/ARCHITECTURE.md: section 10 is the view you draw from, and section 12 has your contract (sim::view,World::load,World::step, nothing else). - The real physics (T-009), growth (T-010) and the runner (T-012) are being built by other
agents right now. Use
sim::testbedworlds and checkpoints made withWorld::saveuntil they land. Do not wait for them. - Worlds will become very large and bodies will differ in size by orders of magnitude
(
docs/DESIGN.mdsection 5, "Scale is free"). Do not build in an assumption that cells are all about the same size, and measure the frame rate at 100,000 cells. - The look is decided (
docs/DESIGN.mdsection 11) but is not this ticket. Plain spheres with true colour and opacity are right here. T-015 builds the look on top of your work.
Result
Branch t-014-viewer-live-sim. No changes to crates/sim.
- The viewer draws the sim's world. A
SimSourceoversim::WorldreadsWorld::view()each time the world changes. Cells are drawn as spheres in their own colour and opacity, using one instanced draw for opaque cells and one for translucent ones. Translucent cells are sorted back to front with a log-depth counting sort, so cells from 0.01 to 100 units across sort correctly together. Cells with zero opacity are not drawn. Bonds are optional (key B, or the Bonds button). - Playback. Play, pause, single step and speed from ⅛× to 64× or max, from the keyboard natively and from on-page buttons on the web. The world steps within a time budget per frame. When it falls behind it says "(behind)" and drops the backlog instead of stalling. The HUD shows steps per second.
- Opening worlds. Natively you can pass a checkpoint, a run folder (newest checkpoint
that loads, skipping damaged ones) or drop a file. On the web:
?checkpoint=URL, dropping a file, or the Open button. Errors such as 404 or "not a checkpoint" are shown on the page. viewer --screenshot [PATH] --camera X,Y,Z --look X,Y,Z --steps Npictures any world from any place.--savewrites a checkpoint and--probe sizesbuilds a test world with cells from radius 0.01 to 100. The camera's near and far planes, zoom limit and fog follow the world's scale.- Done when: a runner-written checkpoint (10k cells, step 900) opens on the preview
deploy and keeps running in Chrome and in WebKit with an iPhone profile:
docs/media/T-014/web-runner-checkpoint-10k.pngandwebkit-iphone-runner-checkpoint-10k.png. The 100k one is inweb-runner-checkpoint-100k.png.docs/VIEWER.mdis updated; its measurements are under "The live world (T-014)". - Speed: natively 216 fps with 100,000 cells running, 669 fps with 10,000. On the web, 60 fps at both sizes. At 100,000 cells the web build steps at 28 of 30 steps per second because stepping shares the page's only thread.