linejig
Draws interactive 3D line illustrations in three.js. One object is built from a few rounded solids and drawn in an isometric view (2:1 axonometric) with one fine line width, in line art (white and black, hierarchy by tone) or in the Brand, Dots, Readout and Pencil styles, so all figures keep a consistent illustration style. It builds in (stack or draw-on), then its one hero part (a needle, a lid, the keys of a keyboard) answers hover and click, and the user can drag to turn and zoom it. No capti
Install
npx skills add https://github.com/37degree-studio/linejig --skill linejigMotion rules
Built in three.js 0.160.0 with Line2 / LineSegments2 fat lines, pinned, with an import map (the line addons import
the bare name three). No AI image or video generation for the drawing or its motion.
Principles
- Motion means something. Each move is what the real object does (a needle settles, a lid lifts, a key turns, an instrument swings) or what a camera does (push, pull, pan). One idea per move.
- It lands once. The illustration builds on entry, makes its move, and holds.
- Two clocks, after Hairline:
- Tween for discrete moves: 700 ms on
cubic-bezier(.32,.72,0,1). Retarget from where it is, never from the start. Stagger related parts by 60 to 200 ms. - Spring for physical settling: k 100, c 18, integrated per frame. Hairline's m 1 is critically damped (overshoot about 0.1°, invisible); use m 2 for a visible overshoot of about 5° on a 60° swing. It overshoots a little and settles, which suits needles, balances and swinging parts. Use it only where the real object would overshoot.
- Tween for discrete moves: 700 ms on
- Camera zoom interpolates scale logarithmically and the centre linearly.
Moves
Intro types (the user chooses)
The intro is selectable, not fixed. Ask the user which one they want, or offer two to compare. In code it is one
setting, INTRO, which a ?intro= URL parameter overrides, so they can be compared side by side. Each one ends on
the same finished drawing, then the hero makes its move.
No dead time: drag, zoom and reset work from the first frame, and from the first frame a hover on the hero or a press
cuts the hero's own move short (a hero that has not arrived yet answers as soon as it is on screen). The figure goes
live at once (onLive runs then, once), the parts still in flight keep landing (the stack, or the draw-on, plays to its
end, with K.stacking true until it does), and its state eases from the intro's pose into the live one over 400 ms, so
state() need not match its intro and live branches. Untouched, the intro plays to liveAt as before.
Planning the stack for each illustration
The stack is not one generic animation. Work it out for each object from how that kind of object is really put together, before you write any code, and write the plan down as an assembly table:
- Name the object's type and how such things are assembled. Use real assembly order, not screen order.
- Find the base, the part everything else is fixed to (a body, a foot, a floor, a chassis). It comes first, from above or rising from its footprint.
- Give every other part its mounting face on a part that is already there, and its
fromvector, the outward normal of that face. A part arrives only after the part it mounts on. - Stack along each axis in order. Coaxial parts go innermost first (lens mount, then the focus ring, then the front ring). Nested parts go outer frame first, then what it holds (a gimbal ring, then the bowl in it).
- The hero comes last, then makes its own move.
Patterns by type:
If an object fits none of these, reason it out from steps 1 to 5. If the plan has a part arriving through another part, or before what it mounts on, the plan is wrong. Fix the plan, not the timing.
More ideas to try later, each still one plain move:
extrude: every footprint is drawn flat on the ground first, then all the solids rise to their heights together.assemble: the parts start pulled apart along their own axes (an exploded view) and slide together.blueprint: dashed construction lines and axes appear first, then the solids form on them, then the guides fade.sweep: a plane passes across the object and leaves the finished drawing behind it.
Before adding one, check it fits the object (stack suits things built in layers, like a stepwell or a chest of trays; assemble suits mechanisms) and it doesn't compete with the hero's move.
Hand-overs (when several illustrations share a page or deck)
- Default: the outgoing drawing fades over about 450 ms while the incoming one arrives.
- Related objects can hand over in one move (a surveyor's theodolite pulls back and slides left while a map grows from the point it was sighting).
- Only the outgoing and incoming drawings exist. Hide and stop every other one at once.
- Going backwards, the drawing is simply there in its final state.
Scrub (scroll stories)
A host can drive a figure's progress instead of its clock: one object that assembles, then opens, as the page
scrolls. fig.scrub(t, { open, split }) (or embedded {type: 'scrub', t, split?, open?}, or ?intro=scrub to start
at 0) maps t in [0, 1] onto the stack intro, parts arriving in ASSEMBLY order, for 0 to split (default 0.75), and
onto the hero's click, from rest to its opened state, for split to 1. While scrubbing the figure plays no intro
and no motion of its own and takes no hover; scrub(null) hands it back and replays. The figure needs nothing new:
a good ASSEMBLY order and an opened state are the whole story.
- One step of text per moment; give each step the t it shows when its text reaches the middle of the screen. The last step is t = 1, the opened state.
- The host eases t toward the scroll (a fifth of the gap a frame); with reduced motion it sets t directly. The figure's own reduced-motion rule does not apply: the reader is moving it.
- Examples: site/stories/espresso.html and suitcase.html, with site/stories/story.js.
Reduced motion
With prefers-reduced-motion: reduce or ?reduced=1: no moves, no draw-on; the final state appears at once (a
250 ms fade at most).
Capture hook
?freeze=MS stops the clock MS after the start. Under headless Chrome drive frames with setTimeout (about every
50 ms) while frozen; virtual time runs timers more reliably than animation frames.