Prompt specification
Build or customize the Three.js 3D scene "Shared household morning scene" 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 household morning scene
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/shared-household-morning-scene-x3879
Scene Description Prompt:
I'd like to see this as a voxel Three.js scene: shared household morning scene. Compose kitchen, entryway, and study corner in one small cutaway home; family members complete different preparations and meet at the door through coordinated paths. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (shared-household-morning-scene-x3879):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>One Home, Three Ways to the Door</title>
<style>
:root {
--ink: #253334;
--muted: #62706e;
--paper: rgba(255, 252, 244, 0.88);
--line: rgba(48, 65, 64, 0.14);
--mia: #ef8b4a;
--noah: #557bc5;
--zoe: #b75e91;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8e5da;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
#stage {
position: fixed;
inset: 0;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#stage canvas:active { cursor: grabbing; }
.ui {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 5;
}
.panel {
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.76);
box-shadow: 0 16px 50px rgba(45, 58, 54, 0.13);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
}
.brand {
position: absolute;
top: 24px;
left: 26px;
width: min(390px, calc(100vw - 52px));
}
.eyebrow {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 7px 10px;
border: 1px solid rgba(37, 51, 52, 0.12);
border-radius: 999px;
background: rgba(255, 252, 244, 0.72);
color: #53615f;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow .live-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: #e77845;
box-shadow: 0 0 0 4px rgba(231, 120, 69, 0.13);
}
h1 {
margin: 13px 0 8px;
font-size: clamp(29px, 3.6vw, 52px);
line-height: 0.98;
letter-spacing: -0.055em;
font-weight: 820;
}
h1 span {
display: block;
color: #72807c;
font-weight: 560;
}
.brand p {
max-width: 335px;
margin: 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.view-controls {
position: absolute;
top: 24px;
right: 24px;
display: flex;
align-items: center;
gap: 7px;
padding: 8px;
border-radius: 14px;
pointer-events: auto;
}
.view-controls button,
.transport button {
border: 0;
color: #42514f;
background: transparent;
cursor: pointer;
transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}
.view-controls button {
padding: 8px 10px;
border-radius: 9px;
font-size: 11px;
font-weight: 750;
}
.view-controls button:hover,
.transport button:hover {
color: #182524;
background: rgba(55, 78, 74, 0.09);
}
.view-controls button.active {
color: #fff;
background: #334846;
}
.divider {
width: 1px;
height: 24px;
background: var(--line);
}
.roster {
position: absolute;
top: 104px;
right: 24px;
width: 235px;
padding: 14px;
border-radius: 17px;
pointer-events: auto;
}
.roster-title {
margin: 0 0 11px;
color: #6a7673;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.person-row {
display: grid;
grid-template-columns: 10px 1fr;
gap: 9px;
padding: 9px 0;
border-top: 1px solid var(--line);
}
.person-row:first-of-type { border-top: 0; }
.person-dot {
width: 9px;
height: 9px;
margin-top: 4px;
border-radius: 3px;
}
.person-name {
font-size: 12px;
font-weight: 800;
}
.person-status {
margin-top: 2px;
color: var(--muted);
font-size: 10.5px;
line-height: 1.35;
}
.timeline {
position: absolute;
left: 24px;
bottom: 24px;
width: min(760px, calc(100vw - 48px));
padding: 13px 15px 12px;
border-radius: 18px;
pointer-events: auto;
}
.timeline-top {
display: flex;
align-items: center;
gap: 13px;
}
.transport {
display: flex;
align-items: center;
gap: 5px;
flex: 0 0 auto;
}
.transport button {
display: grid;
place-items: center;
width: 34px;
height: 34px;
border-radius: 10px;
}
.transport #play {
width: 38px;
color: #fff;
background: #334846;
}
.transport #play:hover { background: #263c3a; }
.scrubber {
position: relative;
flex: 1;
min-width: 100px;
}
#progress {
width: 100%;
height: 5px;
margin: 0;
border-radius: 10px;
appearance: none;
-webkit-appearance: none;
outline: none;
background: linear-gradient(
to right,
#e7894e 0%,
#e7894e var(--progress, 0%),
rgba(57, 75, 72, 0.13) var(--progress, 0%),
rgba(57, 75, 72, 0.13) 100%
);
cursor: pointer;
}
#progress::-webkit-slider-thumb {
width: 14px;
height: 14px;
border: 3px solid #fff;
border-radius: 50%;
appearance: none;
-webkit-appearance: none;
background: #e7894e;
box-shadow: 0 2px 7px rgba(40, 52, 50, 0.25);
}
#progress::-moz-range-thumb {
width: 10px;
height: 10px;
border: 3px solid #fff;
border-radius: 50%;
background: #e7894e;
box-shadow: 0 2px 7px rgba(40, 52, 50, 0.25);
}
.time-label {
width: 84px;
color: #65726f;
font-variant-numeric: tabular-nums;
font-size: 10px;
font-weight: 750;
text-align: right;
}
.phase-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 10px;
padding-left: 47px;
}
#phase {
font-size: 11px;
font-weight: 780;
}
#hint {
color: #7b8683;
font-size: 10px;
text-align: right;
}
.tip {
position: absolute;
left: 50%;
bottom: 128px;
max-width: 320px;
padding: 9px 12px;
border-radius: 11px;
color: #f9f7ee;
background: rgba(39, 54, 52, 0.9);
font-size: 11px;
font-weight: 700;
opacity: 0;
transform: translate(-50%, 8px);
transition: opacity 160ms ease, transform 160ms ease;
}
.tip.visible {
opacity: 1;
transform: translate(-50%, 0);
}
@media (max-width: 760px) {
.brand p, .roster, #hint { display: none; }
.brand { top: 18px; left: 18px; }
.brand h1 { font-size: 30px; }
.view-controls { top: 18px; right: 18px; }
.view-controls .label { display: none; }
.timeline { left: 14px; bottom: 14px; width: calc(100vw - 28px); }
.phase-row { padding-left: 0; }
.time-label { width: 68px; }
}
</style>
</head>
<body>
<div id="stage"></div>
<div class="ui">
<header class="brand">
<div class="eyebrow">
<span class="live-dot"></span>
Shared morning · 08:10
</div>
<h1>
One home.
<span>Three ways to the door.</span>
</h1>
<p>
A tiny voxel household in motion: breakfast in the kitchen, a school bag
in the study, and shoes by the entrance—then three coordinated routes
converge at the front door.
</p>
</header>
<nav class="view-controls panel" aria-label="Camera views">
<button class="active" data-view="iso">Isometric</button>
<button data-view="top">Plan</button>
<button data-view="door">Door</button>
<span class="divider"></span>
<button id="paths-toggle" class="active" aria-pressed="true">
<span class="label">Routes </span>●
</button>
</nav>
<aside class="roster panel">
<h2 class="roster-title">Household route board</h2>
<div class="person-row">
<span class="person-dot" style="background:var(--mia)"></span>
<div>
<div class="person-name">Mia</div>
<div class="person-status" id="status-mia">Setting out breakfast</div>
</div>
</div>
<div class="person-row">
<span class="person-dot" style="background:var(--noah)"></span>
<div>
<div class="person-name">Noah</div>
<div class="person-status" id="status-noah">Packing a school bag</div>
</div>
</div>
<div class="person-row">
<span class="person-dot" style="background:var(--zoe)"></span>
<div>
<div class="person-name">Zoe</div>
<div class="person-status" id="status-zoe">Finding her shoes</div>
</div>
</div>
</aside>
<section class="timeline panel" aria-label="Animation timeline">
<div class="timeline-top">
<div class="transport">
<button id="play" aria-label="Pause animation">Ⅱ</button>
<button id="restart" aria-label="Restart animation">↺</button>
</div>
<div class="scrubber">
<input id="progress" type="range" min="0" max="18" step="0.01" value="0"
aria-label="Morning timeline">
</div>
<div class="time-label"><span id="elapsed">0:00</span> / 0:18</div>
</div>
<div class="phase-row">
<div id="phase">Three rooms. One shared plan.</div>
<div id="hint">Drag to orbit · scroll to zoom · select a family member</div>
</div>
</section>
<div class="tip" id="tip"></div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, camera, and lighting
// -------------------------------------------------------------------------
const stage = document.getElementById("stage");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8e5da);
scene.fog = new THREE.Fog(0xe8e5da, 38, 68);
const renderer = new THREE.WebGLRenderer({ antialias: true });
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.12;
stage.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-12, 12, 8, -8, 0.1, 100);
const cameraState = {
theta: 0.69,
phi: 0.79,
radius: 30,
zoom: 1,
target: new THREE.Vector3(0, 0.75, -0.4)
};
const hemi = new THREE.HemisphereLight(0xfff5db, 0x70817c, 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffe0ad, 3.6);
sun.position.set(-9, 15, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -15;
sun.shadow.camera.right = 15;
sun.shadow.camera.top = 15;
sun.shadow.camera.bottom = -15;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 40;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const windowGlow = new THREE.PointLight(0xffcf83, 30, 12, 2);
windowGlow.position.set(0.3, 2.9, -4.6);
scene.add(windowGlow);
const fill = new THREE.DirectionalLight(0xc7e3ef, 0.7);
fill.position.set(10, 8, -5);
scene.add(fill);
// -------------------------------------------------------------------------
// Voxel construction helpers
// -------------------------------------------------------------------------
const materialCache = new Map();
const geometryCache = new Map();
function material(color, extra = {}) {
if (!extra || Object.keys(extra).length === 0) {
const key = String(color);
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0.02
})
);
}
return materialCache.get(key);
}
return new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0.02,
...extra
});
}
function geometry(w, h, d) {
const key = `${w}:${h}:${d}`;
if (!geometryCache.has(key)) {
geometryCache.set(key, new THREE.BoxGeometry(w, h, d));
}
return geometryCache.get(key);
}
function box(w, h, d, mat, x = 0, y = 0, z = 0, parent = scene) {
const resolved = mat && mat.isMaterial ? mat : material(mat);
const mesh = new THREE.Mesh(geometry(w, h, d), resolved);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function labelSprite(text, color = "#344441", width = 2.25) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 112;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "rgba(255,252,244,0.94)";
ctx.beginPath();
const r = 22;
ctx.moveTo(r, 8);
ctx.lineTo(504 - r, 8);
ctx.quadraticCurveTo(504, 8, 504, 30);
ctx.lineTo(504, 82);
ctx.quadraticCurveTo(504, 104, 482, 104);
ctx.lineTo(30, 104);
ctx.quadraticCurveTo(8, 104, 8, 82);
ctx.lineTo(8, 30);
ctx.quadraticCurveTo(8, 8, 30, 8);
ctx.closePath();
ctx.fill();
ctx.fillStyle = color;
ctx.font = "800 34px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 256, 57);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const spriteMaterial = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(spriteMaterial);
sprite.scale.set(width, width * 112 / 512, 1);
sprite.renderOrder = 20;
return sprite;
}
function addPlant(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.08, z);
group.scale.setScalar(scale);
scene.add(group);
box(0.62, 0.55, 0.62, 0xc97855, 0, 0.28, 0, group);
box(0.72, 0.12, 0.72, 0xe19a72, 0, 0.59, 0, group);
box(0.1, 1.25, 0.1, 0x53745a, 0, 1.22, 0, group);
box(0.45, 0.24, 0.27, 0x6b9467, -0.24, 1.33, 0, group);
box(0.45, 0.24, 0.27, 0x7fa275, 0.25, 1.68, 0, group);
box(0.3, 0.28, 0.31, 0x56815f, -0.16, 1.97, 0.02, group);
return group;
}
// -------------------------------------------------------------------------
// Cutaway house shell and tiled floor
// -------------------------------------------------------------------------
box(80, 0.12, 80, 0xe8e5da, 0, -0.48, 0);
box(16.5, 0.36, 12.5, 0xb7a58e, 0, -0.19, 0);
const tileGeo = geometry(0.485, 0.08, 0.485);
const tileMaterial = material(0xffffff, { vertexColors: true });
const floor = new THREE.InstancedMesh(tileGeo, tileMaterial, 32 * 24);
floor.receiveShadow = true;
floor.castShadow = false;
const dummy = new THREE.Object3D();
const tileColor = new THREE.Color();
let tileIndex = 0;
for (let ix = 0; ix < 32; ix++) {
for (let iz = 0; iz < 24; iz++) {
const x = (ix - 15.5) * 0.5;
const z = (iz - 11.5) * 0.5;
dummy.position.set(x, 0.035, z);
dummy.updateMatrix();
floor.setMatrixAt(tileIndex, dummy.matrix);
if (x < -1.8 && z < 1.2) {
tileColor.set(0xd6d5bc);
} else if (x > 1.5 && z < 1.4) {
tileColor.set(0xc9d1c9);
} else if (x > 4.0 && z > 0.1) {
tileColor.set(0xe1c5aa);
} else {
tileColor.set((ix + iz) % 2 ? 0xd9b98f : 0xe2c69f);
}
floor.setColorAt(tileIndex, tileColor);
tileIndex++;
}
}
floor.instanceMatrix.needsUpdate = true;
floor.instanceColor.needsUpdate = true;
scene.add(floor);
const backWallColors = [0xeee4ce, 0xeadfc7, 0xf0e7d2, 0xe8dfca];
for (let row = 0; row < 8; row++) {
for (let col = 0; col < 16; col++) {
box(
0.96, 0.46, 0.28,
backWallColors[(row + col) % backWallColors.length],
-7.5 + col, 0.32 + row * 0.5, -5.98
);
}
}
const leftWallColors = [0xd8dfd2, 0xd1dacb, 0xdde2d5, 0xcdd8ca];
for (let row = 0; row < 8; row++) {
for (let col = 0; col < 12; col++) {
box(
0.28, 0.46, 0.96,
leftWallColors[(row + col) % leftWallColors.length],
-7.98, 0.32 + row * 0.5, -5.5 + col
);
}
}
box(16, 0.16, 0.12, 0xf6edda, 0, 0.17, -5.79);
box(0.12, 0.16, 12, 0xf6edda, -7.79, 0.17, 0);
// Window with a warm, block-built view.
box(2.45, 1.55, 0.09, 0x739fac, 0.15, 2.67, -5.78);
box(2.68, 0.13, 0.16, 0xf5ead3, 0.15, 3.49, -5.68);
box(2.68, 0.13, 0.16, 0xf5ead3, 0.15, 1.85, -5.68);
box(0.13, 1.75, 0.16, 0xf5ead3, -1.18, 2.67, -5.68);
box(0.13, 1.75, 0.16, 0xf5ead3, 1.48, 2.67, -5.68);
box(0.11, 1.55, 0.16, 0xf5ead3, 0.15, 2.67, -5.65);
box(2.45, 0.1, 0.16, 0xf5ead3, 0.15, 2.67, -5.65);
box(0.32, 1.95, 0.25, 0xe3b18b, -1.4, 2.62, -5.58);
box(0.32, 1.95, 0.25, 0xe3b18b, 1.7, 2.62, -5.58);
// Voxel clock set to approximately 8:10.
const clock = new THREE.Group();
clock.position.set(2.45, 2.82, -5.72);
scene.add(clock);
box(0.9, 0.9, 0.12, 0x53625f, 0, 0, 0, clock);
box(0.72, 0.72, 0.13, 0xf7f1dc, 0, 0, 0.01, clock);
const minuteHand = box(0.055, 0.28, 0.035, 0x354744, 0, 0.12, 0.1, clock);
minuteHand.rotation.z = -Math.PI / 3;
minuteHand.position.set(0.12, 0.07, 0.1);
const hourHand = box(0.065, 0.2, 0.035, 0x354744, 0, 0, 0.11, clock);
hourHand.rotation.z = -THREE.MathUtils.degToRad(245);
hourHand.position.set(-0.09, -0.045, 0.11);
box(0.09, 0.09, 0.04, 0xd98955, 0, 0, 0.13, clock);
// Zone rugs.
box(5.1, 0.025, 3.1, 0xb5c6b2, -4.4, 0.09, -1.75);
box(4.1, 0.025, 3.0, 0xb9c8d2, 4.0, 0.09, -2.45);
box(2.65, 0.025, 2.65, 0xd9a889, 5.65, 0.09, 2.75);
// -------------------------------------------------------------------------
// Kitchen
// -------------------------------------------------------------------------
// Fridge.
box(1.38, 2.85, 1.42, 0xdde5da, -6.62, 1.5, -4.84);
box(1.23, 1.13, 0.08, 0xe8eee4, -6.62, 2.05, -4.08);
box(1.23, 1.43, 0.08, 0xe8eee4, -6.62, 1.08, -4.08);
box(0.08, 0.62, 0.1, 0x64716e, -6.22, 2.18, -3.98);
box(0.08, 0.42, 0.1, 0x64716e, -6.22, 1.31, -3.98);
box(0.65, 0.06, 0.5, 0xf4efe0, -6.9, 0.96, -3.98);
// Stove and cooker.
box(1.65, 1.0, 1.38, 0xd7ddd3, -4.35, 0.58, -4.82);
box(1.82, 0.12, 1.48, 0x4b5553, -4.35, 1.13, -4.78);
for (const dx of [-0.44, 0.44]) {
for (const dz of [-0.34, 0.34]) {
box(0.38, 0.035, 0.38, 0x303938, -4.35 + dx, 1.205, -4.78 + dz);
}
}
box(0.08, 0.08, 0.35, 0x68736f, -4.35, 1.28, -4.03);
box(0.7, 0.46, 0.62, 0xc97654, -4.73, 1.47, -4.77);
box(0.28, 0.07, 0.08, 0x45514e, -4.73, 1.74, -4.77);
box(1.75, 0.35, 0.95, 0xd6d9d1, -4.35, 2.55, -5.12);
box(0.58, 1.15, 0.5, 0xc7ccc3, -4.35, 3.05, -5.45);
// Sink and counters.
box(1.8, 1.0, 1.35, 0xd1dacf, -2.55, 0.58, -4.82);
box(1.95, 0.13, 1.45, 0xf3ead7, -2.55, 1.14, -4.8);
box(0.85, 0.05, 0.66, 0x819895, -2.55, 1.22, -4.78);
box(0.08, 0.55, 0.08, 0x71807c, -2.55, 1.49, -5.23);
box(0.08, 0.08, 0.36, 0x71807c, -2.55, 1.74, -5.08);
// Upper kitchen cabinets.
box(1.7, 1.05, 0.54, 0xd8c6a7, -6.9, 2.38, -5.52);
box(1.45, 0.85, 0.54, 0xe0ceb0, -0.25, 2.4, -5.52);
box(0.08, 0.3, 0.08, 0x6e7770, -6.3, 2.38, -5.2);
box(0.08, 0.3, 0.08, 0x6e7770, -0.52, 2.4, -5.2);
// Island and breakfast setup.
box(3.85, 1.02, 1.3, 0xb9c9b5, -4.35, 0.59, -0.85);
box(4.15, 0.14, 1.55, 0xf2e7d2, -4.35, 1.17, -0.85);
for (let i = 0; i < 4; i++) {
box(0.035, 0.7, 0.04, 0x819984, -5.6 + i * 0.83, 0.64, -0.18);
}
box(0.75, 0.055, 0.5, 0xf8f2df, -4.5, 1.27, -0.85);
box(0.32, 0.12, 0.27, 0xd69b58, -4.55, 1.35, -0.85);
box(0.21, 0.21, 0.21, 0xd85d48, -3.95, 1.36, -0.87);
box(0.18, 0.18, 0.18, 0xe4b449, -3.71, 1.35, -0.75);
box(0.25, 0.31, 0.25, 0xf0e9d9, -5.35, 1.4, -0.8);
box(0.11, 0.11, 0.15, 0xf0e9d9, -5.18, 1.4, -0.8);
// -------------------------------------------------------------------------
// Study corner
// -------------------------------------------------------------------------
// Desk.
box(4.0, 0.16, 1.25, 0xc89e71, 4.05, 1.18, -4.55);
for (const x of [2.35, 5.75]) {
for (const z of [-4.98, -4.12]) {
box(0.14, 1.08, 0.14, 0x5f6d69, x, 0.62, z);
}
}
box(0.18, 0.95, 0.92, 0x8aa6b5, 2.82, 0.56, -4.55);
box(0.16, 0.82, 0.84, 0x6f8997, 5.28, 0.57, -4.55);
// Monitor, keyboard, books.
box(0.12, 0.62, 0.58, 0x3f4b49, 4.25, 1.58, -4.83);
box(0.08, 0.44, 0.43, 0x83b6c4, 4.31, 1.58, -4.83);
box(0.12, 0.08, 0.25, 0x485451, 4.25, 1.29, -4.8);
box(0.75, 0.07, 0.28, 0xd8d6c7, 4.28, 1.31, -4.23);
box(0.28, 0.08, 0.4, 0x758e9b, 5.1, 1.31, -4.27);
const bookColors = [0xd57957, 0x5f86b8, 0xdeb45e, 0x79a184, 0xb87791];
for (let i = 0; i < 5; i++) {
box(0.09, 0.45 + (i % 2) * 0.1, 0.34, bookColors[i], 2.45 + i * 0.13, 1.47, -4.4);
}
// Chair.
box(0.85, 0.16, 0.82, 0x738e98, 4.23, 0.65, -3.28);
box(0.85, 0.92, 0.16, 0x738e98, 4.23, 1.13, -2.91);
box(0.12, 0.58, 0.12, 0x50605e, 3.88, 0.35, -3.28);
box(0.12, 0.58, 0.12, 0x50605e, 4.58, 0.35, -3.28);
// Bookcase.
box(1.45, 3.2, 0.28, 0xa67e5d, 6.8, 1.68, -5.55);
for (let row = 0; row < 4; row++) {
box(1.25, 0.11, 0.7, 0xc0956e, 6.8, 0.4 + row * 0.78, -5.15);
for (let j = 0; j < 5; j++) {
const h = 0.36 + ((row + j) % 3) * 0.06;
box(
0.14, h, 0.38,
bookColors[(row + j) % bookColors.length],
6.3 + j * 0.25, 0.47 + row * 0.78 + h / 2, -5.12
);
}
}
// Voxel desk lamp.
box(0.34, 0.08, 0.34, 0x596663, 3.05, 1.3, -4.7);
box(0.08, 0.62, 0.08, 0x596663, 3.05, 1.62, -4.7);
box(0.45, 0.2, 0.35, 0xe0b465, 3.18, 1.91, -4.7);
// -------------------------------------------------------------------------
// Entryway and front door
// -------------------------------------------------------------------------
// Shoe bench.
box(1.9, 0.18, 0.72, 0xb77e5e, 6.35, 0.69, -0.2);
for (const x of [5.63, 7.07]) {
box(0.16, 0.58, 0.56, 0x8b624d, x, 0.37, -0.2);
}
box(0.42, 0.22, 0.65, 0x4d7186, 6.08, 0.22, -0.2);
box(0.42, 0.22, 0.65, 0xdb8064, 6.62, 0.22, -0.2);
box(0.31, 0.12, 0.36, 0x355b72, 6.03, 0.39, -0.11);
box(0.31, 0.12, 0.36, 0xc76552, 6.63, 0.39, -0.11);
// Coat hooks and hanging jacket.
box(0.12, 1.5, 1.6, 0xa47a5e, 7.74, 1.62, -1.45);
box(0.12, 0.08, 0.25, 0x66574a, 7.6, 2.35, -1.78);
box(0.12, 0.08, 0.25, 0x66574a, 7.6, 2.35, -1.2);
box(0.25, 1.05, 0.58, 0x6e8ca1, 7.48, 1.8, -1.75);
box(0.25, 1.05, 0.58, 0x6e8ca1, 7.48, 1.8, -1.2);
// Door frame and panel.
box(0.3, 3.55, 0.2, 0xf1dfbf, 7.78, 1.78, 1.22);
box(0.3, 3.55, 0.2, 0xf1dfbf, 7.78, 1.78, 4.28);
box(0.3, 0.22, 3.26, 0xf1dfbf, 7.78, 3.52, 2.75);
box(0.18, 3.28, 1.9, 0xbc755d, 7.82, 1.72, 2.75);
box(0.08, 0.94, 1.02, 0x7da4ad, 7.94, 2.44, 2.75);
box(0.1, 0.06, 0.25, 0xe0bd74, 7.96, 1.58, 2.13);
box(0.08, 0.14, 0.07, 0x46534f, 7.95, 1.58, 2.13);
// Doormat and a pair of outdoor shoes.
box(1.85, 0.035, 1.05, 0x496c68, 6.0, 0.11, 3.32);
box(1.48, 0.025, 0.72, 0x60837e, 6.0, 0.135, 3.32);
box(0.35, 0.18, 0.58, 0x3f5864, 5.35, 0.21, 3.68);
box(0.35, 0.18, 0.58, 0x3f5864, 5.78, 0.21, 3.68);
addPlant(7.02, -0.78, 0.8);
addPlant(-7.0, 3.95, 0.9);
// Room labels.
const kitchenLabel = labelSprite("KITCHEN", "#60705d", 2.05);
kitchenLabel.position.set(-4.5, 4.45, -4.8);
scene.add(kitchenLabel);
const studyLabel = labelSprite("STUDY", "#516e80", 1.75);
studyLabel.position.set(4.25, 4.45, -4.75);
scene.add(studyLabel);
const entryLabel = labelSprite("ENTRYWAY", "#8a5d4d", 2.15);
entryLabel.position.set(6.15, 4.42, 2.75);
scene.add(entryLabel);
// -------------------------------------------------------------------------
// People built entirely from voxel-like boxes
// -------------------------------------------------------------------------
function createPerson(name, shirt, skin, hair, scale) {
const root = new THREE.Group();
root.scale.setScalar(scale);
root.userData.familyName = name;
scene.add(root);
const body = box(0.62, 0.76, 0.38, shirt, 0, 1.1, 0, root);
box(0.65, 0.12, 0.4, shirt, 0, 1.46, 0, root);
box(0.5, 0.5, 0.46, skin, 0, 1.82, 0, root);
box(0.53, 0.16, 0.49, hair, 0, 2.08, -0.01, root);
box(0.12, 0.13, 0.08, skin, 0, 1.79, 0.25, root);
box(0.055, 0.055, 0.025, 0x303c3a, -0.12, 1.89, 0.238, root);
box(0.055, 0.055, 0.025, 0x303c3a, 0.12, 1.89, 0.238, root);
const leftArm = new THREE.Group();
const rightArm = new THREE.Group();
leftArm.position.set(-0.4, 1.42, 0);
rightArm.position.set(0.4, 1.42, 0);
root.add(leftArm, rightArm);
box(0.19, 0.63, 0.21, shirt, 0, -0.27, 0, leftArm);
box(0.19, 0.63, 0.21, shirt, 0, -0.27, 0, rightArm);
box(0.2, 0.17, 0.22, skin, 0, -0.64, 0, leftArm);
box(0.2, 0.17, 0.22, skin, 0, -0.64, 0, rightArm);
const leftLeg = new THREE.Group();
const rightLeg = new THREE.Group();
leftLeg.position.set(-0.17, 0.72, 0);
rightLeg.position.set(0.17, 0.72, 0);
root.add(leftLeg, rightLeg);
box(0.23, 0.59, 0.26, 0x46545a, 0, -0.29, 0, leftLeg);
box(0.23, 0.59, 0.26, 0x46545a, 0, -0.29, 0, rightLeg);
box(0.26, 0.16, 0.38, 0x304044, 0, -0.64, 0.07, leftLeg);
box(0.26, 0.16, 0.38, 0x304044, 0, -0.64, 0.07, rightLeg);
const nameTag = labelSprite(name.toUpperCase(), shirt, 1.1);
nameTag.position.set(0, 2.58, 0);
nameTag.material.depthTest = false;
root.add(nameTag);
return {
name,
root,
body,
leftArm,
rightArm,
leftLeg,
rightLeg,
baseScale: scale,
phaseOffset: Math.random() * Math.PI * 2
};
}
const mia = createPerson("Mia", 0xef8b4a, 0xc9825d, 0x563c31, 1.0);
const noah = createPerson("Noah", 0x557bc5, 0xe0ad83, 0x3d302d, 0.82);
const zoe = createPerson("Zoe", 0xb75e91, 0x9b6247, 0x292321, 0.88);
// Mia carries breakfast after setting it out.
const breakfastMug = new THREE.Group();
breakfastMug.position.set(0, -0.73, 0.15);
mia.rightArm.add(breakfastMug);
box(0.23, 0.3, 0.23, 0xf3ead8, 0, 0, 0, breakfastMug);
box(0.1, 0.12, 0.1, 0xf3ead8, 0.15, 0, 0, breakfastMug);
breakfastMug.visible = false;
const toast = box(0.28, 0.1, 0.24, 0xc88e4f, 0, -0.71, 0.17, mia.leftArm);
toast.visible = false;
// Noah's school bag.
const schoolBag = new THREE.Group();
noah.root.add(schoolBag);
box(0.52, 0.62, 0.25, 0x3d657e, 0, 1.1, -0.31, schoolBag);
box(0.3, 0.18, 0.08, 0x7399aa, 0, 1.2, -0.46, schoolBag);
box(0.08, 0.55, 0.08, 0x2d5068, -0.2, 1.17, -0.48, schoolBag);
box(0.08, 0.55, 0.08, 0x2d5068, 0.2, 1.17, -0.48, schoolBag);
schoolBag.visible = false;
// Zoe's keys.
const keys = new THREE.Group();
keys.position.set(0, -0.73, 0.12);
zoe.rightArm.add(keys);
box(0.05, 0.18, 0.05, 0xd4a443, 0, 0, 0, keys);
box(0.16, 0.05, 0.05, 0xd4a443, 0.07, -0.07, 0, keys);
box(0.08, 0.08, 0.04, 0xd4a443, 0.14, -0.07, 0, keys);
keys.visible = false;
// -------------------------------------------------------------------------
// Coordinated routes
// -------------------------------------------------------------------------
const routes = [
{
person: mia,
color: 0xef8b4a,
track: [
{ t: 0, x: -4.35, z: 0.48, h: Math.PI },
{ t: 3.2, x: -4.35, z: 0.48, h: Math.PI },
{ t: 4.25, x: -3.45, z: 0.28, h: 0.35 },
{ t: 7.1, x: -1.75, z: -1.6, h: 0.42 },
{ t: 9.0, x: 0.25, z: -0.12, h: 0.55 },
{ t: 11.5, x: 2.0, z: 0.85, h: 0.66 },
{ t: 14.35,x: 5.05, z: 2.22, h: 0.88 },
{ t: 17.2, x: 5.72, z: 2.92, h: 1.18 }
]
},
{
person: noah,
color: 0x557bc5,
track: [
{ t: 0, x: 4.22, z: -2.35, h: Math.PI },
{ t: 4.15, x: 4.22, z: -2.35, h: Math.PI },
{ t: 5.3, x: 3.75, z: -1.95, h: 2.8 },
{ t: 7.8, x: 2.05, z: -0.95, h: 2.3 },
{ t: 9.6, x: 0.78, z: 0.52, h: 1.6 },
{ t: 12.1, x: 3.15, z: 1.2, h: 0.9 },
{ t: 14.7, x: 5.35, z: 2.05, h: 0.9 },
{ t: 17.2, x: 6.62, z: 2.62, h: 1.05 }
]
},
{
person: zoe,
color: 0xb75e91,
track: [
{ t: 0, x: 6.23, z: 0.74, h: Math.PI },
{ t: 2.65, x: 6.23, z: 0.74, h: Math.PI },
{ t: 3.7, x: 5.78, z: 1.03, h: 0.7 },
{ t: 6.0, x: 6.6, z: 1.45, h: 0.65 },
{ t: 8.7, x: 6.88, z: 2.0, h: 0.95 },
{ t: 11.4, x: 6.2, z: 2.35, h: 1.3 },
{ t: 14.0, x: 6.25, z: 3.12, h: 1.4 },
{ t: 17.2, x: 7.0, z: 3.48, h: 1.4 }
]
}
];
const pathsGroup = new THREE.Group();
scene.add(pathsGroup);
function buildRoute(route) {
const routeMaterial = new THREE.MeshBasicMaterial({
color: route.color,
transparent: true,
opacity: 0.7,
depthWrite: false
});
for (let i = 1; i < route.track.length; i++) {
const a = route.track[i - 1];
const b = route.track[i];
const dx = b.x - a.x;
const dz = b.z - a.z;
const distance = Math.hypot(dx, dz);
const steps = Math.max(1, Math.ceil(distance / 0.3));
for (let j = 0; j <= steps; j++) {
const u = j / steps;
const marker = box(
0.105, 0.022, 0.105,
routeMaterial,
a.x + dx * u,
0.135,
a.z + dz * u,
pathsGroup
);
marker.castShadow = false;
marker.receiveShadow = false;
}
}
}
routes.forEach(buildRoute);
// A pulsing voxel meeting area at the front door.
const meetingMarker = new THREE.Group();
meetingMarker.position.set(6.1, 0.13, 2.85);
pathsGroup.add(meetingMarker);
const meetingMaterial = new THREE.MeshBasicMaterial({
color: 0x3e8a78,
transparent: true,
opacity: 0.58,
depthWrite: false
});
for (let x = -1; x <= 1; x++) {
for (let z = -1; z <= 1; z++) {
if (Math.abs(x) + Math.abs(z) > 1) continue;
const tile = box(0.22, 0.025, 0.22, meetingMaterial, x * 0.25, 0, z * 0.25, meetingMarker);
tile.castShadow = false;
}
}
const readyLabel = labelSprite("READY TO GO!", "#337969", 2.2);
readyLabel.position.set(6.15, 3.75, 3.0);
readyLabel.visible = false;
scene.add(readyLabel);
// -------------------------------------------------------------------------
// Timeline sampling and animation
// -------------------------------------------------------------------------
const duration = 18;
let time = 0;
let playing = true;
function smoothstep(u) {
return u * u * (3 - 2 * u);
}
function shortestAngle(a, b) {
let delta = (b - a + Math.PI) % (Math.PI * 2) - Math.PI;
if (delta < -Math.PI) delta += Math.PI * 2;
return a + delta;
}
function sampleTrack(track, t) {
let index = 1;
while (index < track.length - 1 && t > track[index].t) index++;
const a = track[index - 1];
const b = track[index];
const span = Math.max(0.0001, b.t - a.t);
const u = THREE.MathUtils.clamp((t - a.t) / span, 0, 1);
const s = smoothstep(u);
const x = THREE.MathUtils.lerp(a.x, b.x, s);
const z = THREE.MathUtils.lerp(a.z, b.z, s);
let headingA = a.h;
let headingB = b.h;
if (headingA === undefined) {
headingA = Math.atan2(b.x - a.x, b.z - a.z);
}
if (headingB === undefined) {
headingB = Math.atan2(b.x - a.x, b.z - a.z);
}
const heading = shortestAngle(headingA, headingB);
const moving = Math.hypot(b.x - a.x, b.z - a.z) > 0.08 && u > 0.001 && u < 0.999;
return { x, z, heading, moving, u };
}
function animatePerson(person, route, t) {
const sample = sampleTrack(route.track, t);
const cycle = t * 8.5 + person.phaseOffset;
const walkAmount = sample.moving ? 1 : 0;
person.root.position.x = sample.x;
person.root.position.z = sample.z;
person.root.rotation.y = sample.heading;
let bob = Math.sin(t * 2.1 + person.phaseOffset) * 0.008;
if (walkAmount) bob += Math.abs(Math.sin(cycle)) * 0.045;
person.root.position.y = 0.085 + bob;
person.leftLeg.rotation.x = walkAmount ? Math.sin(cycle) * 0.56 : 0;
person.rightLeg.rotation.x = walkAmount ? -Math.sin(cycle) * 0.56 : 0;
if (walkAmount) {
person.leftArm.rotation.x = -Math.sin(cycle) * 0.46;
person.rightArm.rotation.x = Math.sin(cycle) * 0.46;
person.leftArm.rotation.z = 0.05;
person.rightArm.rotation.z = -0.05;
} else {
person.leftArm.rotation.x = 0;
person.rightArm.rotation.x = 0;
person.leftArm.rotation.z = 0;
person.rightArm.rotation.z = 0;
}
if (person === mia && t < 3.2) {
person.leftArm.rotation.x = -0.92 + Math.sin(t * 4) * 0.15;
person.rightArm.rotation.x = -0.92 - Math.sin(t * 4) * 0.15;
}
if (person === noah && t < 4.15) {
person.rightArm.rotation.x = -1.05 + Math.sin(t * 3.6) * 0.2;
person.leftArm.rotation.x = -0.58;
}
if (person === zoe && t < 2.65) {
person.leftArm.rotation.x = -0.8;
person.rightArm.rotation.x = -0.8;
const crouch = 0.9 + Math.sin(t * 2.8) * 0.025;
person.root.scale.set(person.baseScale, person.baseScale * crouch, person.baseScale);
} else {
person.root.scale.set(person.baseScale, person.baseScale, person.baseScale);
}
// At the door, each family member gives a small wave.
if (t > 14.8) {
person.rightArm.rotation.x = -1.65 + Math.sin(t * 4 + person.phaseOffset) * 0.18;
person.rightArm.rotation.z = -0.15;
}
}
const statusElements = {
mia: document.getElementById("status-mia"),
noah: document.getElementById("status-noah"),
zoe: document.getElementById("status-zoe")
};
function statusFor(person, t) {
if (person === mia) {
if (t < 3.2) return "Setting out breakfast";
if (t < 14.4) return "Carrying breakfast to the door";
return "Waiting by the front door";
}
if (person === noah) {
if (t < 4.15) return "Packing a school bag";
if (t < 14.7) return "Joining the shared route";
return "Waiting by the front door";
}
if (t < 2.65) return "Finding her shoes";
if (t < 14.0) return "Walking the entry loop";
return "Waiting by the front door";
}
const phaseElement = document.getElementById("phase");
const progressElement = document.getElementById("progress");
const elapsedElement = document.getElementById("elapsed");
const playButton = document.getElementById("play");
const restartButton = document.getElementById("restart");
const pathsButton = document.getElementById("paths-toggle");
const tip = document.getElementById("tip");
function updateUI() {
progressElement.value = time;
progressElement.style.setProperty("--progress", `${(time / duration) * 100}%`);
elapsedElement.textContent = `0:${String(Math.floor(time)).padStart(2, "0")}`;
if (time < 3.6) {
phaseElement.textContent = "Three rooms. One shared plan.";
} else if (time < 10) {
phaseElement.textContent = "The routes begin to overlap.";
} else if (time < 14.8) {
phaseElement.textContent = "The hallway fills with purpose.";
} else {
phaseElement.textContent = "Together at the door — ready for 8:15.";
}
statusElements.mia.textContent = statusFor(mia, time);
statusElements.noah.textContent = statusFor(noah, time);
statusElements.zoe.textContent = statusFor(zoe, time);
readyLabel.visible = time > 14.7;
meetingMarker.visible = time > 13.8;
}
function updateScene() {
routes.forEach(route => animatePerson(route.person, route, time));
breakfastMug.visible = time >= 3.2;
toast.visible = time >= 3.2;
schoolBag.visible = time >= 4.15;
keys.visible = time >= 2.65;
const pulse = 1 + Math.sin(time * 3.8) * 0.07;
meetingMarker.scale.setScalar(pulse);
meetingMaterial.opacity = 0.38 + (Math.sin(time * 3.8) * 0.5 + 0.5) * 0.28;
updateUI();
}
playButton.addEventListener("click", () => {
if (time >= duration) time = 0;
playing = !playing;
playButton.textContent = playing ? "Ⅱ" : "▶";
playButton.setAttribute("aria-label", playing ? "Pause animation" : "Play animation");
});
restartButton.addEventListener("click", () => {
time = 0;
playing = true;
playButton.textContent = "Ⅱ";
updateScene();
});
progressElement.addEventListener("input", () => {
time = Number(progressElement.value);
updateScene();
});
pathsButton.addEventListener("click", () => {
const visible = !pathsGroup.visible;
pathsGroup.visible = visible;
pathsButton.classList.toggle("active", visible);
pathsButton.setAttribute("aria-pressed", String(visible));
});
// -------------------------------------------------------------------------
// Custom camera controls: orbit, zoom, and simple presets
// -------------------------------------------------------------------------
let dragging = false;
let dragMoved = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
dragMoved = false;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
if (Math.abs(dx) + Math.abs(dy) > 2) dragMoved = true;
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(cameraState.phi - dy * 0.005, 0.32, 1.16);
previousX = event.clientX;
previousY = event.clientY;
});
renderer.domElement.addEventListener("pointerup", event => {
dragging = false;
if (!dragMoved) selectFamily(event);
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
});
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
cameraState.zoom = THREE.MathUtils.clamp(
cameraState.zoom * Math.exp(-event.deltaY * 0.001),
0.68,
2.15
);
},
{ passive: false }
);
document.querySelectorAll("[data-view]").forEach(button => {
button.addEventListener("click", () => {
document.querySelectorAll("[data-view]").forEach(b => b.classList.remove("active"));
button.classList.add("active");
if (button.dataset.view === "iso") {
cameraState.theta = 0.69;
cameraState.phi = 0.79;
cameraState.zoom = 1;
cameraState.target.set(0, 0.75, -0.4);
} else if (button.dataset.view === "top") {
cameraState.theta = 0.68;
cameraState.phi = 0.33;
cameraState.zoom = 0.95;
cameraState.target.set(0, 0, 0);
} else {
cameraState.theta = 0.94;
cameraState.phi = 0.91;
cameraState.zoom = 1.52;
cameraState.target.set(4.6, 1.0, 1.8);
}
});
});
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x + cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z + cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
camera.zoom = cameraState.zoom;
camera.updateProjectionMatrix();
}
// -------------------------------------------------------------------------
// Family selection
// -------------------------------------------------------------------------
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function selectFamily(event) {
pointer.x = (event.clientX / window.innerWidth) * 2 - 1;
pointer.y = -(event.clientY / window.innerHeight) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects([mia.root, noah.root, zoe.root], true);
if (!hits.length) {
tip.classList.remove("visible");
return;
}
let object = hits[0].object;
while (object && !object.userData.familyName) object = object.parent;
if (!object) return;
const person = object.userData.familyName;
tip.textContent = `${person} — ${statusFor(person === "Mia" ? mia : person === "Noah" ? noah : zoe, time)}`;
tip.classList.add("visible");
clearTimeout(selectFamily.hideTimer);
selectFamily.hideTimer = setTimeout(() => tip.classList.remove("visible"), 2800);
}
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const frustumHeight = Math.max(13.7, 20.5 / aspect);
camera.left = (-frustumHeight * aspect) / 2;
camera.right = (frustumHeight * aspect) / 2;
camera.top = frustumHeight / 2;
camera.bottom = -frustumHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
resize();
updateScene();
const animationClock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(animationClock.getDelta(), 0.05);
if (playing) {
time += delta;
if (time >= duration) {
time = duration;
playing = false;
playButton.textContent = "▶";
playButton.setAttribute("aria-label", "Replay animation");
}
updateScene();
}
updateCamera();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```