An exploded mechanical watch whose Swiss lever escapement is simulated, not animated.
A watch movement pulled apart into its layers and turning slowly in an isometric view: a perlage main plate with jewels and blued screws, the barrel with a mainspring that visibly tightens as you wind it, a going train of involute wheels and pinions (72:12, 80:10, 75:10, 70:7), the escape wheel, the pallet fork and a 2.5 Hz balance with a breathing hairspring. The balance is a torsion oscillator integrated thousands of times a second. When its impulse pin is in the fork, each pallet stone moves along the escape wheel's tip circle, so a tooth is held on a locking face (lock), dragged free (unlock), slides along the slanted impulse face while the mainspring's work is handed to the balance as torque (impulse), then spins free until the other stone catches it (drop). Amplitude is whatever balances that energy against friction, so it climbs when you wind and sags as the spring runs down. The loupe and the trace show each phase as it happens.
Try it. Drag the knurled crown downward to wind the mainspring. Drag elsewhere to turn and tilt the view. Left and right arrows spin the view, up and down change the slow motion (from real time to 1/50), E collapses or explodes the layers, W winds, Space pauses.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build a simulation of a mechanical watch's Swiss lever escapement with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Make a canvas that fills the window, stays sharp on high-DPI screens (scale by devicePixelRatio), and resizes with the window. Use a dark background.
- Model the balance wheel as a torsion oscillator: angle'' = -w0^2 * angle - damping * angle', with w0 for 2.5 Hz. Integrate it in small fixed substeps and draw it as a ring with three arms.
- Draw a 15-tooth escape wheel and a pallet fork pivoting between the escape wheel and the balance, with two pallet stones.
- Give the escapement four phases. The fork rests on a banking pin while a tooth sits on a stone's locking face (lock). When the balance's impulse pin enters the fork notch, the fork angle follows the pin and drags the stone free (unlock). The tooth then slides along the stone's slanted face, so the escape wheel's advance is a function of the fork angle; give the balance torque equal to the mainspring torque times d(wheel angle)/d(balance angle) (impulse). When the tooth leaves the face, let the wheel spin freely until the other stone catches the next tooth (drop).
- Show the current phase as text and the balance amplitude in degrees.
Once that works, make it beautiful:
- Add a slow-motion control, so the phases can be seen, and a strip chart of the balance angle coloured by phase.
- Draw a breathing hairspring: a spiral whose inner end turns with the balance while the outer end stays pinned.
- Add a mainspring the visitor winds by dragging, raising the torque and with it the amplitude.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as the full going train with involute wheels, an exploded isometric view of the movement, or a timegrapher that plots the beat error.