Skip to content

Domino Chain (Real Physics)

A long line of dominoes topples one after another, simulated with real forces — then the camera pulls back.

Physics, D1 MotionAny rendererReal physics170 lines of codev1.0.0

In Science & maths, Toys, games & parties

Next: Bouncing Balls (Real Physics)Surprise me

Domino Chain (Real Physics) preview
Starting live preview…
00:00:00:00 / 00:00:00:01

Live, running the real source.

Your current settings go with it. Combine several clips and hand them over together from your sequence.

Effect controls

Presets

36
0.55

Distance between dominoes as a fraction of their height. Closer falls faster.

1.4

How hard the first domino is flicked. Too soft and it will not tip — that is physics.

14

9.81 behaves like metre-tall dominoes. Raise it for a quicker, smaller-looking chain.

The preview runs the same code your AI receives. These settings travel with the hand-off.

Info

What it is

Push the first domino and watch the wave run down the line. Each domino is simulated with gravity and contact forces, so the speed of the wave, the way pieces lean on each other and the final resting angles come from the physics rather than a keyframed animation. Change how many dominoes there are, how far apart they stand, how hard the first one is pushed and the colour gradient along the line.

Reuse it in your own idea

  • Build 3D dominoes in Three.js and rotate each about its front-bottom edge by angleAt (works with Orbit Camera).
  • Let the last domino trigger a Kinetic Title reveal by starting the title at the frame where the last angle exceeds 0.05.
  • Use frontAt(frame) to drive a progress indicator or camera in any scene.

Which part is reusable

src/domino-chain.js is the ingredient your AI reuses. demo.js is only the example scene around it, and uses the demo harness only for the demo.

Good to know

  • One degree of freedom per domino: no sliding, bouncing or tumbling, so impossible-looking setups (very wide spacing) simply stop.
  • Straight line on a flat floor; no curves, branches or other objects.
  • Contact is a stiff spring (penalty) model; pieces can overlap by up to about 0.04 units (4% of height) while pressing.

Technical details

Technical details
Implementation
Plain JavaScript math — works with any renderer · ES module src/domino-chain.js
Exports
  • simulateDominoChain({ count?, spacing?, thickness?, gravity?, push?, fps?, durationSeconds?, stepHz? }) => { angleAt(frame, i), pivotX(i), frontAt(frame), count, spacing, thickness, height, frameCount, stats }
  • drawDomino(ctx, sim, frame, i, view, fill?, pip?) => void
Dependencies (exact)
  • apw-runtime@1.0.0 (demo) — Demo harness and colour helpers. src/domino-chain.js has no dependencies.
How it fits a scene

Coordinates: Side view. Domino height = 1 unit, floor at y = 0, domino i pivots on its front-bottom edge at x = i × spacing.

Lighting: None (motion only).

Timing: Bake once; frames are random-access lookups.

Output
1080×1080, 30 fps, 8 s · physics simulation, baked at a fixed step (deterministic) · not a loop — The chain falls once and stays down.
Tested
Rendered 240 frames on 2026-10-02 in Chrome 151.0.7922.137 headless on Linux 7.0.0-31-generic (x64), Node 22.14.0 (Canvas 2D). Same frame twice from fresh pages: identical.
Performance
Baking 8 s of 36 dominoes at 4 kHz takes roughly 60–130 ms in Node 22. Playback is a lookup. Up to 80 dominoes; straight line only.
Export a video yourself
Download the source, then in the folder: npm install npm run render -- domino-chain/1.0.0 --out my-video.mp4Needs Node 18+, ffmpeg and Chrome/Chromium. Add --params my-settings.json (from Copy settings) for your own settings.
Version
1.0.0 · sha256:e992e482d596745a… · other versions: 1.1.0
Files
License
MIT. Copyright (c) 2026 AI Pixel Wizard. Released under the MIT License (see LICENSE in this folder). License details
Provenance
Original code written for AI Pixel Wizard in October 2026.
BinMore like this

Coin Stack

3D object3DSeamless loop12 seconds

Jelly Cube

3D object3DSeamless loop10 seconds