---
name: inside-figure
description: Build an "inside figure" of an everyday machine as one HTML file. A comic-style 3D model you can operate with buttons, then cut open to see the working mechanism, with labelled parts. Use when the user asks for an inside figure, a cutaway, or "how does a <machine> work" as something to play with.
---

# Inside figure

You are drawing one everyday machine as a small interactive 3D figure in a single HTML file. The viewer first uses it like the real thing (buttons that do what the real controls do), then presses **Cut it open** and sees the mechanism that made it happen, with labels.

## Decide before you draw

Write these down first. If a machine fails any of them, pick another machine.

1. **Three to six actions** the viewer can take, in the order a person would: insert coin, turn crank, take gumball. Every action must change something visible.
2. **The reveal.** One sentence: what does the cut show that people do not know? ("only the bottom half of an ATM is a safe", "the claw's grip is set by the board"). The figure exists for this sentence.
3. **The mechanism** that connects each action to its result: 4 to 7 parts, each with a 3 to 8 word note. These become the labels.
4. **The cut plane.** Choose the side that exposes the mechanism while leaving the controls whole (usually a vertical plane through the middle, removing the half facing the camera).

## Look

- Comic toon shading: `MeshToonMaterial` with a 3-step gradient map (150 / 214 / 255), ambient light ~1.0, one directional light ~1.5 with soft shadows.
- Black ink: crease edges with `EdgesGeometry` (threshold ~28°) drawn as `LineSegments2` / `LineMaterial` (~1.6 px), plus an inverted hull (`BackSide`, slightly scaled) on curved shapes.
- Palette: white, paper `#f4f1ea`, greys, black `#141414`, one red `#c04d38` for the most important part, and at most one body colour per machine (muted blue, green, yellow or red).
- Paper background `#f2f1ee`, a soft blue-grey shadow on the floor (`ShadowMaterial`), orthographic camera at an isometric angle, drag to turn.
- Real proportions in metres. Build from boxes, cylinders, spheres, tori, tubes and extruded shapes. Add the small things: screws, labels, slots, seams, lights. Detail is what makes it read as the real object.

## Structure

- `shell`: the casing. Its materials get `clippingPlanes: [cut]` and `side: DoubleSide`; set `renderer.localClippingEnabled = true`.
- `guts`: the mechanism, never clipped. Controls the viewer touches (buttons, cranks, joysticks) also go in guts, so the cut never leaves them floating.
- The cut is one `THREE.Plane`. Closed: constant far outside the model. Open: through the middle. Animate the constant with an ease when the button is pressed.
- One state object, one `update(dt)` that poses everything from state. Animate with exponential approach (`x += (target - x) * (1 - exp(-dt * rate))`), not tweens.
- Labels: HTML tags at the screen edges with leader lines (SVG) to the projected part positions. Show them only when the cut is open.
- A status line that always says what to do next.
- Small synthesized sounds with WebAudio (coin, click, motor hum while something moves). Nothing plays before the first tap.

## Output

One HTML file. Load three.js from a CDN with an import map (`three` and `three/addons/`). Panel on the right with the actions as big buttons, the status line on top, and the cut button at the bottom. Keyboard shortcuts for every action. Works on a phone (panel goes below the model).

## Checklist before you hand it over

- Every action does something you can see.
- The cut reveals the sentence from step 2, and every label points at a real part.
- Nothing floats after the cut.
- It looks like the real machine at first glance, before any interaction.
