UI / Decor
Room Prop
One thing out of the 3D room on a turntable: the bed, a desk, the wardrobe, a plush toy or the Christmas tree, each answering a press the way it does in the room.
A queen bed with a pillow, a phone and a row of plush toys
Drag to turn it. Press it to set it off, the way it does in the room.
Installation
npx shadcn@latest add https://jiaweing.com/r/room-prop.jsonWith the @jiaweing namespace set up, use @jiaweing/room-prop in place of the URL.
Usage
tsx
import { RoomProp } from "@/components/room/room-prop";tsx
<div className="h-72 w-72">
<RoomProp model="bed" />
</div>- A press sets it off the way it does in the room: drawers open, lights go off and on, toys hop.
- Writing on screens and signs uses the page's own font.
- 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
RoomProp
| Prop | Type | Default | Description |
|---|---|---|---|
| model | "bed" | "main-desk" | "second-desk" | "pc" | "chair" | "crate" | "drawers" | "bedside" | "wardrobe" | "floor-light" | "shelves" | "phone" | "flowers" | "mouse" | "headphones" | "dozy" | "elephant" | "rabbit" | "red-panda" | "nibble" | "tree" | "snowman" | "wreath" | "fairy-lights" | "santa-hat" | - | Which thing of the room to show. |
| spin | number | 0.35 | Turns a second on its own. 0 holds it still. |
| label | string | - | What screen readers say for it. Default: what it is. |
| className | string | - | Classes on the stage. It fills its parent, so give the parent a height. |
MIT licensed. Copy it, change it, ship it.