Prompt specification
Build or customize the Three.js 3D scene "Family mixed-activity evening" 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: Family mixed-activity evening
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/family-mixed-activity-evening-x0223
Scene Description Prompt:
A voxel family shares a table for homework, drawing, and repairs, exchanging tools across distinct work zones. Three.js from cdnjs, one HTML file.
Working Three.js Starter (family-mixed-activity-evening-x0223):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>The Shared Table — A Voxel Family Scene</title>
<style>
:root {
--ink: #24333a;
--muted: #66767a;
--paper: rgba(255, 252, 245, 0.92);
--line: rgba(36, 51, 58, 0.12);
--blue: #65a8dc;
--yellow: #efb64f;
--green: #68aa78;
--coral: #e97962;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
color: var(--ink);
background:
radial-gradient(circle at 50% 18%, #fffaf0 0%, #eee5d7 58%, #ddd1c1 100%);
font-family: "Trebuchet MS", "Avenir Next", system-ui, sans-serif;
}
body::after {
content: "";
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
opacity: 0.16;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E");
mix-blend-mode: multiply;
}
canvas {
position: fixed;
inset: 0;
display: block;
z-index: 1;
touch-action: none;
outline: none;
}
.ui {
position: fixed;
inset: 0;
z-index: 3;
pointer-events: none;
}
header {
position: absolute;
top: 28px;
left: 30px;
max-width: 430px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
color: #5d6e70;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 22px;
height: 4px;
border-radius: 4px;
background: var(--coral);
box-shadow: 7px 0 0 #efb64f, 14px 0 0 #68aa78;
}
h1 {
margin: 0;
font-size: clamp(31px, 4vw, 55px);
line-height: 0.98;
letter-spacing: -0.055em;
}
header p {
max-width: 390px;
margin: 13px 0 0;
color: var(--muted);
font-size: 14px;
line-height: 1.55;
}
.live {
position: absolute;
top: 28px;
right: 30px;
display: flex;
align-items: center;
gap: 9px;
padding: 10px 14px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(255, 252, 245, 0.78);
box-shadow: 0 9px 30px rgba(71, 55, 37, 0.08);
backdrop-filter: blur(10px);
color: #4f6264;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.live-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #68aa78;
box-shadow: 0 0 0 5px rgba(104, 170, 120, 0.14);
animation: pulse 2s infinite;
}
@keyframes pulse {
50% {
box-shadow: 0 0 0 8px rgba(104, 170, 120, 0);
}
}
.zone-info {
position: absolute;
left: 30px;
bottom: 100px;
width: 300px;
padding: 18px 20px;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--paper);
box-shadow: 0 18px 50px rgba(71, 55, 37, 0.11);
backdrop-filter: blur(12px);
}
.zone-top {
display: flex;
align-items: center;
gap: 13px;
}
.zone-number {
display: grid;
width: 42px;
height: 42px;
flex: 0 0 auto;
place-items: center;
border-radius: 12px;
color: white;
background: var(--blue);
font-size: 13px;
font-weight: 900;
transition: background 250ms ease;
}
.zone-info h2 {
margin: 0 0 3px;
font-size: 18px;
letter-spacing: -0.025em;
}
.zone-info .meta {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.zone-info p {
margin: 14px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.5;
}
.exchange {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 15px;
padding-top: 14px;
border-top: 1px solid var(--line);
}
.exchange-copy {
display: flex;
align-items: center;
gap: 8px;
color: #56696b;
font-size: 11px;
font-weight: 700;
}
.exchange-dot {
width: 9px;
height: 9px;
border-radius: 3px;
background: var(--coral);
transform: rotate(45deg);
}
button {
border: 0;
color: var(--ink);
font: inherit;
cursor: pointer;
pointer-events: auto;
-webkit-tap-highlight-color: transparent;
}
.send-button {
padding: 8px 11px;
border-radius: 9px;
background: #24333a;
color: white;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.04em;
transition: transform 160ms ease, background 160ms ease;
}
.send-button:hover {
background: #e97962;
transform: translateY(-1px);
}
.controls {
position: absolute;
left: 50%;
bottom: 24px;
display: flex;
gap: 6px;
padding: 7px;
border: 1px solid var(--line);
border-radius: 17px;
background: rgba(255, 252, 245, 0.94);
box-shadow: 0 15px 45px rgba(71, 55, 37, 0.14);
backdrop-filter: blur(14px);
transform: translateX(-50%);
pointer-events: auto;
}
.controls button {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 13px;
border-radius: 11px;
background: transparent;
color: #687779;
font-size: 11px;
font-weight: 800;
white-space: nowrap;
transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}
.controls button:hover {
color: var(--ink);
background: rgba(36, 51, 58, 0.06);
}
.controls button.active {
color: white;
background: var(--ink);
}
.controls .divider {
width: 1px;
margin: 6px 2px;
background: var(--line);
}
.swatch {
width: 9px;
height: 9px;
border-radius: 3px;
background: var(--blue);
}
.swatch.art {
background: var(--yellow);
}
.swatch.repair {
background: var(--green);
}
.hint {
position: absolute;
right: 30px;
bottom: 34px;
color: rgba(54, 70, 72, 0.68);
font-size: 10px;
font-weight: 700;
line-height: 1.6;
text-align: right;
letter-spacing: 0.03em;
}
.loading {
position: fixed;
inset: 0;
z-index: 10;
display: grid;
place-items: center;
color: var(--ink);
background: #f0e7d9;
font-size: 12px;
font-weight: 900;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 500ms ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 900px) {
header {
top: 20px;
left: 20px;
}
header p,
.live,
.hint {
display: none;
}
.zone-info {
left: 18px;
bottom: 92px;
width: min(290px, calc(100vw - 36px));
}
.controls {
bottom: 14px;
max-width: calc(100vw - 20px);
overflow-x: auto;
}
.controls button {
padding: 9px 10px;
}
}
@media (max-width: 520px) {
h1 {
max-width: 280px;
font-size: 34px;
}
.zone-info {
padding: 14px;
}
.zone-info p {
display: none;
}
.exchange {
margin-top: 10px;
padding-top: 10px;
}
.controls button span.label {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive voxel family sharing a work table"></canvas>
<div class="ui">
<header>
<div class="eyebrow">Voxel home studio</div>
<h1>One table.<br />Three worlds.</h1>
<p>
Homework, drawing, and repairs unfold side by side while pencils,
books, and tools travel between the family.
</p>
</header>
<div class="live">
<span class="live-dot"></span>
<span>4 family members · 3 work zones</span>
</div>
<section class="zone-info" aria-live="polite">
<div class="zone-top">
<div class="zone-number" id="zone-number">01</div>
<div>
<h2 id="zone-title">Homework Bay</h2>
<div class="meta" id="zone-meta">Blue mat · quiet corner</div>
</div>
</div>
<p id="zone-description">
Notes, books, and a sharpened pencil wait beside the shared edge.
</p>
<div class="exchange">
<div class="exchange-copy">
<span class="exchange-dot"></span>
<span id="exchange-text">Tools are passing between zones</span>
</div>
<button class="send-button" id="send-tools">Pass tools</button>
</div>
</section>
<nav class="controls" aria-label="Scene controls">
<button data-zone="home" class="active">
<span class="swatch"></span>
<span class="label">Homework</span>
</button>
<button data-zone="art">
<span class="swatch art"></span>
<span class="label">Drawing</span>
</button>
<button data-zone="repair">
<span class="swatch repair"></span>
<span class="label">Repairs</span>
</button>
<span class="divider"></span>
<button id="reset-view" title="Reset camera">
<span class="label">Reset</span>
↺
</button>
<button id="toggle-motion" title="Pause or resume animation">
<span class="label" id="motion-label">Pause</span>
<span id="motion-icon">Ⅱ</span>
</button>
</nav>
<div class="hint">
DRAG TO ORBIT · WHEEL TO ZOOM<br />
SHIFT + DRAG TO PAN · CLICK A ZONE
</div>
</div>
<div class="loading" id="loading">Building the shared table…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xf0e7d9);
scene.fog = new THREE.Fog(0xf0e7d9, 18, 35);
const camera = new THREE.OrthographicCamera(-8, 8, 5, -5, 0.1, 100);
const cameraState = {
yaw: 0.72,
pitch: 0.62,
zoom: 1,
targetYaw: 0.72,
targetPitch: 0.62,
targetZoom: 1,
target: new THREE.Vector3(0, 1.15, 0),
targetGoal: new THREE.Vector3(0, 1.15, 0)
};
const materialCache = new Map();
function M(color, options = {}) {
const key = `${color}-${JSON.stringify(options)}`;
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0,
...options
})
);
}
return materialCache.get(key);
}
function box(w, h, d, material, x = 0, y = 0, z = 0, parent = scene) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function group(x = 0, y = 0, z = 0, parent = scene) {
const g = new THREE.Group();
g.position.set(x, y, z);
parent.add(g);
return g;
}
function makeLabel(text, color, width = 1.45) {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 512;
labelCanvas.height = 128;
const ctx = labelCanvas.getContext("2d");
ctx.clearRect(0, 0, 512, 128);
ctx.fillStyle = color;
ctx.beginPath();
ctx.roundRect(12, 18, 488, 92, 22);
ctx.fill();
ctx.fillStyle = "rgba(255,255,255,.18)";
ctx.fillRect(28, 31, 456, 8);
ctx.fillStyle = "#ffffff";
ctx.font = "900 43px Trebuchet MS, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 256, 68);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(width, width * 0.25, 1);
sprite.renderOrder = 20;
return sprite;
}
// Lighting
scene.add(new THREE.HemisphereLight(0xfff7e8, 0x9e8e79, 2.1));
const keyLight = new THREE.DirectionalLight(0xfff4dc, 3.1);
keyLight.position.set(5.5, 10, 7.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -8;
keyLight.shadow.camera.right = 8;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 25;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xb9d8ed, 0.75);
fillLight.position.set(-6, 5, -4);
scene.add(fillLight);
// Room and tiled voxel floor
box(10.2, 0.34, 8.2, M(0xbba58a), 0, -0.26, 0);
const tileColors = [0xe9ddca, 0xeee3d1, 0xe3d6c1];
for (let ix = 0; ix < 10; ix++) {
for (let iz = 0; iz < 8; iz++) {
const color = tileColors[(ix + iz * 2) % tileColors.length];
box(
0.96,
0.055,
0.96,
M(color),
-4.5 + ix,
-0.065,
-3.5 + iz
);
}
}
// Back wall
box(10.2, 5.4, 0.2, M(0xf2e9dc), 0, 2.52, -4.06);
box(10.2, 0.13, 0.27, M(0xcbb59a), 0, 0.02, -4.03);
box(10.2, 0.13, 0.27, M(0xcbb59a), 0, 5.16, -4.03);
// Window
const windowGroup = group(-3.12, 3.18, -3.91);
box(2.0, 1.65, 0.09, M(0x87bad5, {
emissive: 0x5b89a3,
emissiveIntensity: 0.22
}), 0, 0, 0, windowGroup);
box(2.25, 0.14, 0.16, M(0xfaf2e6), 0, 0.87, 0.04, windowGroup);
box(2.25, 0.14, 0.16, M(0xfaf2e6), 0, -0.87, 0.04, windowGroup);
box(0.14, 1.65, 0.16, M(0xfaf2e6), -1.05, 0, 0.04, windowGroup);
box(0.14, 1.65, 0.16, M(0xfaf2e6), 1.05, 0, 0.04, windowGroup);
box(0.09, 1.65, 0.18, M(0xfaf2e6), 0, 0, 0.06, windowGroup);
box(2.0, 0.08, 0.18, M(0xfaf2e6), 0, 0, 0.06, windowGroup);
// Wall art
const wallArt = group(0.1, 3.35, -3.88);
box(1.55, 1.18, 0.09, M(0x6f4938), 0, 0, 0, wallArt);
box(1.34, 0.97, 0.055, M(0xf8f0e3), 0, 0, 0.07, wallArt);
box(0.35, 0.35, 0.035, M(0xe97962), -0.27, 0.15, 0.11, wallArt);
box(0.35, 0.35, 0.035, M(0xefb64f), 0.08, 0.15, 0.11, wallArt);
box(0.35, 0.35, 0.035, M(0x65a8dc), 0.43, 0.15, 0.11, wallArt);
box(0.62, 0.15, 0.035, M(0x68aa78), 0.08, -0.22, 0.11, wallArt);
// Shelf
box(2.25, 0.13, 0.54, M(0x8a5d43), 3.25, 3.42, -3.67);
box(2.25, 0.13, 0.54, M(0x8a5d43), 3.25, 2.33, -3.67);
const bookColors = [0x65a8dc, 0xe97962, 0xefb64f, 0x68aa78, 0x876b9b];
for (let i = 0; i < 9; i++) {
const h = 0.34 + (i % 3) * 0.08;
box(
0.13 + (i % 2) * 0.03,
h,
0.28,
M(bookColors[i % bookColors.length]),
2.43 + i * 0.19,
2.93 + h / 2,
-3.63
);
}
box(0.7, 0.5, 0.38, M(0xd8b98c), 3.83, 3.75, -3.62);
box(0.28, 0.28, 0.28, M(0x876b9b), 2.42, 2.55, -3.62);
// Plant
const plant = group(-4.05, 0, -3.15);
box(0.58, 0.58, 0.58, M(0xd88762), 0, 0.28, 0, plant);
box(0.66, 0.12, 0.66, M(0xe6a17e), 0, 0.56, 0, plant);
box(0.09, 1.05, 0.09, M(0x567e55), 0, 1.03, 0, plant);
box(0.65, 0.18, 0.35, M(0x68aa78), -0.24, 1.12, 0, plant);
box(0.62, 0.18, 0.36, M(0x7cb77b), 0.25, 1.38, 0, plant);
box(0.58, 0.17, 0.34, M(0x4e8b63), -0.14, 1.65, 0, plant);
// Small side stool
box(0.72, 0.12, 0.72, M(0xb47b52), 4.15, 0.72, 1.45);
for (const x of [-0.25, 0.25]) {
for (const z of [-0.25, 0.25]) {
box(0.1, 0.7, 0.1, M(0x8b6244), 4.15 + x, 0.35, 1.45 + z);
}
}
// Main table
const table = group();
box(5.8, 0.22, 3.0, M(0xc88e58), 0, 1.55, 0, table);
box(5.92, 0.13, 3.12, M(0x8b5f43), 0, 1.40, 0, table);
for (const x of [-2.36, 2.36]) {
for (const z of [-1.06, 1.06]) {
box(0.2, 1.42, 0.2, M(0x9b6946), x, 0.69, z, table);
}
}
box(4.7, 0.15, 0.18, M(0x9b6946), 0, 0.46, 0, table);
box(0.18, 0.15, 2.0, M(0x9b6946), 0, 0.46, 0, table);
// Work-zone mats
const zones = {
home: {
index: "01",
title: "Homework Bay",
meta: "Blue mat · quiet corner",
description:
"Notes, books, and a sharpened pencil wait beside the shared edge.",
color: 0x65a8dc,
x: -1.95,
z: 0.08
},
art: {
index: "02",
title: "Pixel Studio",
meta: "Golden mat · creative corner",
description:
"A tiny easel turns colored blocks into a family-sized masterpiece.",
color: 0xefb64f,
x: 0,
z: -0.67
},
repair: {
index: "03",
title: "Repair Corner",
meta: "Green mat · practical corner",
description:
"A patient robot, a toolbox, and the family's best little wrench.",
color: 0x68aa78,
x: 1.92,
z: 0.08
}
};
const hitTargets = [];
const zoneMeshes = {};
function createZone(id, data, width, depth) {
box(
width + 0.08,
0.035,
depth + 0.08,
M(0x6f675d),
data.x,
1.685,
data.z
);
const zoneMaterial = new THREE.MeshStandardMaterial({
color: data.color,
roughness: 0.9,
emissive: data.color,
emissiveIntensity: 0.035
});
const matMesh = box(
width,
0.045,
depth,
zoneMaterial,
data.x,
1.71,
data.z
);
zoneMeshes[id] = matMesh;
const hitMaterial = new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false
});
const hit = box(
width,
0.8,
depth,
hitMaterial,
data.x,
2.08,
data.z
);
hit.castShadow = false;
hit.receiveShadow = false;
hit.userData.zone = id;
hitTargets.push(hit);
const label = makeLabel(data.title.toUpperCase(), `#${data.color.toString(16).padStart(6, "0")}`);
label.position.set(data.x, data.z < 0 ? 3.08 : 2.46, data.z + 0.15);
scene.add(label);
}
createZone("home", zones.home, 1.48, 1.92);
createZone("art", zones.art, 1.52, 1.43);
createZone("repair", zones.repair, 1.5, 1.93);
// Homework props
const homework = group(-1.92, 1.75, 0.16);
homework.rotation.y = -0.08;
box(0.79, 0.025, 0.98, M(0xfffdf7), 0, 0, 0, homework);
for (let i = 0; i < 6; i++) {
box(
0.49 - (i % 2) * 0.08,
0.012,
0.018,
M(i === 0 ? 0x65a8dc : 0xb7c2c1),
-0.03,
0.022,
-0.34 + i * 0.115,
homework
);
}
box(0.32, 0.025, 0.34, M(0xe9c55f), 0.24, 0.025, 0.32, homework);
const bookStack = group(-2.12, 1.78, -0.75);
box(0.72, 0.11, 0.47, M(0xe97962), 0, 0, 0, bookStack);
box(0.67, 0.055, 0.43, M(0xfff8e9), 0, 0.073, 0, bookStack);
box(0.72, 0.09, 0.47, M(0x65a8dc), 0.04, 0.13, 0.01, bookStack);
// Pencil cup
const pencilCup = group(-2.53, 1.75, 0.83);
box(0.26, 0.31, 0.26, M(0x65a8dc), 0, 0.15, 0, pencilCup);
box(0.19, 0.025, 0.19, M(0x3c6f92), 0, 0.315, 0, pencilCup);
box(0.05, 0.42, 0.05, M(0xefb64f), -0.04, 0.46, 0, pencilCup);
box(0.05, 0.36, 0.05, M(0xe97962), 0.05, 0.43, 0.02, pencilCup);
// Drawing easel and pixel artwork
const easel = group(0, 1.72, -0.7);
box(1.26, 0.88, 0.1, M(0x8a5d43), 0, 0.62, 0, easel);
box(1.09, 0.72, 0.055, M(0xfff8e9), 0, 0.62, 0.075, easel);
box(0.08, 0.74, 0.08, M(0x9b6946), -0.42, 0.29, 0.04, easel);
box(0.08, 0.74, 0.08, M(0x9b6946), 0.42, 0.29, 0.04, easel);
box(0.08, 0.08, 0.62, M(0x9b6946), 0, 0.12, 0.23, easel);
const pixels = [
[-0.29, 0.71, 0.14, 0.14, 0x65a8dc],
[-0.12, 0.71, 0.14, 0.14, 0xe97962],
[0.05, 0.71, 0.14, 0.14, 0xefb64f],
[-0.29, 0.54, 0.14, 0.14, 0xefb64f],
[-0.12, 0.54, 0.14, 0.14, 0x68aa78],
[0.05, 0.54, 0.14, 0.14, 0x65a8dc],
[-0.21, 0.38, 0.14, 0.14, 0x68aa78],
[-0.04, 0.38, 0.14, 0.14, 0xe97962]
];
for (const [x, y, w, h, color] of pixels) {
box(w, h, 0.025, M(color), x, y, 0.12, easel);
}
// Palette and paint blocks
box(0.48, 0.035, 0.34, M(0xf0d7a8), 0.58, 1.75, -0.48);
box(0.1, 0.04, 0.1, M(0xe97962), 0.43, 1.78, -0.58);
box(0.1, 0.04, 0.1, M(0x65a8dc), 0.58, 1.78, -0.58);
box(0.1, 0.04, 0.1, M(0x68aa78), 0.72, 1.78, -0.58);
// Repair robot
const robot = group(1.75, 1.74, -0.3);
box(0.57, 0.55, 0.45, M(0x75a9b2), 0, 0.36, 0, robot);
box(0.63, 0.43, 0.48, M(0xe2c58d), 0, 0.84, 0, robot);
box(0.09, 0.24, 0.09, M(0x60777b), 0, 1.15, 0, robot);
box(0.14, 0.14, 0.14, M(0xe97962), 0, 1.32, 0, robot);
box(0.1, 0.13, 0.025, M(0x263a40), -0.16, 0.88, 0.252, robot);
box(0.1, 0.13, 0.025, M(0x263a40), 0.16, 0.88, 0.252, robot);
box(0.22, 0.025, 0.025, M(0x263a40), 0, 0.73, 0.252, robot);
box(0.16, 0.23, 0.16, M(0x536d72), -0.38, 0.4, 0, robot);
box(0.16, 0.23, 0.16, M(0x536d72), 0.38, 0.4, 0, robot);
box(0.19, 0.15, 0.25, M(0x536d72), -0.17, 0.04, 0, robot);
box(0.19, 0.15, 0.25, M(0x536d72), 0.17, 0.04, 0, robot);
// Toolbox
const toolbox = group(2.4, 1.76, 0.72);
box(0.65, 0.29, 0.42, M(0xe97962), 0, 0.14, 0, toolbox);
box(0.67, 0.08, 0.44, M(0xc45f4d), 0, 0.33, 0, toolbox);
box(0.25, 0.045, 0.07, M(0x74483c), 0, 0.43, 0, toolbox);
box(0.08, 0.19, 0.44, M(0xb95143), -0.31, 0.14, 0, toolbox);
box(0.08, 0.19, 0.44, M(0xb95143), 0.31, 0.14, 0, toolbox);
// Shared tool tray
const tray = group(0.12, 1.75, 1.07);
box(1.38, 0.08, 0.47, M(0x9b6946), 0, 0, 0, tray);
box(1.38, 0.12, 0.06, M(0xb47b52), 0, 0.09, 0.22, tray);
box(1.38, 0.12, 0.06, M(0xb47b52), 0, 0.09, -0.22, tray);
box(0.06, 0.12, 0.45, M(0xb47b52), -0.67, 0.09, 0, tray);
box(0.06, 0.12, 0.45, M(0xb47b52), 0.67, 0.09, 0, tray);
box(0.24, 0.08, 0.24, M(0xefb64f), 0.35, 0.09, 0, tray);
box(0.14, 0.1, 0.14, M(0x65a8dc), -0.28, 0.1, 0.03, tray);
const sharedLabel = makeLabel("SHARED TOOLS", "#34474b", 1.4);
sharedLabel.position.set(0.12, 2.42, 1.17);
scene.add(sharedLabel);
// Voxel family
const people = [];
function createPerson({
name,
role,
position,
target,
shirt,
pants,
hair,
skin = 0xdca77f,
scale = 1,
accessory = null
}) {
const root = group(position.x, 0, position.z);
root.scale.setScalar(scale);
const dx = target.x - position.x;
const dz = target.z - position.z;
root.rotation.y = Math.atan2(dx, dz);
const upper = group(0, 0, 0, root);
box(0.25, 0.17, 0.38, M(0x354248), -0.18, 0.1, 0.055, upper);
box(0.25, 0.17, 0.38, M(0x354248), 0.18, 0.1, 0.055, upper);
box(0.22, 0.66, 0.24, M(pants), -0.18, 0.51, 0, upper);
box(0.22, 0.66, 0.24, M(pants), 0.18, 0.51, 0, upper);
box(0.76, 0.76, 0.43, M(shirt), 0, 1.18, 0, upper);
box(0.22, 0.17, 0.22, M(skin), 0, 1.65, 0, upper);
const head = group(0, 2.04, 0, upper);
box(0.72, 0.69, 0.68, M(skin), 0, 0, 0, head);
box(0.075, 0.09, 0.025, M(0x263238), -0.14, 0.055, 0.35, head);
box(0.075, 0.09, 0.025, M(0x263238), 0.14, 0.055, 0.35, head);
box(0.17, 0.025, 0.02, M(0x8e5147), 0, -0.13, 0.35, head);
box(0.09, 0.09, 0.08, M(skin), 0, -0.015, 0.38, head);
box(0.75, 0.16, 0.7, M(hair), 0, 0.37, -0.01, head);
box(0.74, 0.38, 0.12, M(hair), 0, 0.16, -0.31, head);
if (accessory === "bun") {
box(0.31, 0.3, 0.28, M(hair), 0, 0.44, -0.39, head);
}
if (accessory === "glasses") {
box(0.21, 0.17, 0.028, M(0x394b50), -0.14, 0.055, 0.37, head);
box(0.21, 0.17, 0.028, M(0x394b50), 0.14, 0.055, 0.37, head);
box(0.1, 0.025, 0.03, M(0x394b50), 0, 0.055, 0.38, head);
}
if (accessory === "cap") {
box(0.79, 0.11, 0.75, M(0xe97962), 0, 0.45, -0.01, head);
box(0.58, 0.06, 0.28, M(0xc45f4d), 0, 0.42, 0.45, head);
}
const arms = [];
for (const side of [-1, 1]) {
const arm = group(side * 0.49, 1.48, 0, upper);
box(0.22, 0.22, 0.23, M(shirt), 0, -0.08, 0, arm);
box(0.19, 0.47, 0.21, M(skin), 0, -0.39, 0, arm);
box(0.21, 0.2, 0.22, M(skin), 0, -0.7, 0, arm);
arms.push(arm);
}
if (role === "artist") {
box(0.58, 0.59, 0.055, M(0xf3e6d2), 0, 1.12, 0.24, upper);
box(0.13, 0.57, 0.06, M(0xf3e6d2), -0.19, 1.13, 0.25, upper);
box(0.13, 0.57, 0.06, M(0xf3e6d2), 0.19, 1.13, 0.25, upper);
}
if (role === "repair") {
box(0.15, 0.65, 0.06, M(0x4f7890), -0.2, 1.18, 0.24, upper);
box(0.15, 0.65, 0.06, M(0x4f7890), 0.2, 1.18, 0.24, upper);
box(0.15, 0.13, 0.06, M(0x4f7890), 0, 1.2, 0.25, upper);
}
if (role === "helper") {
box(0.48, 0.46, 0.06, M(0x8d739a), 0, 1.13, 0.24, upper);
box(0.12, 0.51, 0.06, M(0x8d739a), -0.19, 1.15, 0.25, upper);
box(0.12, 0.51, 0.06, M(0x8d739a), 0.19, 1.15, 0.25, upper);
}
const person = {
name,
role,
root,
upper,
head,
arms,
phase: Math.random() * Math.PI * 2
};
people.push(person);
return person;
}
createPerson({
name: "Milo",
role: "homework",
position: new THREE.Vector3(-3.65, 0, 0.08),
target: new THREE.Vector3(-1.4, 0, 0),
shirt: 0x65a8dc,
pants: 0x3f5968,
hair: 0x4c342b,
skin: 0xe3b18a,
scale: 0.86,
accessory: "cap"
});
createPerson({
name: "June",
role: "artist",
position: new THREE.Vector3(-0.35, 0, -2.7),
target: new THREE.Vector3(0, 0, -0.6),
shirt: 0xefb64f,
pants: 0x76565a,
hair: 0x3c2b27,
skin: 0xc98e68,
scale: 1,
accessory: "bun"
});
createPerson({
name: "Sam",
role: "repair",
position: new THREE.Vector3(3.65, 0, 0.08),
target: new THREE.Vector3(1.5, 0, 0),
shirt: 0x68aa78,
pants: 0x526b7a,
hair: 0x49372f,
skin: 0xd39a70,
scale: 1.03,
accessory: "glasses"
});
createPerson({
name: "Pip",
role: "helper",
position: new THREE.Vector3(-0.55, 0, 2.65),
target: new THREE.Vector3(0.2, 0, 0.7),
shirt: 0x876b9b,
pants: 0x485c76,
hair: 0x684635,
skin: 0xe0aa83,
scale: 0.77
});
// Moving shared tools
function createPencil() {
const g = group();
box(0.09, 0.09, 0.55, M(0xefb64f), 0, 0, 0, g);
box(0.09, 0.09, 0.12, M(0xf1d6a8), 0, 0, 0.33, g);
box(0.09, 0.09, 0.08, M(0x394b50), 0, 0, 0.43, g);
box(0.095, 0.095, 0.12, M(0xe97962), 0, 0, -0.33, g);
return g;
}
function createWrench() {
const g = group();
const metal = M(0x9ba8a9, { metalness: 0.45, roughness: 0.42 });
box(0.1, 0.09, 0.62, metal, 0, 0, 0.02, g);
box(0.32, 0.1, 0.13, metal, 0, 0, -0.32, g);
box(0.1, 0.1, 0.19, metal, -0.11, 0, -0.41, g);
box(0.1, 0.1, 0.19, metal, 0.11, 0, -0.41, g);
box(0.12, 0.1, 0.16, M(0xe97962), 0, 0, 0.38, g);
return g;
}
const pencil = createPencil();
const wrench = createWrench();
scene.add(pencil, wrench);
const pencilCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-1.92, 1.94, 0.28),
new THREE.Vector3(-1.28, 2.48, 0.66),
new THREE.Vector3(-0.43, 2.37, 1.05),
new THREE.Vector3(0.08, 1.98, 1.08)
]);
const wrenchCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(1.85, 1.96, -0.06),
new THREE.Vector3(1.38, 2.5, 0.43),
new THREE.Vector3(0.65, 2.42, 0.98),
new THREE.Vector3(0.28, 1.98, 1.08)
]);
// UI state
let activeZone = "home";
let animationPlaying = true;
let exchangeBoost = 0;
let exchangeTime = 0;
let sceneTime = 0;
const zoneNumber = document.getElementById("zone-number");
const zoneTitle = document.getElementById("zone-title");
const zoneMeta = document.getElementById("zone-meta");
const zoneDescription = document.getElementById("zone-description");
const exchangeText = document.getElementById("exchange-text");
function setActiveZone(id, focus = true) {
activeZone = id;
const data = zones[id];
zoneNumber.textContent = data.index;
zoneNumber.style.background = `#${data.color.toString(16).padStart(6, "0")}`;
zoneTitle.textContent = data.title;
zoneMeta.textContent = data.meta;
zoneDescription.textContent = data.description;
document.querySelectorAll("[data-zone]").forEach(button => {
button.classList.toggle("active", button.dataset.zone === id);
});
for (const [key, mesh] of Object.entries(zoneMeshes)) {
mesh.material.emissiveIntensity = key === id ? 0.24 : 0.035;
}
if (focus) {
cameraState.targetGoal.set(
data.x * 0.32,
1.3,
data.z * 0.25
);
}
exchangeText.textContent = `${data.title} selected`;
}
document.querySelectorAll("[data-zone]").forEach(button => {
button.addEventListener("click", () => setActiveZone(button.dataset.zone, true));
});
document.getElementById("send-tools").addEventListener("click", () => {
exchangeBoost = 1.8;
exchangeText.textContent = "Pencil and wrench are on the move";
});
document.getElementById("reset-view").addEventListener("click", () => {
cameraState.targetYaw = 0.72;
cameraState.targetPitch = 0.62;
cameraState.targetZoom = 1;
cameraState.targetGoal.set(0, 1.15, 0);
});
const motionIcon = document.getElementById("motion-icon");
const motionLabel = document.getElementById("motion-label");
document.getElementById("toggle-motion").addEventListener("click", () => {
animationPlaying = !animationPlaying;
motionIcon.textContent = animationPlaying ? "Ⅱ" : "▶";
motionLabel.textContent = animationPlaying ? "Pause" : "Play";
exchangeText.textContent = animationPlaying
? "Tools are passing between zones"
: "Family time is paused";
});
setActiveZone("home", false);
// Direct camera controls — no external controls module.
const pointer = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
let pointerDown = false;
let dragging = false;
let pointerMoved = false;
let lastX = 0;
let lastY = 0;
function updatePointer(event) {
const rect = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function pickZone() {
raycaster.setFromCamera(pointer, camera);
const hit = raycaster.intersectObjects(hitTargets, false)[0];
return hit ? hit.object.userData.zone : null;
}
canvas.addEventListener("pointerdown", event => {
pointerDown = true;
dragging = false;
pointerMoved = false;
lastX = event.clientX;
lastY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", event => {
updatePointer(event);
if (pointerDown) {
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
if (Math.abs(dx) + Math.abs(dy) > 2) {
dragging = true;
pointerMoved = true;
}
if (event.shiftKey || event.metaKey) {
const right = new THREE.Vector3(Math.cos(cameraState.yaw), 0, -Math.sin(cameraState.yaw));
const forward = new THREE.Vector3(-Math.sin(cameraState.yaw), 0, -Math.cos(cameraState.yaw));
const scale = 0.012 / cameraState.zoom;
cameraState.targetGoal.addScaledVector(right, -dx * scale);
cameraState.targetGoal.addScaledVector(forward, -dy * scale);
} else {
cameraState.targetYaw -= dx * 0.006;
cameraState.targetPitch = THREE.MathUtils.clamp(
cameraState.targetPitch + dy * 0.0045,
0.28,
1.05
);
}
lastX = event.clientX;
lastY = event.clientY;
} else {
canvas.style.cursor = pickZone() ? "pointer" : "grab";
}
});
canvas.addEventListener("pointerup", event => {
updatePointer(event);
if (!pointerMoved) {
const id = pickZone();
if (id) setActiveZone(id, true);
}
pointerDown = false;
dragging = false;
canvas.style.cursor = "grab";
canvas.releasePointerCapture(event.pointerId);
});
canvas.addEventListener("pointercancel", () => {
pointerDown = false;
dragging = false;
});
canvas.addEventListener(
"wheel",
event => {
event.preventDefault();
cameraState.targetZoom = THREE.MathUtils.clamp(
cameraState.targetZoom - event.deltaY * 0.001,
0.65,
1.85
);
},
{ passive: false }
);
canvas.style.cursor = "grab";
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
renderer.setSize(width, height, false);
const verticalSize = Math.max(9.4, 11.1 / aspect);
camera.left = (-verticalSize * aspect) / 2;
camera.right = (verticalSize * aspect) / 2;
camera.top = verticalSize / 2;
camera.bottom = -verticalSize / 2;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
resize();
const tempPoint = new THREE.Vector3();
const tempTangent = new THREE.Vector3();
const forwardAxis = new THREE.Vector3(0, 0, 1);
function animateTool(tool, curve, phase) {
const u = 0.5 - 0.5 * Math.cos(exchangeTime + phase);
curve.getPoint(u, tempPoint);
curve.getTangent(u, tempTangent).normalize();
tool.position.copy(tempPoint);
tool.quaternion.setFromUnitVectors(forwardAxis, tempTangent);
tool.rotateZ(sceneTime * 1.3 + phase);
}
function animatePeople(time) {
for (const person of people) {
person.upper.position.y = Math.sin(time * 2 + person.phase) * 0.012;
person.head.rotation.y = Math.sin(time * 1.1 + person.phase) * 0.075;
person.head.rotation.z = Math.sin(time * 0.8 + person.phase) * 0.025;
const [left, right] = person.arms;
if (person.role === "homework") {
left.rotation.x = -0.48 + Math.sin(time * 2 + person.phase) * 0.05;
right.rotation.x = -0.86 + Math.sin(time * 5.2 + person.phase) * 0.14;
right.rotation.z = -0.12;
} else if (person.role === "artist") {
left.rotation.x = -0.75 + Math.sin(time * 2.2 + person.phase) * 0.06;
right.rotation.x = -0.82 + Math.sin(time * 4.1 + person.phase) * 0.12;
left.rotation.z = 0.11;
right.rotation.z = -0.1;
} else if (person.role === "repair") {
left.rotation.x = -0.58 + Math.sin(time * 1.8 + person.phase) * 0.05;
right.rotation.x = -0.93 + Math.sin(time * 3.4 + person.phase) * 0.11;
right.rotation.z = -0.2;
} else {
left.rotation.x = -0.54 + Math.sin(time * 2.4 + person.phase) * 0.08;
right.rotation.x = -0.68 + Math.sin(time * 3.1 + person.phase) * 0.13;
}
}
}
let previous = performance.now();
function render(now) {
requestAnimationFrame(render);
const dt = Math.min((now - previous) / 1000, 0.05);
previous = now;
if (animationPlaying) {
sceneTime += dt;
exchangeTime += dt * (0.52 + exchangeBoost * 0.75);
exchangeBoost = Math.max(0, exchangeBoost - dt);
}
animatePeople(sceneTime);
animateTool(pencil, pencilCurve, 0.3);
animateTool(wrench, wrenchCurve, 2.25);
cameraState.yaw += (cameraState.targetYaw - cameraState.yaw) * 0.08;
cameraState.pitch += (cameraState.targetPitch - cameraState.pitch) * 0.08;
cameraState.zoom += (cameraState.targetZoom - cameraState.zoom) * 0.08;
cameraState.target.lerp(cameraState.targetGoal, 0.075);
const distance = 15;
const horizontal = Math.cos(cameraState.pitch) * distance;
camera.position.set(
cameraState.target.x + Math.sin(cameraState.yaw) * horizontal,
cameraState.target.y + Math.sin(cameraState.pitch) * distance,
cameraState.target.z + Math.cos(cameraState.yaw) * horizontal
);
camera.lookAt(cameraState.target);
camera.zoom = cameraState.zoom;
camera.updateProjectionMatrix();
renderer.render(scene, camera);
}
requestAnimationFrame(render);
requestAnimationFrame(() => {
const loading = document.getElementById("loading");
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 600);
});
</script>
</body>
</html>
```