# Wooden Bed

> A cozy low-poly wooden bed with an arched headboard, corner posts, a thick mattress, puffy pillows and a colored blanket with a folded-back sheet. Switch between single and double width and recolor the blanket and wood. Fits bedrooms, inns, cabins and RPG house interiors.

![Wooden Bed preview](https://codels.download/m/bed.png)

Multi-view sheet (3/4, front, side, top): https://codels.download/m/bed.sheet.png

## Facts

- Category: Props › Furniture
- Size (W × H × D): 1.73 × 1.07 × 2.20 m — units are meters, +Y up, front faces +Z
- Origin: center of the base (y = 0)
- Triangles: 572 · Meshes: 20 · Materials: 6
- License: CC0-1.0 (Codels built-in)
- Tags: bed, bedroom, tavern, cartoon, low-poly, stylized, medieval, modern, interior, village, city-builder, rpg, checkpoint, furniture, interactable, prop, fabric, wood, wide, mobile-friendly, parametric, color-blue, color-brown, color-orange, size-medium, poly-low
- Page: https://codels.download/models/bed

## Files

| Format | URL |
|---|---|
| three.js ES module (`createBed()`) | https://codels.download/m/bed.js |
| React Three Fiber component (`<Bed />`) | https://codels.download/m/bed.jsx |
| Instancing module (`createBedInstances(count, place)`, one draw call per material) | https://codels.download/m/bed.instanced.js |
| Standalone HTML demo | https://codels.download/m/bed.html |
| glTF binary | https://codels.download/m/bed.glb |
| glTF binary, Meshopt-compressed (2–3× smaller; GLTFLoader needs `setMeshoptDecoder(MeshoptDecoder)`) | https://codels.download/m/bed.glb?compress=meshopt |
| glTF JSON | https://codels.download/m/bed.gltf |
| OBJ (vertex colors) + MTL | https://codels.download/m/bed.obj · https://codels.download/m/bed.mtl |
| STL | https://codels.download/m/bed.stl |
| CodelSpec JSON | https://codels.download/m/bed.json |

## Parameters

Append them as query parameters to any URL above to get a customized variant (e.g. `?size=...`).

| Param | Type | Range / options | Default | Current |
|---|---|---|---|---|
| `size` | select | single \| double | double | double |
| `blanket` | color | #rrggbb | #3b609e | #3b609e |
| `wood` | color | #rrggbb | #9c6236 | #9c6236 |

## Parts

- postHead (box · woodDark)
- postFoot (box · woodDark)
- knob (cylinder · woodDark)
- knob (cylinder · woodDark)
- sideRail (box · wood)
- postHead (box · woodDark)
- postFoot (box · woodDark)
- knob (cylinder · woodDark)
- knob (cylinder · woodDark)
- sideRail (box · wood)
- headboard (extrude · wood)
- headRail (box · woodDark)
- footboard (box · wood)
- footRail (box · woodDark)
- mattress (box · mattress)
- blanket (box · blanket)
- sheetFold (box · sheet)
- blanketStripe (box · blanketDark)
- pillow (extrude · sheet)
- pillow (extrude · sheet)

## How to use

Save the code below as `bed.js`, then:

```js
import { createBed } from './bed.js';
const model = createBed();
scene.add(model);
```

## Code

```js
/**
 * Wooden Bed — Codels 3D model library (https://codels.download/models/bed)
 * License: CC0-1.0 · Units: meters · Y-up · Front: +Z · Origin: center of the base (y = 0)
 * Triangles: 572 · Size (W × H × D): 1.73 × 1.07 × 2.20 m
 *
 * Usage:
 *   import { createBed } from './bed.js';
 *   
 *   const model = createBed();
 *   model.position.set(0, 0, 0);
 *   scene.add(model);
 */
import * as THREE from 'three';

const deg = THREE.MathUtils.degToRad;

// Extrude a 2D outline along Z (centered). bevel = [thickness, size, segments].
function extrude(outline, depth, holes = [], bevel = null) {
  const shape = new THREE.Shape(outline.map(([x, y]) => new THREE.Vector2(x, y)));
  for (const hole of holes) shape.holes.push(new THREE.Path(hole.map(([x, y]) => new THREE.Vector2(x, y))));
  const options = bevel
    ? { depth, bevelEnabled: true, bevelThickness: bevel[0], bevelSize: bevel[1], bevelSegments: bevel[2] }
    : { depth, bevelEnabled: false };
  return new THREE.ExtrudeGeometry(shape, options).translate(0, 0, -depth / 2);
}

export function createBed() {
  const root = new THREE.Group();
  root.name = 'Bed';

  // Materials
  const woodMat = new THREE.MeshStandardMaterial({ name: 'wood', color: 0x9c6236, roughness: 0.85, flatShading: true });
  const woodDarkMat = new THREE.MeshStandardMaterial({ name: 'woodDark', color: 0x704727, roughness: 0.9, flatShading: true });
  const mattressMat = new THREE.MeshStandardMaterial({ name: 'mattress', color: 0xe9e3d6, roughness: 1, flatShading: true });
  const sheetMat = new THREE.MeshStandardMaterial({ name: 'sheet', color: 0xf6f2ea, roughness: 1, flatShading: true });
  const blanketMat = new THREE.MeshStandardMaterial({ name: 'blanket', color: 0x3b609e, roughness: 1, flatShading: true });
  const blanketDarkMat = new THREE.MeshStandardMaterial({ name: 'blanketDark', color: 0x2e4b7b, roughness: 1, flatShading: true });

  // Shared geometries
  const boxGeo = new THREE.BoxGeometry(0.085, 1.02, 0.085);
  const boxGeo2 = new THREE.BoxGeometry(0.085, 0.62, 0.085);
  const cylinderGeo = new THREE.CylinderGeometry(0.025, 0.0468, 0.05, 6);
  const boxGeo3 = new THREE.BoxGeometry(0.05, 0.16, 2.105);
  const extrudeGeo = extrude([[0.31, 0.12], [0.2895, 0.1695], [0.24, 0.19], [-0.24, 0.19], [-0.2895, 0.1695], [-0.31, 0.12], [-0.31, -0.12], [-0.2895, -0.1695], [-0.24, -0.19], [0.24, -0.19], [0.2895, -0.1695], [0.31, -0.12]], 0.07, [], [0.035, 0.03, 2]);

  // Parts
  const postHead = new THREE.Mesh(boxGeo, woodDarkMat);
  postHead.name = 'postHead';
  postHead.position.set(-0.8225, 0.51, -1.0525);
  root.add(postHead);
  const postFoot = new THREE.Mesh(boxGeo2, woodDarkMat);
  postFoot.name = 'postFoot';
  postFoot.position.set(-0.8225, 0.31, 1.0525);
  root.add(postFoot);
  const knob = new THREE.Mesh(cylinderGeo, woodDarkMat);
  knob.name = 'knob';
  knob.position.set(-0.8225, 1.045, -1.0525);
  root.add(knob);
  const knob2 = new THREE.Mesh(cylinderGeo, woodDarkMat);
  knob2.name = 'knob';
  knob2.position.set(-0.8225, 0.645, 1.0525);
  root.add(knob2);
  const sideRail = new THREE.Mesh(boxGeo3, woodMat);
  sideRail.name = 'sideRail';
  sideRail.position.set(-0.8, 0.25, 0);
  root.add(sideRail);
  const postHead2 = new THREE.Mesh(boxGeo, woodDarkMat);
  postHead2.name = 'postHead';
  postHead2.position.set(0.8225, 0.51, -1.0525);
  root.add(postHead2);
  const postFoot2 = new THREE.Mesh(boxGeo2, woodDarkMat);
  postFoot2.name = 'postFoot';
  postFoot2.position.set(0.8225, 0.31, 1.0525);
  root.add(postFoot2);
  const knob3 = new THREE.Mesh(cylinderGeo, woodDarkMat);
  knob3.name = 'knob';
  knob3.position.set(0.8225, 1.045, -1.0525);
  root.add(knob3);
  const knob4 = new THREE.Mesh(cylinderGeo, woodDarkMat);
  knob4.name = 'knob';
  knob4.position.set(0.8225, 0.645, 1.0525);
  root.add(knob4);
  const sideRail2 = new THREE.Mesh(boxGeo3, woodMat);
  sideRail2.name = 'sideRail';
  sideRail2.position.set(0.8, 0.25, 0);
  root.add(sideRail2);
  const headboard = new THREE.Mesh(extrude([[-0.79, 0], [-0.79, 0.5], [-0.5925, 0.5459], [-0.395, 0.5849], [-0.1975, 0.6109], [0, 0.62], [0.1975, 0.6109], [0.395, 0.5849], [0.5925, 0.5459], [0.79, 0.5], [0.79, 0]], 0.045), woodMat);
  headboard.name = 'headboard';
  headboard.position.set(0, 0.3, -1.0525);
  root.add(headboard);
  const headRail = new THREE.Mesh(new THREE.BoxGeometry(1.58, 0.05, 0.06), woodDarkMat);
  headRail.name = 'headRail';
  headRail.position.set(0, 0.295, -1.0525);
  root.add(headRail);
  const footboard = new THREE.Mesh(new THREE.BoxGeometry(1.58, 0.26, 0.04), woodMat);
  footboard.name = 'footboard';
  footboard.position.set(0, 0.4, 1.0525);
  root.add(footboard);
  const footRail = new THREE.Mesh(new THREE.BoxGeometry(1.6, 0.045, 0.065), woodDarkMat);
  footRail.name = 'footRail';
  footRail.position.set(0, 0.5525, 1.0525);
  root.add(footRail);
  const mattress = new THREE.Mesh(new THREE.BoxGeometry(1.5, 0.22, 2), mattressMat);
  mattress.name = 'mattress';
  mattress.position.set(0, 0.41, 0);
  root.add(mattress);
  const blanket = new THREE.Mesh(new THREE.BoxGeometry(1.55, 0.21, 1.42), blanketMat);
  blanket.name = 'blanket';
  blanket.position.set(0, 0.44, 0.31);
  root.add(blanket);
  const sheetFold = new THREE.Mesh(new THREE.BoxGeometry(1.56, 0.035, 0.12), sheetMat);
  sheetFold.name = 'sheetFold';
  sheetFold.position.set(0, 0.5495, -0.35);
  root.add(sheetFold);
  const blanketStripe = new THREE.Mesh(new THREE.BoxGeometry(1.556, 0.212, 0.08), blanketDarkMat);
  blanketStripe.name = 'blanketStripe';
  blanketStripe.position.set(0, 0.442, 0.77);
  root.add(blanketStripe);
  const pillow = new THREE.Mesh(extrudeGeo, sheetMat);
  pillow.name = 'pillow';
  pillow.position.set(-0.36, 0.575, -0.73);
  pillow.rotation.set(deg(-78), 0, 0);
  root.add(pillow);
  const pillow2 = new THREE.Mesh(extrudeGeo, sheetMat);
  pillow2.name = 'pillow';
  pillow2.position.set(0.36, 0.575, -0.73);
  pillow2.rotation.set(deg(-78), 0, 0);
  root.add(pillow2);

  root.traverse((o) => {
    if (o.isMesh) {
      o.castShadow = true;
      o.receiveShadow = true;
    }
  });
  return root;
}

export default createBed;
```

---
Codels — 3D models as code for three.js. Search more: https://codels.download/api/v1/models?q=<query> · Guide: https://codels.download/llms.txt
