UI / Decor
Room Kit
The 3D room's building kit for three.js: soft boxes, cylinders and balls in one flat ink each, the seven inks, toon paints, and a small stage that shows one model on a see-through turntable.
Made with the kit
10 soft shapes, welded into one mesh. Drag to turn it.
The seven inks
- amber
- pink
- magenta
- indigo
- cyan
- green
- lime
Installation
npx shadcn@latest add https://jiaweing.com/r/room-kit.jsonWith the @jiaweing namespace set up, use @jiaweing/room-kit in place of the URL.
Usage
tsx
import { Group } from "three";
import { ModelStage } from "@/components/room/model-stage";
import { ball, box, INK, weld } from "@/components/room/scene/kit";tsx
<div className="h-64 w-64">
<ModelStage
build={(mats) => {
const root = new Group();
box(root, INK.indigo, [0.6, 0.4, 0.6], [0, 0, 0]);
ball(root, INK.amber, 0.18, [0, 0.58, 0]);
weld(root, mats);
return { object: root };
}}
label="A blue block with a gold ball on top"
modelKey="block"
/>
</div>- Every other part of the room installs this first, so the room, the models and the effects share one copy.
- Drag sideways to turn it. Up and down drags still scroll the page.
- three.js is only fetched in the browser, once it is on the page. Nothing is drawn while it is scrolled out of sight, and the WebGL context is let go on unmount.
- For visitors who ask for reduced motion, it holds still and a press jumps straight to where it ends.
Props
ModelStage
| Prop | Type | Default | Description |
|---|---|---|---|
| build | (mats, box, still) => Model | Promise<Model> | - | Makes the model from the room's paints. A Model is { object, idle?, hover?, press?, dispose? }. |
| modelKey | string | - | Changes when build would make something else. |
| spin | number | 0.35 | Turns a second on its own. 0 holds it still. |
| label | string | - | What screen readers say for it. |
| className | string | - | Classes on the stage. It fills its parent, so give the parent a height. |
scene/kit
| Prop | Type | Default | Description |
|---|---|---|---|
| box, cyl, ball | (parent, color, size, at, opts?) => Mesh | - | Soft shapes in one flat ink each. weld(root, mats) joins them into one mesh. |
| INK, INK_LIST | Color | - | The seven inks of the 2026 gradient, and the ink and paper. |
| oklch | (l, c, h) => Color | - | A three.js colour from OKLCH. |
MIT licensed. Copy it, change it, ship it.