Feature Library

DOM stitched to GPU cloth

1.75 GPU · 0.21 CPU ms
A still of the DOM stitched to GPU cloth demo
Still
The live demo starts when it’s in view.Drag a card to another day · on the banners, the pointer is air

Real, selectable DOM text riding a cloth simulated on the GPU.

What it costs a frame

1.75 ms
0.21 ms
GPU
1.75 ms
CPU, median
0.21 ms
CPU, 95th pct
0.34 ms
Draw calls
0
Weight
Moderate

Measured 14 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged GPU 1.45–2.36, CPU 0.21–0.23 ms). What ran: Measured on the sheet: 6 panels, 7,865 points, 3 substeps of 15 Jacobi passes a frame, 14 cards read back as 56 probes. A card is moved to another day every 1.2 s, so the cloth never rests and the readback and matrix3d placement run every frame. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool1.750.210.34
apple · Apple A19 Proin a browser tab · 16 November 202614.00.240.34
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 20266.950.340.67

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

How steadily it runs on Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258V · in a browser tab

Typical frame ?
16.65 ms
1% low ?
56 fps
Varies by ?
±0.36 ms
All metricsIntel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258V · in a browser tab
p50p95p9916.03 ms18.00 ms +
How long each frame took. Most frames sit in the tall bars; a long tail to the right is hitching.

Frames run on a 60 Hz timer (a page demo), so most frames take about one tick, 16.7 ms: the spread around it is what matters.

Frames

Median (p50) ?
16.65 ms
p95 ?
17.41 ms
p99 ?
17.86 ms
Slowest ?
18.04 ms
Mean ?
16.68 ms
Standard deviation ?
0.36 ms
1% low ?
56 fps
0.1% low ?
55 fps
Hitches ?
0 of 600
Over budget ?
0 of 600

Main thread

Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.1 / 0.9 / 1.0 ms

Input

No input during this run. A browser-tab run plays none.

Memory

JavaScript heap ?
89.4 → 89.0 MB
Growth ?
-0.50 MB

What it needs

Renders with
WebGPUNeeds WebGPU: current Chrome and Edge, Safari 26+, Firefox 141+ on Windows.
Your browser
Checking…Looking for WebGPU
Depends on
NothingNo other packages

What it’s for

  1. A planning board where each column or day sags as deep as it is busy, and tears past its capacity
  2. Banners, notices and pull-quotes that hang and sway, and stay selectable, translatable text
  3. A tactile hero or onboarding page where the pointer blows the copy
  4. Showing load, stress or overload as something you can feel rather than read
  5. Any DOM laid onto a GPU surface: the probe-and-matrix3d pattern works for flags, sails or water too

Pitfalls, in brief

  1. Each substep integrates with dt divided by the substeps.
  2. Relax from one buffer into the other (Jacobi), an odd number of passes, so the last pass writes the buffer that is drawn and probed.
  3. The loads are placed in rest space, not where the cloth is now: a weight stays where it was sewn, as the cloth sags under it.
  4. A torn link still pulls at seven tenths in the solve; only drawing drops it.
  5. The readback is a frame or two behind: two staging buffers, mapAsync, and nothing waits on it.
10 more in brief
  1. A block needs transform-origin: 0 0 and must sit at its container’s (0, 0), the same origin the camera’s W × H uses.
  2. Measure flat with offsets (measureFlat), not getBoundingClientRect: the rect of a block already carrying a matrix3d is its tilted box.
  3. After re-measuring, place the blocks straight away from the last reading: until the next read they would sit untransformed at (0, 0), a visible flash.
  4. A patch torn apart under a block can fold its quad inside out: check the screen quad is convex and the right way round before using it (saneQuad), and lay the block flat, moved by its corners’ mean, if not.
  5. Eight storage buffers is the default per-stage limit.
  6. The canvas follows the host through a ResizeObserver.
  7. Text on the cloth is drawn at the cloth’s scale: frame the camera so a block’s box is drawn at 0.75 or more of its own size (about 12 px for 16 px text).
  8. A tear drawn as a plain discard reads as a hard black block.
  9. Rest: the engine stops stepping, drawing and reading back once no input changed for 2.5 s and its stats read the same 40 times.
  10. Without bloom the night silk’s glow would clip to white: colours roll off above 0.8 with a soft shoulder.
15 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Also as

Where it comes from

From HaTac. Fully custom code.

Thomas Jakobsen, Advanced Character Physics (GDC 2001): Verlet integration with constraints relaxed toward rest lengths, the method under the cloth.

Mark Jarzynski & Marc Olano, Hash Functions for GPU Rendering (JCGT, 2020): The PCG hash behind the crack lines and the fibres, the same on the GPU and the CPU.

Paul Heckbert, Fundamentals of Texture Mapping and Image Warping (1989): The closed-form square-to-quad homography that quadMatrix turns into a CSS matrix3d.

Inigo Quilez, 2D distance functions: The box distance that puckers the silk round each card, re-written in WGSL.

clothverletjacobicomputereadbackmatrix3dhomographydom + gputearingraw webgpuwgsldrag and dropcpu fallbackcanvas 2d fallbacktimestamp queriesno dependencies

Near it in the frame