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 linejigInteraction rules
The illustration plays its intro (draw-on, then the hero's move), then becomes something the user can handle. Interaction turns on only after the intro lands.
One hero, the rest still
- Name the hero before building: the one part that carries the message. It is the
hipart. If the object has a control that drives another part (a camera's shutter button drives the lens and shutter), the control is the hero: hover is the half-press (the lens hunts focus), click is the full press (the shutter fires). - The hero can be a family of identical parts that each work the same way: the keys of a keyboard, piano keys,
buttons on a panel, drawers in a cabinet. Then every member answers the pointer, one at a time (hover presses or
opens the one under the pointer; click does its full action). One member may carry the
hitone as the accent (the keyboard's Enter); the rest keep their tones. The frame or case still stays still. - Only the hero has its own response. Every other part moves only with the whole object, when the user turns or zooms the view.
- The hero's response is what the real part does when touched or approached:
If the hero has no natural response, choose another hero or another object.
- On leave, the hero springs back to rest.
Turning and zooming the view
- Turn: a click-drag, or a one-finger drag on touch, orbits the camera around the object. Clamp azimuth to ±40° and elevation to 15° to 60° around the rest view, and damp it with the spring. On release the view stays for about 2 s, then springs back to rest, so the drawing always returns to its composed view.
- Zoom: the wheel or a two-finger pinch, 0.8× to 2.5×, toward the pointer (orthographic zoom plus a pan). Lines stay 1 px at every zoom. A double-click or double-tap resets the view.
- Do not fight the page. On a full-screen illustration the wheel may zoom. On an illustration embedded in a
scrolling page, the wheel zooms only with Ctrl or a pinch (the kernel does this under
?embed=1), so scrolling still scrolls. Puttouch-action: noneon the canvas only.
Hit testing
Raycast against the hero's fill mesh. Give it a generous, invisible hit area (a disc over the compass card, a box around a key), so a thin part is easy to catch.
Hints
The cursor is the only hint: grab / grabbing over the object, pointer over the hero. No text, tooltips,
handles or UI chrome.
Reduced motion
Direct manipulation still works (the user is driving it), but with no springs or overshoot: the hero snaps to its target and the view stays where it was left.
In the kernel
Figures are built on the kernel (https://linejig.com/kernel/linejig.js), which wires orbit, zoom, hit testing, cursors and reduced motion.
The figure registers hit areas while it draws (K.hit(id, poly), nearest last) and names its hero:
id is the hit area's id, so a family hero gets one per member. K.hover and K.pointer are there each frame for a
hero that follows the pointer (the needle, the focus ring).
The action event
A hero's click can hand off to the host page: an empty state's "compose", an onboarding step's "continue". Give the
hero action: '<id>' and opened(st), true once its move reaches its open state (the lid open, the cap lifted).
At that moment the kernel posts {type: 'action', id, figure} to the parent when embedded, and dispatches a
linejig:action CustomEvent on the window when standalone. Without opened, it fires one tween (700 ms) after
the click. The host owns the words (the gallery shows the manifest's action.label as a button); the drawing never
does.
Turntable mode
?mode=turntable, or the mode message: no hand, and after the intro the object turns slowly about its vertical
axis, ±35° over 40 s (or one full turn in 40 s with turntable: 'full', only for a figure whose back is finished).
For loading screens and screen-recorded loops. Reduced motion holds it still.
Open finished, click from the host, keyboard
?intro=none(any figure) opens the figure finished and live, with no intro played.def.intro: 'none'andfig.setIntro('none')do the same. With none,?freeze=MScounts from the finished state.noneis never listed in theintrosthe figure reports, so menus built from that list stay as they were.- Embed message in:
{type: 'click', id?}clicks the hero as a pointer press would (id defaults to the hero), and{type: 'intro', value: 'none'}jumps to the finished figure. Thereadymessage carriesclick: true, so a host can check for the click message before relying on it. - The
createFigureresult hassetIntro(name | 'none')andclick(id?). A def can carryname(used for the aria-label) andHERO.label(the action's wording). - Keyboard: a figure with
HERO.actionthat is interactive and takes pointer events is a button. Tab focuses it and shows the hover state with a 2 px ink focus ring around the object; Enter or Space clicks; Escape or blur leaves. Turntable, freeze andpointer-events: nonehosts get no tab stop. A cross-origin host that disables pointer events on the iframe should also settabindex="-1"on it.