inkworks
Builds interactive 3D "how it works" explainer pages for any machine or mechanism (engines, pumps, locks, gearboxes, turbines, printers, hearts) in the Inkworks look, a white engineering drawing with ink-outlined three.js parts, numbered balloon labels and a cycle you can slow down, step, scrub and orbit. Two layouts, a full drafting sheet with instruments and a cycle chart, or a clean figure card with the model alone. You write one mechanism file of geometry, kinematics and words, the kit does
Install
npx skills add https://github.com/Moh4696/inkworks-skill --skill inkworksWalkthrough clips and sound
Recording
kit/tools/record.py makes a frame-exact 60 fps 1920x1080 clip of the live page.
- Virtual clock.
performance.now,Date.now,requestAnimationFrame,setTimeoutand CSS animations are replaced before the page loads, and step exactly 1/60 s per video frame. The clip is perfectly smooth however long each screenshot takes (about 3 to 10 frames a second of real time). - Real input. A drawn ink arrow cursor follows a scripted path with eased, slightly arced moves, and a red ring blooms on each press. Playwright's real mouse events do the clicking and dragging, so the slider, the orbit, the chart scrub and every button behave exactly as they do for a person.
- Viewport 1600x900 at 1.2x device scale, scaled to 1920x1080 by ffmpeg (lanczos), H.264 CRF 16,
yuv420p,+faststart. - WebKit headless renders WebGL at full speed on macOS. A screenshot occasionally stalls; the recorder retries it (the clock is paused, so the frame is identical).
Writing a plan
A plan is a Python file with build(rects, Script, centre) returning a Script. rects has the live positions (CSS px) of next, prev, play, drive (the slider), chart, stage, lists focus, speeds, phases, actions, and toggles keyed by layer.
A good 40 second order: idle while the camera settles, step through the phases, play, push the input up and hold while the rate climbs, orbit out and back with two equal drags (orbit damping keeps turning after release), toggle the housing off and on, scrub the chart or use an action, follow another unit, drop to the slowest speed, rest the cursor off the model and hold.
Always check a --frames-every 30 contact sheet before the full render: look at both ends of the stroke and both ends of the orbit.
Clips are silent by default. Add sound only when asked.
Sound
The page's state is deterministic under the virtual clock, so a dry run of the same plan gives the exact per-frame state of the video:
The log fields are [rate, input, theta, slow, playing] per frame. engine_sound.py is the worked example for an inline-4:
- Real-speed sound, not slowed with the picture: firing rate = rpm / 30 Hz, so the pitch follows the tachometer.
- Smooth pressure pulses (tau 0.45 ms; at 1.1 ms the harmonics roll off and high rpm becomes a pure hum) plus a short noise burst per firing, slightly different per cylinder for the idle burble.
- Exhaust resonances (75, 155, 330, 720, 1650, 2600 Hz) and a short pipe comb, crossfaded dark to bright with load.
- Load = throttle plus acceleration, so the rev roars and then settles. Volume follows load and rpm (idle about 11 dB under full revs).
- Intake roar from band-passed noise with the throttle, a faint valve-train tick, gentle tanh saturation, a small room, loudness-normalised to about -16 LUFS on mux.
For another machine, write its own script from the same log: a pump is a hiss on each delivery and a soft clunk at the end of each stroke; a gearbox is mesh whine at teeth x rpm. Check the result with a spectrogram (ffmpeg ... showspectrumpic) before handing it over.