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.

Rev 7 of 7 · Live
Rev 7 · Live Aqua
1 flag · live front

 

Show the code 16-layer TEXTURE_2D_ARRAY stack, three 3D layouts, reflections and projective hit testing
  1. 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>.
  2. Zero-snapshot GPU revision stack. Allocates a 16-layer TEXTURE_2D_ARRAY inside a VRAM cap (24 MB on phones, 36 MB on desktop) and copies each committed state on the GPU via blitFramebuffer() and copyTexSubImage3D().
  3. 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.
  4. 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 uTex or uHistory in pass 1.
  5. 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 to updateElementGeometry() 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