Time Machine and Cover Flow for live HTML
I wanted to know if a single WebGL 2 TEXTURE_2D_ARRAY can recreate three 2007 spatial stacks (macOS Leopard Time Machine, iTunes Cover Flow and Windows Vista Flip 3D) for a live editing history of HTML states, keeping openSnapshots at zero while the front card stays editable. Type on the front card, tap a colour pill or press Save snapshot to push a new layer into the stack, then scroll, drag or tap an older card to travel back and restore it.
Show the code 16-layer TEXTURE_2D_ARRAY stack, three 3D layouts, reflections and projective hit testing
- One drawable document card inside one canvas. The title input, notes textarea, theme pills, priority checkboxes and Save button sit inside a single
<canvas content="drawable" layoutsubtree>. - Zero-snapshot GPU revision stack. Allocates a 16-layer
TEXTURE_2D_ARRAYinside a VRAM cap (24 MB on phones, 36 MB on desktop) and copies each committed state on the GPU viablitFramebuffer()andcopyTexSubImage3D(). - Time Machine, Cover Flow and Flip 3D poses. Computes each card's 3D translation, yaw, pitch, dimming and floor reflection alpha, then interpolates poses when you switch modes.
- Backdrops, rounded cards and floor reflections. Draws the Leopard starfield, Cover Flow obsidian floor or Vista aurora in pass 0, mirrored fading floor reflections in pass 2, and rounded glass-rimmed cards from either live
uTexoruHistoryin pass 1. - Projective front-card hit testing. Projects the focused live card's 3D clip matrix into canvas CSS coordinates, scales it by
geometryUnit()and passes it toupdateElementGeometry()so clicks and typing hit angled cards too.
How it works
In /time-scrubber/, keeping a visual history of an element meant holding dozens of open
ElementImage objects from captureElementImage(), and the graphics guard flags pages that leave
more than eight open. Here I reused the GPU array idea from /slit-scan/: one
ElementGL context from /lib/element-gl.js uploads the live HTML card with
gl.texElementSubImage2D(), then copies saved states straight into a 16-layer
gl.TEXTURE_2D_ARRAY using gl.copyTexSubImage3D(). No ElementImage snapshots
are created, and no pixels ever return to JavaScript during rendering.
On load, the page steps the card through seven seed revisions in seven consecutive paint cycles so the stack starts full
of real rendered HTML layers across all four colour themes. Whenever you switch a theme pill, press Enter in the title
input or tap Save snapshot, the next paint event uploads the live card into uTex, downscales it on the GPU
through a scratch framebuffer when the high-DPI texture exceeds the array's 24 MB phone (or 36 MB desktop) VRAM cap, and
copies it into the next layer of uHistory. Each revision also saves its plain JSON state (title, notes, theme
and checkboxes) beside its GPU layer index, so a lost WebGL context can rebuild every layer after restore.
All three 2007 spatial layouts run through the same fragment shader and back-to-front painter's sort. Time Machine stacks
older revisions up and back into a procedural starfield tunnel; Cover Flow angles side cards inward over a glossy black
floor with mirrored fading reflection quads; Flip 3D cascades angled cards back-left over a Vista-style aurora. When the
front card is the live head revision, it samples full-DPR uTex directly and projects its 3D clip matrix into
canvas.updateElementGeometry() scaled by geometryUnit() so typing, checkboxes and buttons work
even on Flip 3D's 25-degree tilt. Scrubbing to an older snapshot previews its frozen TEXTURE_2D_ARRAY layer
up front and parks the live DOM inert until you press Restore this revision or jump back to live.
Live checks
These wait for a tap so the demo starts with no extra WebGL contexts running. Each check creates its own isolated fixture on the corner test stage and retires it afterwards.
Findings
- A 16-layer
RGBA8TEXTURE_2D_ARRAYcapped at 24 MB (640 px) on phones and 36 MB (760 px) on desktop holds 16 distinct HTML document revisions at full 2x Retina card size (720x584) withwindow.__gfx.snapshots.open === 0and zero per-frame readback. - Sizing
ElementGLbefore callingupload()stops the initial seed revisions from capturing at117x87from a 300 by 150 unresized canvas backing store. - Projecting the front card's 3D clip matrix through
ndcToCssand scaling bygeometryUnit()keeps native<input>,<textarea>, checkbox and button hit boxes aligned across Time Machine, Cover Flow and angled Flip 3D. - Parking the live drawable DOM with
inert = truewhile previewing an archived layer stops stray taps from editing the hidden live draft before the visitor chooses Restore this revision. - Because every history entry keeps its lightweight form state alongside its GPU layer index, an
onRestoredcontext recovery can replay the capture queue and rebuild all 16 layers without losing user edits. - Measured in headless Chrome 160 Canary (2026-11-27, 412 px DPR 2.625 and 960 px DPR 2): all 4 live checks pass (
1.19 MP,9.5 MB,0errors). Chrome 159 on Android andnpm run check:jankstay not verified.