176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.
HTML ai-promptsanimationcss-animationsfrontendgithub-pagesjavascriptmicrointeractionsmotion-designno-dependenciesreferencescroll-animationui-animationweb-animationweb-developmentwebgl
docs: correct the last 3D wording found by the fix-wave re-reviews
matin8ba4fa61c6b4
diff --git a/animations/06-3d-advanced/README.md b/animations/06-3d-advanced/README.mdindex d0ade474..aa62874d 100644--- a/animations/06-3d-advanced/README.md+++ b/animations/06-3d-advanced/README.md@@ -1,6 +1,6 @@# 06 — 3D & Advanced-WebGL, shaders, particles, 3D transforms, and the performance-sensitive effects that push the browser's limits. The demos that move by themselves have Pause; the ones you hover, click or scroll have Show me or Play.+WebGL, shaders, particles, 3D transforms, and the performance-sensitive effects that push the browser's limits. The demos that move by themselves have Pause (SVG Path Animation has Replay and Loop); the ones you hover, click or scroll have Show me or Play.## Animationsdiff --git a/animations/06-3d-advanced/svg-path-animation/README.md b/animations/06-3d-advanced/svg-path-animation/README.mdindex b5270f71..c5e391f5 100644--- a/animations/06-3d-advanced/svg-path-animation/README.md+++ b/animations/06-3d-advanced/svg-path-animation/README.md@@ -44,7 +44,7 @@ paths.forEach((path, i) => {});```-**Fill at end** — trigger a fill reveal after the stroke draw completes. The path has to start with `fill: transparent`, not `fill: none`: a fill can only fade from a colour, and from `none` it would snap on.+**Fill at end** — trigger a fill reveal after the stroke draw completes. The path has to start with `fill: transparent`, not `fill: none`: a fill can only fade from a color, and from `none` it would snap on.```jspath.style.fill = 'transparent'; // not 'none'diff --git a/docs/superpowers/plans/2026-09-29-3d-content.md b/docs/superpowers/plans/2026-09-29-3d-content.mdindex ee5a91ec..ca055288 100644--- a/docs/superpowers/plans/2026-09-29-3d-content.md+++ b/docs/superpowers/plans/2026-09-29-3d-content.md@@ -1053,7 +1053,7 @@ None: leave out the `details.hb-options` block.- **Stage font:** no text on the stage; `.fallback` uses the site font.- **Stage:** only the canvas. The fps and scene badges and the shader source panel go; `.fallback` stays. `hb-dots`: no. Default height.- **Phone fallback:** today's stays: on phones (screens 600px wide or less, or 500px tall or less) the canvas draws at 0.7 of the stage's CSS size (up to 1.5 times on computers), and Detail takes two thirds of the steps there (16 · 32 · 64 in place of 24 · 48 · 96; today phones start at 32).-- **Pixel cap:** on every screen the canvas also holds about 300,000 pixels at most, and the browser scales it up: the scale is the smaller of the ratio above and `Math.sqrt(300000/(w×h))` for a stage of w×h CSS pixels. The cost is one ray march per backing pixel, so without the cap the 60 fps rule failed on integrated graphics. Measured on an Intel UHD chip, frames drawn in 3 seconds (180 is 60 fps), each run checked against a stage-sized control page that read 181–182: 1280×720 at 1.5× 96 frames before the cap and 180 after; 1440×900 at 2× 86 → 180; 1920×1080 at 1× 167 → 181; a 768×1024 tablet at 2× with the CPU slowed four times 120 → 181; the 1366×657 laptop 180 → 179, which is no change, because its canvas was already under the cap.+- **Pixel cap:** on every screen the canvas also holds about 300,000 pixels at most, and the browser scales it up: the scale is the smaller of the ratio above and `Math.sqrt(300000/(w×h))` for a stage of w×h CSS pixels. The cost is one ray march per backing pixel, so without the cap the 60 fps rule failed on integrated graphics. Measured on an Intel UHD chip, frames drawn in 3 seconds (180 is 60 fps), each run checked against a stage-sized control page that read 181–182: 1280×720 at 1.5× 96 frames before the cap and 180 after; 1440×900 at 2× 86 → 180; 1920×1080 at 1× 181 → 181 (the final review's 167 did not reproduce); a 768×1024 tablet at 2× with the CPU slowed four times 120 → 181; the 1366×657 laptop 180 → 179, which is no change (its canvas was 958×325, about 4% over the cap, and is now 940×319).**Main settings**@@ -1104,8 +1104,8 @@ None: leave out the `details.hb-options` block.- [Volumetric Smoke / 3D Noise](../volumetric-smoke/) — rays that add up smoke instead of stopping at a surface- [WebGL Shader Animation](../webgl-shader-animation/) — simpler shaders on the same setup- [Fluid / Liquid Simulation](../fluid-simulation/) — the same melting of shapes, in 2D-- **README How it works:** unchanged-- **README Production notes:** unchanged+- **README How it works:** the snippet steps `t += d * 0.9` (a little short, since blended and carved shapes are not exact distances) and stops at `t > 22.0`, as the page does (final fix wave).+- **README Production notes:** the Performance bullet says the cost scales with pixels and with the work per step, and that the demo caps its canvas at about 300,000 pixels (final fix wave).- **Category line:** `06.12 · 3D & Advanced`- **Pager:** Previous: 2.5D / Pseudo-3D (`../2-5d-pseudo-3d/`) · Next: GPGPU Particle System (`../gpgpu-particle-system/`)@@ -1174,7 +1174,7 @@ None: leave out the `details.hb-options` block.- [Fluid / Liquid Simulation](../fluid-simulation/) — a shader that melts blobs together- [WebGL Shader Animation](../webgl-shader-animation/) — shaders that paint every pixel- **README How it works:** the physics snippet matches the new shader: after `uniform int uBehavior;` add `uniform float uStep; // 1, or 1/3 in slow motion`; the vortex's four velocity lines each end in `* uStep`; the damping line becomes `vx *= pow(0.985, uStep); vy *= pow(0.985, uStep); // damping`; and the move becomes `x += vx * uStep; y += vy * uStep;`. The rest is unchanged.-- **README Production notes:** unchanged+- **README Production notes:** the phone rule reads "on phones (screens 600px wide or less, or 500px tall or less)" (final fix wave).- **Category line:** `06.13 · 3D & Advanced`- **Pager:** Previous: Ray Marching / SDF Scene (`../ray-marching-sdf/`) · Next: Image Distortion on Hover (`../image-distortion-hover/`)@@ -1248,7 +1248,7 @@ None: leave out the `details.hb-options` block.- [Parallax 3D Tilt](../parallax-3d-tilt/) — a card leans toward the pointer instead of bending- [Fluid / Liquid Simulation](../fluid-simulation/) — a liquid look that follows the pointer- **README How it works:** unchanged, plus two sentences after the procedural-texture snippet: "In the demo the pattern stands still, as a real image would: its time value stays at 0, and only the distortion moves. Once the pointer has gone and the fade has finished, the demo stops drawing, and the pointer or Show me starts it again."-- **README Production notes:** in the "Backing store and DPR" bullet, "so a paused or reduced-motion demo has to repaint after a resize or it goes black" becomes "so a demo that is not drawing every frame (this one stops at rest) has to repaint after a resize or it goes black". The rest is unchanged.+- **README Production notes:** in the "Backing store and DPR" bullet, "so a paused or reduced-motion demo has to repaint after a resize or it goes black" becomes "so a demo that is not drawing every frame (this one stops at rest) has to repaint after a resize or it goes black". The Wrap bullet names `CLAMP_TO_EDGE` (final fix wave); the rest is unchanged.- **Category line:** `06.14 · 3D & Advanced`- **Pager:** Previous: GPGPU Particle System (`../gpgpu-particle-system/`) · Next: Cloth / Soft-Body Simulation (`../cloth-simulation/`)@@ -1263,10 +1263,10 @@ None: leave out the `details.hb-options` block.- **Reset:** hangs a fresh cloth (`initCloth(paused)`, today's Reset cloth). While paused it settles the fresh cloth first (see the first picture below), so it shows the cloth already hanging, still; while playing it hangs the cloth flat and the loop lets it fall.- **Sequence:** the canvas loop as in the preamble (`loop(ts)`, 16ms gate). Each drawn frame runs `update()`, then `draw()`, as today.- **Two functions in place of today's `start()`,** which both rebuilt the cloth and started the loop: `rebuild(settle)` is `resize(); initCloth(settle);`, for Detail and for a resize (both pass `paused` on as `settle`); `resume()` is `if(raf)return; lastT=performance.now(); raf=requestAnimationFrame(loop);`, for Play (`hb:pause` with `paused` false). At load the page runs `rebuild(true)`, then `resume()`.- - **The first picture:** `initCloth(settle)` draws the cloth (today it draws only while paused). With `settle` it first runs 120 silent physics steps (`windT+=16; update();` each, two seconds of a 60 fps loop), so a cloth shown still (at load, on a paused arrival or under reduced motion) already hangs and sways, not the flat coloured rectangle it starts as; `rebuild(true)` at load does that. It costs 25 · 47 · 71 ms at Low · Medium · High on a laptop; on the throttled phone 84 ms at Low (the phone default, paid once at load), 195 ms at Medium and 470 ms at High (paid when the visitor presses Detail while paused).+ - **The first picture:** `initCloth(settle)` draws the cloth (today it draws only while paused). With `settle` it first runs 120 silent physics steps (`windT+=16; update();` each, two seconds of a 60 fps loop), so a cloth shown still (at load, on a paused arrival or under reduced motion) already hangs and sways, not the flat coloured rectangle it starts as; `rebuild(true)` at load does that. It costs 25 · 47 · 71 ms at Low · Medium · High on a laptop; on the throttled phone 84 ms at Low (the phone default, paid once at load), 195 ms at Medium and about half a second to a second at High (paid when the visitor presses Detail while paused).- **While paused,** Hangs from, Detail, Reset and a resize show a fresh cloth that has been settled first (`initCloth(paused)`, `rebuild(paused)`); while playing they hang it flat and the loop lets it fall. Shows the points redraws, and Wind, Gravity and Stiffness show at the next Play (they change how it moves).- **Dragging does nothing while paused:** the `if(paused){update();draw();}` line in the `pointermove` handler goes, so a paused cloth stays still.- - The resize handler keeps its guard (it returns when the stage's size has not changed) and calls `rebuild()`.+ - The resize handler keeps its guard (it returns when the stage's size has not changed) and calls `rebuild(paused)`.- **Reduced motion:** the page's `paused=matchMedia(…).matches` start goes, and so does the rule `*,*::before,*::after{animation:none!important;transition:none!important}` (see the preamble).- **Stage font:** no text on the stage.- **Stage:** only the canvas. The fps badge goes. `touch-action:none` on the stage and the canvas stays (dragging needs it). `hb-dots`: no. Default height.@@ -1277,7 +1277,7 @@ None: leave out the `details.hb-options` block.| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo ||---|---|---|---|---|---|-| Hangs from | Choice buttons | Two corners · Top edge · One corner · Nothing | Two corners | Where the cloth is pinned; Nothing lets it fall. | `PIN_MODE`: `'top-corners'` / `'top-edge'` / `'single'` / `'none'`, then `initCloth()` |+| Hangs from | Choice buttons | Two corners · Top edge · One corner · Nothing | Two corners | Where the cloth is pinned; Nothing lets it fall. | `PIN_MODE`: `'top-corners'` / `'top-edge'` / `'single'` / `'none'`, then `initCloth(paused)` || Wind | Choice buttons | Light · Medium · Strong | Medium | How hard the wind blows; it rises and falls. | `WIND`: 0.2 / 0.5 / 1.2 || Stiffness | Choice buttons | Stretchy · Medium · Stiff | Medium | Stretchy sags and bounces; stiff keeps its shape. | `ITERS`: 2 / 4 / 8 |@@ -1286,7 +1286,7 @@ None: leave out the `details.hb-options` block.| Setting | Control | Choices or range (value shown) | Default | Hint | Sets in the demo ||---|---|---|---|---|---|| Gravity | Choice buttons | Light · Normal · Heavy | Normal | Heavy cloth hangs straighter and falls faster. | `GRAVITY`: 0.06 / 0.12 / 0.2 |-| Detail | Choice buttons | Low · Medium · High | Medium (Low on phones) | More points make finer folds; phones start at Low. | `COLS`: 16 / 24 / 40, with `ROWS=Math.round(COLS*.75)`, then `rebuild()` |+| Detail | Choice buttons | Low · Medium · High | Medium (Low on phones) | More points make finer folds; phones start at Low. | `COLS`: 16 / 24 / 40, with `ROWS=Math.round(COLS*.75)`, then `rebuild(paused)` || Shows the points | Switch | on / off | off | Marks each point; pinned ones are red. | `SHOW_VERTS` true / false, then `draw()` while paused |- **Removed:**@@ -1347,7 +1347,7 @@ None: leave out the `details.hb-options` block.- **The plume's edge:** `density()` returns 0 at once where the plume's shape is faint, `if(src<1e-3)return 0.;` after the `src` line and before the `fbm` line, so the five noise samples are only taken where there can be smoke. The first picture changes by 4/255 at most in a pixel (12/255 at most with Thick smoke; 15/255 later in the loop).- **The canvas:** it is capped at about 65,000 pixels. It draws at `Math.min(devicePixelRatio, 0.75 on phones and 1 elsewhere, Math.sqrt(65000/(w×h)))` of the stage's CSS size, where w×h is the stage's size in CSS pixels, and the browser scales it up (the resize guard compares the resulting canvas size, as before). With both changes the stage differs from today's by 0.05 to 0.15/255 on average; the grain is a little coarser. The cap was 90,000 at first, which drew only 148 to 156 frames in 3 seconds on a portrait tablet (768×1024 at 2×, CPU slowed four times); 65,000 draws 181 there, and its first picture differs from the 90,000 one in 0.02% of its pixels by more than 8/255. Laptops and landscape tablets draw 181 at every cap.- **Phones** are screens 600px wide or less, or 500px tall or less (held sideways). There the canvas is also at most 0.75 of the stage and a ray takes at most 48 steps, so High is 48 (today's).- - **Measured:** frames drawn in 3 seconds at Medium (180 is a full 60 fps), before → after: 1366×657 laptop 23 → 180, 1280×800 computer 21 → 181, tablet 25 → 156, phone held upright 114 → 180, phone held sideways 61 → 181; at High: 12 → 122, 11 → 113, 14 → 85, 80 → 159 (48 steps), 44 → 160 (48 steps). Low draws about 180 on every screen.+ - **Measured:** frames drawn in 3 seconds at Medium (180 is a full 60 fps), before → after: 1366×657 laptop 23 → 180, 1280×800 computer 21 → 181, tablet 25 → 181 (156 at the first 90,000 cap), phone held upright 114 → 180, phone held sideways 61 → 181; at High (measured at the first 90,000 cap): 12 → 122, 11 → 113, 14 → 85, 80 → 159 (48 steps), 44 → 160 (48 steps). Low draws about 180 on every screen.**Main settings**@@ -1398,7 +1398,7 @@ None: leave out the `details.hb-options` block.- [Ray Marching / SDF Scene](../ray-marching-sdf/) — rays that stop at surfaces instead of adding up smoke- [Noise-Based Motion](../noise-based-motion/) — the same kind of noise, on a flat canvas- [Fluid / Liquid Simulation](../fluid-simulation/) — a soft, liquid look drawn by a shader-- **README How it works:** in the `smokeDensity` snippet, `t * speed` becomes `rise`, and the line `if (src < 0.001) return 0.0; // nothing to add here, so skip the noise` goes after the `src` line, before the `fbm` line. These sentences follow the snippet, as two paragraphs: "`rise` grows every frame by the frame's time × the speed, on the page, so changing the speed never makes the smoke jump." and "Wherever `src` has faded to almost nothing the function returns before the noise, so the five noise samples are only taken where there can be smoke. That, together with the smaller canvas described under Mobile cost, keeps the demo smooth on laptops and phones." The rest is unchanged.+- **README How it works:** in the `smokeDensity` snippet, `t * speed` becomes `rise`, and the line `if (src < 0.001) return 0.0; // nothing to add here, so skip the noise` goes after the `src` line, before the `fbm` line. These sentences follow the snippet, as two paragraphs: "`rise` grows every frame by the frame's time × the speed, on the page, so changing the speed never makes the smoke jump." and "Wherever `src` has faded to almost nothing the function returns before the noise, so the five noise samples are only taken where there can be smoke. That, together with the smaller canvas described under Mobile cost, keeps the demo smooth on laptops and phones." The snippet's last line reads `* src * density * 2.0`, as the page does (final fix wave). The rest is unchanged.- **README Production notes:** the Mobile cost bullet is rewritten, the rest is unchanged:> - **Mobile cost**: this is fill-rate bound — every fragment runs up to `steps x (fbm + 3 shadow taps)`, so the demo trims it three ways. `smokeDensity` returns before the noise wherever the plume has faded out. The backing store is capped at about 65,000 pixels and the browser scales it up to the stage, which suits soft smoke; it never exceeds 1 CSS pixel per fragment either. On phones (screens 600px wide or less, or 500px tall or less when held sideways) the backing store is also at most 0.75 of the stage and the march at most 48 steps. Honouring a 3x phone DPR would multiply the cost ninefold.