Prompt specification
Build or customize the Three.js 3D scene "Shared studio activity zones" inside the active workspace.
Engineering Constraints:
1. Runtime & Orbit: Use Three.js r160 with OrbitControls (damping enabled) and ACESFilmicToneMapping.
2. Frame Timing: Drive all motion strictly with clock.getDelta() so animation speed is FPS-independent.
3. Viewport Hygiene: Handle window resize cleanly, cap DPR at Math.min(window.devicePixelRatio, 2), and dispose geometries/materials/renderer on unmount.
Scene Metadata:
Scene: Shared studio activity zones
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/shared-studio-activity-zones-x0219
Scene Description Prompt:
A voxel studio with workbench, reading corner, exercise mat, and dining table, connected by clear paths. Three.js from cdnjs, one HTML file.
Working Three.js Starter (shared-studio-activity-zones-x0219):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voxel Studio</title>
<style>
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d7d1c5;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#app,
#app canvas {
width: 100%;
height: 100%;
display: block;
}
#app canvas {
touch-action: none;
cursor: grab;
}
#app canvas:active {
cursor: grabbing;
}
.title-card {
position: fixed;
top: 22px;
left: 22px;
z-index: 10;
max-width: 330px;
padding: 16px 18px;
color: #302c27;
background: rgba(255, 250, 240, 0.91);
border: 1px solid rgba(79, 65, 48, 0.14);
border-radius: 14px;
box-shadow: 0 10px 30px rgba(54, 45, 35, 0.12);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 6px;
color: #a86442;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0 0 7px;
font-size: clamp(22px, 3vw, 30px);
line-height: 1;
letter-spacing: -0.04em;
}
.subtitle {
margin: 0;
color: #6c6256;
font-size: 12px;
line-height: 1.5;
}
.controls {
position: fixed;
right: 20px;
bottom: 20px;
z-index: 10;
display: flex;
gap: 8px;
padding: 7px;
background: rgba(255, 250, 240, 0.9);
border: 1px solid rgba(79, 65, 48, 0.14);
border-radius: 12px;
box-shadow: 0 8px 24px rgba(54, 45, 35, 0.12);
backdrop-filter: blur(10px);
}
button {
border: 0;
border-radius: 8px;
padding: 9px 12px;
color: #493f34;
background: #eee5d7;
font: inherit;
font-size: 11px;
font-weight: 750;
cursor: pointer;
transition:
background 140ms ease,
transform 140ms ease;
}
button:hover {
background: #dfcfbb;
transform: translateY(-1px);
}
button.active {
color: white;
background: #a86442;
}
.legend {
position: fixed;
left: 22px;
bottom: 20px;
z-index: 10;
display: flex;
flex-wrap: wrap;
gap: 7px;
max-width: min(560px, calc(100vw - 44px));
padding: 8px;
background: rgba(255, 250, 240, 0.87);
border: 1px solid rgba(79, 65, 48, 0.12);
border-radius: 11px;
box-shadow: 0 8px 24px rgba(54, 45, 35, 0.1);
backdrop-filter: blur(10px);
}
.legend-item {
display: flex;
align-items: center;
gap: 6px;
padding: 5px 8px;
color: #5e5549;
font-size: 10px;
font-weight: 750;
}
.dot {
width: 8px;
height: 8px;
border-radius: 2px;
background: var(--dot);
}
.hint {
position: fixed;
right: 22px;
top: 22px;
z-index: 10;
padding: 9px 12px;
color: #62594d;
background: rgba(255, 250, 240, 0.82);
border: 1px solid rgba(79, 65, 48, 0.11);
border-radius: 9px;
font-size: 10px;
font-weight: 650;
pointer-events: none;
}
#loading {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
color: #584d40;
background: #e4ddd1;
font-size: 13px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
transition: opacity 300ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 700px) {
.title-card {
top: 12px;
left: 12px;
max-width: calc(100vw - 24px);
padding: 12px 14px;
}
.subtitle {
display: none;
}
.hint {
display: none;
}
.controls {
right: 12px;
bottom: 12px;
}
.legend {
left: 12px;
bottom: 69px;
max-width: calc(100vw - 24px);
}
.legend-item {
padding: 3px 5px;
font-size: 9px;
}
}
</style>
</head>
<body>
<div id="app"></div>
<div class="title-card">
<div class="eyebrow">Compact Living</div>
<h1>Voxel Studio</h1>
<p class="subtitle">
Four clearly defined zones, connected by an open cross-shaped walkway.
</p>
</div>
<div class="hint">Drag to orbit · Scroll to zoom · Arrow keys to rotate</div>
<div class="legend" aria-label="Studio zones">
<div class="legend-item">
<span class="dot" style="--dot:#b67747"></span>Workbench
</div>
<div class="legend-item">
<span class="dot" style="--dot:#bd756b"></span>Reading
</div>
<div class="legend-item">
<span class="dot" style="--dot:#78966f"></span>Exercise
</div>
<div class="legend-item">
<span class="dot" style="--dot:#d0aa61"></span>Dining
</div>
<div class="legend-item">
<span class="dot" style="--dot:#eee3cf"></span>Clear paths
</div>
</div>
<div class="controls">
<button id="reset-view" type="button">Reset</button>
<button id="top-view" type="button">Top view</button>
<button id="toggle-labels" class="active" type="button">Labels</button>
</div>
<div id="loading">Building the studio…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const app = document.querySelector("#app");
const loading = document.querySelector("#loading");
// ------------------------------------------------------------------
// Renderer, scene, and lighting
// ------------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
app.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd8d3c8);
scene.fog = new THREE.Fog(0xd8d3c8, 31, 65);
const camera = new THREE.PerspectiveCamera(
39,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemisphere = new THREE.HemisphereLight(0xfff5df, 0x71806e, 2.15);
scene.add(hemisphere);
const sunlight = new THREE.DirectionalLight(0xffead0, 3.4);
sunlight.position.set(8, 14, 9);
sunlight.castShadow = true;
sunlight.shadow.mapSize.set(2048, 2048);
sunlight.shadow.camera.left = -14;
sunlight.shadow.camera.right = 14;
sunlight.shadow.camera.top = 14;
sunlight.shadow.camera.bottom = -14;
sunlight.shadow.camera.near = 1;
sunlight.shadow.camera.far = 42;
sunlight.shadow.bias = -0.0004;
sunlight.shadow.normalBias = 0.025;
scene.add(sunlight);
const windowLight = new THREE.PointLight(0x9bd9ef, 5.5, 11, 2);
windowLight.position.set(4.3, 3.2, -4.8);
scene.add(windowLight);
const warmFill = new THREE.PointLight(0xffbb72, 2.2, 10, 2);
warmFill.position.set(-4.5, 4.3, 1.7);
scene.add(warmFill);
// ------------------------------------------------------------------
// Materials and geometry helpers
// ------------------------------------------------------------------
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0,
...options
});
}
const M = {
floor: material(0xcda77d),
floorEdge: material(0xa97950),
path: material(0xeee3cf),
pathEdge: material(0xd3bea0),
wall: material(0xe9e1d5),
wallTrim: material(0xf3ede4),
darkWood: material(0x684837),
wood: material(0x9b6b48),
lightWood: material(0xc99561),
paleWood: material(0xe0bd85),
charcoal: material(0x353b3b),
cream: material(0xf5e9d3),
white: material(0xf8f5ed),
sage: material(0x78966f),
darkSage: material(0x4f6f53),
coral: material(0xb96f66),
blush: material(0xd99a88),
gold: material(0xd0aa61),
blue: material(0x6e9dad),
paleBlue: material(0xb5d9df),
terra: material(0xb96845),
green: material(0x5e8050),
leaf: material(0x78965c),
soil: material(0x4d3a2c),
bookRed: material(0xa65346),
bookBlue: material(0x587b8b),
bookYellow: material(0xd1a44f),
black: material(0x252a2a),
lamp: material(0xffd99a, {
emissive: 0xffb64d,
emissiveIntensity: 0.8
}),
window: material(0x9dd6e4, {
emissive: 0x72bad1,
emissiveIntensity: 0.48,
roughness: 0.35
})
};
function addBox(
parent,
width,
height,
depth,
x,
y,
z,
mat,
castShadow = true,
receiveShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
parent.add(mesh);
return mesh;
}
function makeGroup(parent, x = 0, y = 0, z = 0, rotationY = 0) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotationY;
parent.add(group);
return group;
}
function makePlant(parent, x, z, scale = 1) {
const plant = makeGroup(parent, x, 0, z);
addBox(plant, 0.5 * scale, 0.42 * scale, 0.5 * scale, 0, 0.21 * scale, 0, M.terra);
addBox(plant, 0.58 * scale, 0.09 * scale, 0.58 * scale, 0, 0.43 * scale, 0, M.lightWood);
addBox(plant, 0.1 * scale, 1.05 * scale, 0.1 * scale, 0, 0.93 * scale, 0, M.darkWood);
addBox(plant, 0.5 * scale, 0.34 * scale, 0.34 * scale, -0.2 * scale, 1.15 * scale, 0, M.leaf);
addBox(plant, 0.34 * scale, 0.42 * scale, 0.34 * scale, 0.24 * scale, 1.35 * scale, 0, M.green);
addBox(plant, 0.38 * scale, 0.3 * scale, 0.38 * scale, 0, 1.65 * scale, 0.05 * scale, M.leaf);
addBox(plant, 0.28 * scale, 0.28 * scale, 0.45 * scale, -0.05 * scale, 1.42 * scale, 0.12 * scale, M.green);
return plant;
}
function makeCrate(parent, x, y, z, width = 0.8, depth = 0.65) {
const crate = makeGroup(parent, x, y, z);
const height = 0.55;
addBox(crate, width, height, depth, 0, height / 2, 0, M.lightWood);
addBox(crate, width + 0.04, 0.08, depth + 0.04, 0, height - 0.05, 0, M.wood);
addBox(crate, width + 0.04, 0.08, depth + 0.04, 0, 0.08, 0, M.wood);
addBox(crate, 0.1, height + 0.02, depth + 0.05, -width * 0.32, height / 2, 0, M.wood);
addBox(crate, 0.1, height + 0.02, depth + 0.05, width * 0.32, height / 2, 0, M.wood);
return crate;
}
// ------------------------------------------------------------------
// Room shell, floor, paths, and windows
// ------------------------------------------------------------------
const room = makeGroup(scene);
addBox(room, 16.4, 0.36, 12.4, 0, -0.2, 0, M.floorEdge);
addBox(room, 16.1, 0.08, 12.1, 0, -0.01, 0, M.floor);
addBox(room, 16.4, 3.8, 0.25, 0, 1.9, -6.05, M.wall);
addBox(room, 0.25, 3.8, 12.2, -8.05, 1.9, 0, M.wall);
addBox(room, 16.15, 0.16, 0.14, 0, 0.08, -5.87, M.wallTrim);
addBox(room, 0.14, 0.16, 11.9, -7.87, 0.08, 0, M.wallTrim);
// Floor plank seams.
const seamMaterial = new THREE.MeshBasicMaterial({
color: 0x916746,
transparent: true,
opacity: 0.2
});
for (let x = -7; x <= 7; x++) {
addBox(room, 0.018, 0.009, 11.8, x, 0.036, 0, seamMaterial, false, false);
}
for (let z = -5; z <= 5; z++) {
addBox(room, 15.8, 0.009, 0.018, 0, 0.037, z, seamMaterial, false, false);
}
// Cross-shaped circulation path.
addBox(room, 2.05, 0.035, 11.85, 0, 0.05, 0, M.path, false, true);
addBox(room, 15.85, 0.038, 2.05, 0, 0.055, 0, M.path, false, true);
addBox(room, 0.05, 0.015, 11.65, -1.0, 0.077, 0, M.pathEdge, false, false);
addBox(room, 0.05, 0.015, 11.65, 1.0, 0.077, 0, M.pathEdge, false, false);
addBox(room, 15.65, 0.015, 0.05, 0, 0.079, -1.0, M.pathEdge, false, false);
addBox(room, 15.65, 0.015, 0.05, 0, 0.079, 1.0, M.pathEdge, false, false);
// Back-wall window.
addBox(room, 3.45, 2.15, 0.08, 4.25, 2.65, -5.87, M.window, false, false);
addBox(room, 3.72, 0.12, 0.16, 4.25, 3.76, -5.79, M.wallTrim);
addBox(room, 3.72, 0.12, 0.16, 4.25, 1.54, -5.79, M.wallTrim);
addBox(room, 0.12, 2.25, 0.16, 2.49, 2.65, -5.79, M.wallTrim);
addBox(room, 0.12, 2.25, 0.16, 6.01, 2.65, -5.79, M.wallTrim);
addBox(room, 0.09, 2.15, 0.17, 4.25, 2.65, -5.77, M.wallTrim);
// Pixel-like buildings beyond the window.
addBox(room, 0.68, 0.95, 0.04, 3.05, 2.25, -5.81, M.paleBlue, false, false);
addBox(room, 0.92, 0.55, 0.04, 5.25, 2.05, -5.81, M.paleBlue, false, false);
addBox(room, 0.45, 1.35, 0.04, 5.82, 2.45, -5.81, M.blue, false, false);
// Reading wall art.
addBox(room, 0.1, 1.75, 2.25, -7.84, 2.5, 3.45, M.darkWood);
addBox(room, 0.11, 1.55, 2.05, -7.76, 2.5, 3.45, M.cream);
addBox(room, 0.12, 0.48, 0.62, -7.68, 2.74, 3.13, M.coral);
addBox(room, 0.12, 0.32, 0.42, -7.68, 2.35, 3.76, M.sage);
addBox(room, 0.12, 0.28, 0.34, -7.67, 2.16, 3.28, M.gold);
// ------------------------------------------------------------------
// Workbench zone
// ------------------------------------------------------------------
addBox(room, 5.75, 0.035, 3.15, -4.8, 0.055, -4.25, M.paleWood, false, true);
const workbench = makeGroup(room, -4.8, 0, -4.65);
addBox(workbench, 5.0, 0.25, 1.65, 0, 1.52, 0, M.wood);
addBox(workbench, 4.65, 0.13, 1.25, 0, 0.48, 0, M.darkWood);
const benchLegPositions = [
[-2.2, -0.61],
[2.2, -0.61],
[-2.2, 0.61],
[2.2, 0.61]
];
benchLegPositions.forEach(([x, z]) => {
addBox(workbench, 0.23, 1.42, 0.23, x, 0.73, z, M.darkWood);
});
// Drawer cabinet.
addBox(workbench, 1.25, 1.13, 1.3, 1.58, 0.74, -0.02, M.lightWood);
addBox(workbench, 1.08, 0.28, 0.08, 1.58, 1.03, 0.67, M.wood);
addBox(workbench, 1.08, 0.28, 0.08, 1.58, 0.68, 0.67, M.wood);
addBox(workbench, 1.08, 0.28, 0.08, 1.58, 0.33, 0.67, M.wood);
addBox(workbench, 0.24, 0.06, 0.08, 1.58, 1.03, 0.73, M.charcoal);
addBox(workbench, 0.24, 0.06, 0.08, 1.58, 0.68, 0.73, M.charcoal);
addBox(workbench, 0.24, 0.06, 0.08, 1.58, 0.33, 0.73, M.charcoal);
// Pegboard and tools.
addBox(room, 5.2, 1.9, 0.12, -4.8, 2.65, -5.79, M.lightWood);
addBox(room, 5.0, 1.7, 0.05, -4.8, 2.65, -5.71, M.paleWood);
const holeMat = new THREE.MeshBasicMaterial({ color: 0x957047 });
for (let row = 0; row < 5; row++) {
for (let col = 0; col < 12; col++) {
addBox(
room,
0.045,
0.045,
0.025,
-7.08 + col * 0.415,
2.05 + row * 0.3,
-5.675,
holeMat,
false,
false
);
}
}
// Hammer.
addBox(room, 0.12, 0.72, 0.12, -6.65, 2.62, -5.58, M.wood);
addBox(room, 0.54, 0.2, 0.18, -6.65, 3.0, -5.58, M.charcoal);
// Square and ruler.
addBox(room, 0.18, 0.85, 0.12, -5.82, 2.58, -5.58, M.gold);
addBox(room, 0.48, 0.18, 0.12, -5.66, 2.98, -5.58, M.gold);
addBox(room, 0.1, 0.9, 0.1, -5.15, 2.65, -5.58, M.charcoal);
// Saw.
addBox(room, 0.82, 0.13, 0.12, -4.25, 2.42, -5.56, M.blue);
addBox(room, 0.23, 0.32, 0.13, -3.78, 2.55, -5.56, M.darkWood);
// Shelf above the bench.
addBox(room, 2.15, 0.12, 0.5, -3.68, 3.35, -5.54, M.wood);
addBox(room, 0.35, 0.45, 0.35, -4.35, 3.61, -5.52, M.terra);
addBox(room, 0.28, 0.35, 0.3, -3.85, 3.57, -5.51, M.blue);
addBox(room, 0.48, 0.2, 0.32, -3.1, 3.5, -5.52, M.paleWood);
// Workbench objects.
addBox(workbench, 0.65, 0.18, 0.5, -1.82, 1.73, 0.25, M.charcoal);
addBox(workbench, 0.2, 0.33, 0.54, -2.02, 1.87, 0.25, M.charcoal);
addBox(workbench, 0.2, 0.33, 0.54, -1.58, 1.87, 0.25, M.charcoal);
addBox(workbench, 1.05, 0.09, 0.68, 0.25, 1.68, 0.12, M.paleWood);
addBox(workbench, 0.7, 0.11, 0.42, 0.28, 1.77, 0.13, M.lightWood);
addBox(workbench, 0.18, 0.18, 0.18, -0.1, 1.8, -0.12, M.coral);
addBox(workbench, 0.22, 0.22, 0.22, 0.67, 1.82, 0.05, M.sage);
// Desk lamp.
addBox(workbench, 0.52, 0.08, 0.4, -1.3, 1.69, -0.43, M.charcoal);
addBox(workbench, 0.1, 0.72, 0.1, -1.3, 2.05, -0.43, M.charcoal);
addBox(workbench, 0.55, 0.1, 0.1, -1.08, 2.39, -0.43, M.charcoal);
addBox(workbench, 0.45, 0.24, 0.38, -0.86, 2.31, -0.39, M.gold);
addBox(workbench, 0.33, 0.06, 0.25, -0.86, 2.17, -0.39, M.lamp, false, false);
makeCrate(workbench, -1.5, 0.56, 0, 0.85, 0.7);
makeCrate(workbench, -0.45, 0.56, 0, 0.85, 0.7);
// ------------------------------------------------------------------
// Reading corner
// ------------------------------------------------------------------
addBox(room, 4.7, 0.045, 3.9, -4.85, 0.065, 2.9, M.blush, false, true);
addBox(room, 4.35, 0.015, 3.55, -4.85, 0.092, 2.9, M.cream, false, true);
const sofa = makeGroup(room, -5.35, 0, 3.4, Math.PI / 2);
addBox(sofa, 2.8, 0.42, 1.28, 0, 0.45, 0, M.coral);
addBox(sofa, 2.8, 1.25, 0.3, 0, 1.12, -0.53, M.coral);
addBox(sofa, 0.34, 0.78, 1.32, -1.23, 0.78, 0, M.coral);
addBox(sofa, 0.34, 0.78, 1.32, 1.23, 0.78, 0, M.coral);
addBox(sofa, 1.13, 0.23, 0.94, -0.59, 0.78, 0.11, M.blush);
addBox(sofa, 1.13, 0.23, 0.94, 0.59, 0.78, 0.11, M.blush);
const pillowA = addBox(sofa, 0.56, 0.55, 0.18, -0.66, 1.13, 0.31, M.gold);
pillowA.rotation.z = 0.12;
const pillowB = addBox(sofa, 0.55, 0.52, 0.18, 0.64, 1.12, 0.31, M.sage);
pillowB.rotation.z = -0.12;
[
[-1.1, -0.45],
[1.1, -0.45],
[-1.1, 0.45],
[1.1, 0.45]
].forEach(([x, z]) => {
addBox(sofa, 0.18, 0.38, 0.18, x, 0.19, z, M.darkWood);
});
// Side table and book.
addBox(room, 0.78, 0.14, 0.78, -3.15, 0.92, 3.85, M.wood);
addBox(room, 0.16, 0.82, 0.16, -3.15, 0.43, 3.85, M.darkWood);
addBox(room, 0.52, 0.1, 0.38, -3.15, 1.04, 3.85, M.bookBlue);
addBox(room, 0.45, 0.08, 0.34, -3.11, 1.13, 3.85, M.bookRed);
// Floor lamp.
addBox(room, 0.58, 0.1, 0.58, -2.65, 0.08, 5.05, M.charcoal);
addBox(room, 0.1, 2.55, 0.1, -2.65, 1.4, 5.05, M.charcoal);
addBox(room, 0.7, 0.16, 0.7, -2.65, 2.67, 5.05, M.gold);
addBox(room, 0.5, 0.08, 0.5, -2.65, 2.56, 5.05, M.lamp, false, false);
// Bookcase against the left wall.
const bookcase = makeGroup(room, -7.55, 0, 1.25, Math.PI / 2);
addBox(bookcase, 2.6, 2.85, 0.12, 0, 1.43, -0.27, M.darkWood);
addBox(bookcase, 0.15, 2.85, 0.62, -1.3, 1.43, 0, M.wood);
addBox(bookcase, 0.15, 2.85, 0.62, 1.3, 1.43, 0, M.wood);
[0.3, 0.92, 1.54, 2.16, 2.82].forEach((y) => {
addBox(bookcase, 2.62, 0.12, 0.64, 0, y, 0, M.lightWood);
});
const bookMaterials = [M.bookRed, M.bookBlue, M.bookYellow, M.sage, M.cream];
for (let shelf = 0; shelf < 4; shelf++) {
for (let bookIndex = 0; bookIndex < 7; bookIndex++) {
const height = 0.32 + ((bookIndex + shelf) % 3) * 0.08;
const width = 0.12 + ((bookIndex + shelf) % 2) * 0.035;
addBox(
bookcase,
width,
height,
0.35,
-1.03 + bookIndex * 0.32,
0.38 + shelf * 0.62 + height / 2,
0.05,
bookMaterials[(bookIndex + shelf) % bookMaterials.length]
);
}
}
makePlant(room, -7.0, 5.0, 1.05);
makePlant(room, -2.25, 0.35, 0.7);
// ------------------------------------------------------------------
// Dining table
// ------------------------------------------------------------------
addBox(room, 5.0, 0.04, 3.7, 4.3, 0.065, -3.65, M.gold, false, true);
addBox(room, 4.65, 0.015, 3.35, 4.3, 0.091, -3.65, M.paleWood, false, true);
const table = makeGroup(room, 4.3, 0, -3.65);
addBox(table, 3.2, 0.24, 1.8, 0, 1.5, 0, M.wood);
addBox(table, 2.85, 0.12, 1.45, 0, 1.28, 0, M.darkWood);
[
[-1.28, -0.62],
[1.28, -0.62],
[-1.28, 0.62],
[1.28, 0.62]
].forEach(([x, z]) => {
addBox(table, 0.22, 1.38, 0.22, x, 0.72, z, M.darkWood);
});
function makeChair(parent, x, z, rotationY) {
const chair = makeGroup(parent, x, 0, z, rotationY);
addBox(chair, 0.82, 0.16, 0.8, 0, 0.88, 0, M.lightWood);
addBox(chair, 0.82, 0.85, 0.16, 0, 1.28, -0.34, M.lightWood);
addBox(chair, 0.72, 0.12, 0.72, 0, 0.77, 0, M.coral);
[
[-0.3, -0.27],
[0.3, -0.27],
[-0.3, 0.27],
[0.3, 0.27]
].forEach(([lx, lz]) => {
addBox(chair, 0.12, 0.76, 0.12, lx, 0.39, lz, M.darkWood);
});
return chair;
}
makeChair(room, 2.25, -3.65, Math.PI / 2);
makeChair(room, 6.35, -3.65, -Math.PI / 2);
makeChair(room, 4.3, -5.15, 0);
makeChair(room, 4.3, -2.15, Math.PI);
// Table settings, all voxel-shaped.
[
[-0.85, -0.48],
[0.85, -0.48],
[-0.85, 0.48],
[0.85, 0.48]
].forEach(([x, z], index) => {
addBox(table, 0.62, 0.035, 0.48, x, 1.635, z, M.white);
addBox(table, 0.42, 0.055, 0.32, x, 1.68, z, index % 2 ? M.sage : M.cream);
addBox(table, 0.16, 0.28, 0.16, x + 0.46, 1.78, z, M.blue);
});
// Centerpiece.
addBox(table, 0.55, 0.08, 0.55, 0, 1.68, 0, M.terra);
addBox(table, 0.32, 0.32, 0.32, 0, 1.87, 0, M.green);
addBox(table, 0.25, 0.25, 0.25, 0.16, 1.82, 0.08, M.gold);
makePlant(room, 7.1, -5.05, 0.85);
// Sideboard under the window.
addBox(room, 2.4, 0.9, 0.72, 4.25, 0.48, -5.25, M.wood);
addBox(room, 2.5, 0.12, 0.82, 4.25, 0.98, -5.25, M.lightWood);
addBox(room, 0.74, 0.58, 0.07, 3.66, 0.49, -4.85, M.paleWood);
addBox(room, 0.74, 0.58, 0.07, 4.84, 0.49, -4.85, M.paleWood);
addBox(room, 0.25, 0.06, 0.08, 3.66, 0.49, -4.79, M.charcoal);
addBox(room, 0.25, 0.06, 0.08, 4.84, 0.49, -4.79, M.charcoal);
// ------------------------------------------------------------------
// Exercise zone
// ------------------------------------------------------------------
addBox(room, 4.15, 0.085, 2.65, 4.45, 0.1, 2.7, M.sage, false, true);
addBox(room, 3.85, 0.018, 2.35, 4.45, 0.151, 2.7, M.darkSage, false, true);
addBox(room, 3.55, 0.01, 2.08, 4.45, 0.164, 2.7, M.sage, false, true);
// Yoga blocks.
const blockA = addBox(room, 0.48, 0.3, 0.48, 3.25, 0.32, 2.05, M.coral);
blockA.rotation.y = 0.16;
const blockB = addBox(room, 0.48, 0.3, 0.48, 3.55, 0.32, 2.5, M.gold);
blockB.rotation.y = -0.13;
// Rolled towel represented by stacked rectangular forms.
addBox(room, 0.65, 0.18, 0.48, 5.65, 0.28, 3.35, M.cream);
addBox(room, 0.55, 0.16, 0.43, 5.65, 0.44, 3.35, M.blue);
addBox(room, 0.08, 0.17, 0.44, 5.35, 0.45, 3.35, M.cream);
// Water bottle.
addBox(room, 0.28, 0.52, 0.28, 6.25, 0.42, 2.0, M.paleBlue);
addBox(room, 0.22, 0.16, 0.22, 6.25, 0.75, 2.0, M.charcoal);
addBox(room, 0.31, 0.1, 0.31, 6.25, 0.16, 2.0, M.cream);
// Low dumbbell shelf.
addBox(room, 1.55, 0.12, 0.55, 6.55, 0.3, 3.8, M.darkWood);
addBox(room, 0.13, 0.7, 0.13, 5.9, 0.35, 3.8, M.darkWood);
addBox(room, 0.13, 0.7, 0.13, 7.2, 0.35, 3.8, M.darkWood);
[-0.4, 0, 0.4].forEach((offset, index) => {
const x = 6.55 + offset;
const color = [M.charcoal, M.gold, M.charcoal][index];
addBox(room, 0.55, 0.12, 0.12, x, 0.49, 3.8, M.charcoal);
addBox(room, 0.22, 0.3, 0.3, x - 0.29, 0.49, 3.8, color);
addBox(room, 0.22, 0.3, 0.3, x + 0.29, 0.49, 3.8, color);
});
// Small exercise bench.
addBox(room, 2.25, 0.18, 0.72, 4.35, 0.82, 4.55, M.wood);
addBox(room, 1.9, 0.35, 0.56, 4.35, 0.58, 4.55, M.charcoal);
[-0.85, 0.85].forEach((x) => {
addBox(room, 0.16, 0.72, 0.58, 4.35 + x, 0.4, 4.55, M.darkWood);
});
makePlant(room, 7.1, 5.05, 0.95);
// ------------------------------------------------------------------
// Floating zone labels
// ------------------------------------------------------------------
const labels = [];
function roundedRect(ctx, x, y, width, height, radius) {
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width - radius, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
ctx.lineTo(x + width, y + height - radius);
ctx.quadraticCurveTo(
x + width,
y + height,
x + width - radius,
y + height
);
ctx.lineTo(x + radius, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
ctx.lineTo(x, y + radius);
ctx.quadraticCurveTo(x, y, x + radius, y);
ctx.closePath();
}
function makeLabel(text, accent, x, y, z, width = 2.5) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
roundedRect(ctx, 8, 12, 496, 104, 22);
ctx.fillStyle = "rgba(255, 249, 238, 0.96)";
ctx.fill();
ctx.fillStyle = accent;
roundedRect(ctx, 22, 29, 16, 70, 7);
ctx.fill();
ctx.fillStyle = "#3f382f";
ctx.font = "800 48px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text.toUpperCase(), 270, 65);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.position.set(x, y, z);
sprite.scale.set(width, width * 0.25, 1);
sprite.renderOrder = 20;
scene.add(sprite);
labels.push(sprite);
return sprite;
}
makeLabel("Workbench", "#b67747", -4.8, 3.55, -4.55, 2.55);
makeLabel("Reading", "#bd756b", -4.75, 3.0, 3.05, 2.2);
makeLabel("Dining", "#d0aa61", 4.3, 3.55, -3.6, 2.2);
makeLabel("Exercise", "#78966f", 4.45, 1.85, 2.7, 2.2);
// ------------------------------------------------------------------
// Custom orbit camera controls
// ------------------------------------------------------------------
const cameraState = {
yaw: 0.73,
pitch: 0.67,
distance: 23.5,
target: new THREE.Vector3(0, 0.55, 0)
};
function updateCamera() {
const horizontal = Math.cos(cameraState.pitch) * cameraState.distance;
const vertical = Math.sin(cameraState.pitch) * cameraState.distance;
camera.position.set(
cameraState.target.x + Math.sin(cameraState.yaw) * horizontal,
cameraState.target.y + vertical,
cameraState.target.z + Math.cos(cameraState.yaw) * horizontal
);
camera.lookAt(cameraState.target);
}
updateCamera();
const canvas = renderer.domElement;
let dragging = false;
let pointerMoved = false;
let lastX = 0;
let lastY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
pointerMoved = false;
lastX = event.clientX;
lastY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
if (Math.abs(dx) + Math.abs(dy) > 2) {
pointerMoved = true;
}
cameraState.yaw -= dx * 0.006;
cameraState.pitch = THREE.MathUtils.clamp(
cameraState.pitch + dy * 0.004,
0.28,
1.46
);
lastX = event.clientX;
lastY = event.clientY;
updateCamera();
});
function endPointer(event) {
dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.distance = THREE.MathUtils.clamp(
cameraState.distance * Math.exp(event.deltaY * 0.001),
11,
35
);
updateCamera();
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") {
cameraState.yaw += 0.1;
} else if (event.key === "ArrowRight") {
cameraState.yaw -= 0.1;
} else if (event.key === "ArrowUp") {
cameraState.pitch = THREE.MathUtils.clamp(
cameraState.pitch + 0.07,
0.28,
1.46
);
} else if (event.key === "ArrowDown") {
cameraState.pitch = THREE.MathUtils.clamp(
cameraState.pitch - 0.07,
0.28,
1.46
);
} else if (event.key === "+" || event.key === "=") {
cameraState.distance = Math.max(11, cameraState.distance - 1);
} else if (event.key === "-" || event.key === "_") {
cameraState.distance = Math.min(35, cameraState.distance + 1);
} else if (event.key.toLowerCase() === "r") {
resetView();
} else {
return;
}
updateCamera();
});
function resetView() {
cameraState.yaw = 0.73;
cameraState.pitch = 0.67;
cameraState.distance = 23.5;
cameraState.target.set(0, 0.55, 0);
updateCamera();
}
document.querySelector("#reset-view").addEventListener("click", resetView);
document.querySelector("#top-view").addEventListener("click", () => {
cameraState.yaw = 0.01;
cameraState.pitch = 1.46;
cameraState.distance = 22;
cameraState.target.set(0, 0.35, 0);
updateCamera();
});
const labelsButton = document.querySelector("#toggle-labels");
let labelsVisible = true;
labelsButton.addEventListener("click", () => {
labelsVisible = !labelsVisible;
labels.forEach((label) => {
label.visible = labelsVisible;
});
labelsButton.classList.toggle("active", labelsVisible);
});
// ------------------------------------------------------------------
// Resize and render loop
// ------------------------------------------------------------------
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
renderer.setAnimationLoop(() => {
renderer.render(scene, camera);
});
requestAnimationFrame(() => {
loading.classList.add("hidden");
});
</script>
</body>
</html>
```