Prompt specification
Build or customize the Three.js 3D scene "Outdoor booth moves indoors" 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: Outdoor booth moves indoors
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/outdoor-booth-moves-indoors-x3858
Scene Description Prompt:
Rain sends a voxel festival booth indoors: pack, carry, and reassemble every component in a hall. One HTML scene using Three.js from cdnjs.
Working Three.js Starter (outdoor-booth-moves-indoors-x3858):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voxel Festival: Indoor Rain Rescue</title>
<style>
:root {
color-scheme: dark;
--ink: #eef8ff;
--muted: #91a8bb;
--panel: rgba(8, 18, 30, 0.82);
--line: rgba(163, 213, 235, 0.18);
--cyan: #64e5f2;
--orange: #ff9d45;
--pink: #ff5d91;
--green: #b6ef68;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #08121e;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
#app {
position: fixed;
inset: 0;
}
.topbar {
position: fixed;
z-index: 5;
top: 22px;
left: 24px;
right: 24px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 18px;
pointer-events: none;
}
.brand {
max-width: 430px;
padding: 16px 18px;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(14px);
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 6px;
color: var(--cyan);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 7px;
height: 7px;
content: "";
border-radius: 2px;
background: var(--green);
box-shadow: 0 0 12px var(--green);
}
h1 {
margin: 0;
font-size: clamp(21px, 3vw, 34px);
line-height: 1.04;
letter-spacing: -0.04em;
}
.subtitle {
margin: 8px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.weather {
min-width: 190px;
padding: 14px 16px;
border: 1px solid rgba(100, 229, 242, 0.24);
border-radius: 14px;
background: rgba(7, 30, 47, 0.8);
backdrop-filter: blur(14px);
pointer-events: auto;
}
.weather-label {
color: #8eb3c5;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.weather-value {
display: flex;
align-items: center;
gap: 10px;
margin-top: 7px;
font-size: 14px;
font-weight: 750;
}
.rain-icon {
color: var(--cyan);
font-size: 20px;
}
.manifest {
position: fixed;
z-index: 5;
top: 145px;
right: 24px;
width: 220px;
padding: 15px;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
backdrop-filter: blur(14px);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}
.manifest-title {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.count {
color: var(--green);
}
.manifest-list {
display: grid;
gap: 5px;
}
.manifest-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
min-height: 25px;
padding: 4px 7px;
border-radius: 7px;
color: #7890a3;
font-size: 11px;
transition: 180ms ease;
}
.manifest-row .name {
display: flex;
align-items: center;
gap: 7px;
}
.manifest-row .box {
width: 10px;
height: 10px;
border: 1px solid #60778a;
border-radius: 2px;
}
.manifest-row .state {
font-size: 8px;
font-weight: 900;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.manifest-row.packed {
color: #bed2df;
background: rgba(100, 229, 242, 0.05);
}
.manifest-row.packed .box {
border-color: var(--cyan);
background: rgba(100, 229, 242, 0.25);
}
.manifest-row.packed .state {
color: var(--cyan);
}
.manifest-row.placed {
color: #d9ffd0;
background: rgba(182, 239, 104, 0.07);
}
.manifest-row.placed .box {
border-color: var(--green);
background: var(--green);
box-shadow: 0 0 9px rgba(182, 239, 104, 0.45);
}
.manifest-row.placed .state {
color: var(--green);
}
.timeline-panel {
position: fixed;
z-index: 6;
left: 24px;
right: 24px;
bottom: 20px;
display: grid;
grid-template-columns: minmax(220px, 1fr) minmax(320px, 1.7fr) auto;
align-items: center;
gap: 18px;
padding: 14px 16px;
border: 1px solid var(--line);
border-radius: 17px;
background: rgba(7, 16, 27, 0.88);
backdrop-filter: blur(16px);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}
.now-playing {
min-width: 0;
}
.phase {
color: var(--cyan);
font-size: 9px;
font-weight: 900;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.description {
overflow: hidden;
margin-top: 4px;
color: #a9bdca;
font-size: 11px;
text-overflow: ellipsis;
white-space: nowrap;
}
.scrubber-wrap {
display: grid;
gap: 9px;
}
.chapters {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 6px;
}
.chapter {
padding: 7px 5px;
border: 1px solid transparent;
border-radius: 8px;
background: rgba(255, 255, 255, 0.035);
color: #7891a4;
font: inherit;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.08em;
cursor: pointer;
transition: 160ms ease;
}
.chapter:hover {
color: white;
background: rgba(255, 255, 255, 0.07);
}
.chapter.active {
border-color: rgba(100, 229, 242, 0.4);
background: rgba(100, 229, 242, 0.1);
color: var(--cyan);
}
input[type="range"] {
width: 100%;
height: 4px;
margin: 0;
border-radius: 99px;
outline: none;
appearance: none;
background:
linear-gradient(
to right,
var(--cyan) 0%,
var(--cyan) var(--progress, 0%),
rgba(255, 255, 255, 0.12) var(--progress, 0%),
rgba(255, 255, 255, 0.12) 100%
);
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 12px;
height: 12px;
border: 2px solid #07111d;
border-radius: 3px;
appearance: none;
background: var(--cyan);
box-shadow: 0 0 10px rgba(100, 229, 242, 0.65);
}
input[type="range"]::-moz-range-thumb {
width: 10px;
height: 10px;
border: 2px solid #07111d;
border-radius: 3px;
background: var(--cyan);
}
.controls {
display: flex;
gap: 7px;
}
button.control {
min-width: 70px;
height: 38px;
padding: 0 12px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(255, 255, 255, 0.04);
color: #d9e8f0;
font: inherit;
font-size: 10px;
font-weight: 800;
cursor: pointer;
transition: 160ms ease;
}
button.control:hover {
border-color: rgba(100, 229, 242, 0.45);
color: var(--cyan);
background: rgba(100, 229, 242, 0.08);
}
.hint {
position: fixed;
z-index: 4;
left: 26px;
bottom: 112px;
color: rgba(204, 225, 237, 0.52);
font-size: 10px;
pointer-events: none;
}
@media (max-width: 800px) {
.manifest {
display: none;
}
.weather {
display: none;
}
.topbar {
left: 12px;
right: 12px;
top: 12px;
}
.brand {
padding: 12px 14px;
}
.timeline-panel {
left: 10px;
right: 10px;
bottom: 10px;
grid-template-columns: 1fr auto;
gap: 10px;
padding: 11px;
}
.scrubber-wrap {
grid-column: 1 / -1;
grid-row: 2;
}
.controls {
grid-column: 2;
grid-row: 1;
}
button.control {
min-width: 42px;
padding: 0 9px;
}
#autoButton {
display: none;
}
.hint {
display: none;
}
}
</style>
</head>
<body>
<div id="app"></div>
<div class="topbar">
<section class="brand">
<div class="eyebrow">Festival logistics // Bay 03</div>
<h1>Rain Check, Voxel Check.</h1>
<p class="subtitle">
One crate. Eleven components. One indoor festival booth.
</p>
</section>
<section class="weather">
<div class="weather-label">Loading conditions</div>
<div class="weather-value">
<span class="rain-icon">╱</span>
<span>Heavy rain outside</span>
</div>
</section>
</div>
<aside class="manifest">
<div class="manifest-title">
<span>Component manifest</span>
<span class="count" id="placedCount">0 / 11</span>
</div>
<div class="manifest-list" id="manifestList"></div>
</aside>
<div class="hint">Drag to orbit · Scroll to zoom · Space to pause</div>
<footer class="timeline-panel">
<div class="now-playing">
<div class="phase" id="phaseLabel">01 / PACK</div>
<div class="description" id="description">Rain incoming — stow every part.</div>
</div>
<div class="scrubber-wrap">
<div class="chapters">
<button class="chapter active" data-start="0">PACK</button>
<button class="chapter" data-start="5.8">CARRY</button>
<button class="chapter" data-start="10.8">REBUILD</button>
<button class="chapter" data-start="20.8">FEST</button>
</div>
<input
id="scrubber"
type="range"
min="0"
max="2400"
value="0"
aria-label="Scene timeline"
>
</div>
<div class="controls">
<button class="control" id="playButton">PAUSE</button>
<button class="control" id="replayButton">REPLAY</button>
<button class="control" id="autoButton">AUTO CAM</button>
</div>
</footer>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ---------------------------------------------------------------------
// Core
// ---------------------------------------------------------------------
const app = document.querySelector("#app");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x091522);
scene.fog = new THREE.Fog(0x091522, 14, 34);
const camera = new THREE.PerspectiveCamera(
47,
innerWidth / innerHeight,
0.1,
80
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
app.appendChild(renderer.domElement);
const COLORS = {
navy: 0x112538,
navy2: 0x193247,
steel: 0x30495c,
dark: 0x09121c,
wood: 0xb96f3e,
woodLight: 0xd99553,
woodDark: 0x78442e,
teal: 0x36b8ad,
tealDark: 0x167a7a,
cyan: 0x64e5f2,
orange: 0xff8d3d,
orangeLight: 0xffb74d,
pink: 0xff527f,
green: 0xb6ef68,
cream: 0xffe8b3,
blue: 0x6bb8ff
};
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0.02,
...options
});
const mats = {
navy: material(COLORS.navy),
navy2: material(COLORS.navy2),
steel: material(COLORS.steel, { metalness: 0.28, roughness: 0.48 }),
dark: material(COLORS.dark),
wood: material(COLORS.wood),
woodLight: material(COLORS.woodLight),
woodDark: material(COLORS.woodDark),
teal: material(COLORS.teal),
tealDark: material(COLORS.tealDark),
cyan: material(COLORS.cyan, { emissive: 0x143e48, emissiveIntensity: 0.5 }),
orange: material(COLORS.orange),
orangeLight: material(COLORS.orangeLight),
pink: material(COLORS.pink),
green: material(COLORS.green),
cream: material(COLORS.cream),
blue: material(COLORS.blue)
};
const boxGeometry = new THREE.BoxGeometry(1, 1, 1);
function box(
width,
height,
depth,
mat,
x = 0,
y = 0,
z = 0,
parent = scene
) {
const mesh = new THREE.Mesh(boxGeometry, mat);
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function groupBox(group, width, height, depth, mat, x = 0, y = 0, z = 0) {
return box(width, height, depth, mat, x, y, z, group);
}
function makeTextTexture(title, subtitle, background = "#10283a") {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 384;
const ctx = canvas.getContext("2d");
ctx.imageSmoothingEnabled = false;
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = "#64e5f2";
ctx.lineWidth = 18;
ctx.strokeRect(20, 20, canvas.width - 40, canvas.height - 40);
ctx.fillStyle = "#ffe8b3";
ctx.font = "900 112px monospace";
ctx.textAlign = "center";
ctx.fillText(title, 512, 166);
ctx.fillStyle = "#91d7df";
ctx.font = "700 38px monospace";
ctx.fillText(subtitle, 512, 260);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.NearestFilter;
return texture;
}
// ---------------------------------------------------------------------
// Lighting
// ---------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xa6d8ff, 0x382d29, 1.7));
const keyLight = new THREE.DirectionalLight(0xffe1bb, 3.1);
keyLight.position.set(5, 10, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -13;
keyLight.shadow.camera.right = 13;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const rainLight = new THREE.PointLight(0x48bfff, 9, 12, 2);
rainLight.position.set(-8.2, 3.5, 0.5);
scene.add(rainLight);
const boothLight = new THREE.PointLight(0xffb864, 0, 9, 2);
boothLight.position.set(1.7, 2.7, -0.4);
scene.add(boothLight);
// ---------------------------------------------------------------------
// Festival hall
// ---------------------------------------------------------------------
const hall = new THREE.Group();
scene.add(hall);
box(18.5, 0.28, 12.5, mats.dark, 0, -0.18, 0, hall);
const floorMats = [
material(0x334452),
material(0x2c3d49),
material(0x3a4a55)
];
for (let ix = 0; ix < 12; ix++) {
for (let iz = 0; iz < 8; iz++) {
box(
1.46,
0.08,
1.46,
floorMats[(ix + iz) % floorMats.length],
-8.25 + ix * 1.5,
-0.02,
-5.25 + iz * 1.5,
hall
);
}
}
// Back and right walls.
box(18.5, 6.3, 0.35, mats.navy, 0, 3.05, -6.15, hall);
box(0.35, 6.3, 12.5, mats.navy2, 9.15, 3.05, 0, hall);
// Left wall with a wide loading-door opening.
box(0.35, 6.3, 4.1, mats.navy2, -9.15, 3.05, -4.1, hall);
box(0.35, 6.3, 2.6, mats.navy2, -9.15, 3.05, 4.7, hall);
box(0.35, 1.45, 5.8, mats.navy2, -9.15, 5.58, 1.05, hall);
// Door frame and rainy blue recess.
box(0.48, 4.95, 0.25, mats.steel, -8.92, 2.45, -1.75, hall);
box(0.48, 4.95, 0.25, mats.steel, -8.92, 2.45, 3.85, hall);
box(0.48, 0.25, 5.85, mats.steel, -8.92, 4.92, 1.05, hall);
const outside = new THREE.Mesh(
new THREE.PlaneGeometry(5.6, 5.7),
new THREE.MeshBasicMaterial({ color: 0x173a54 })
);
outside.rotation.y = Math.PI / 2;
outside.position.set(-9.38, 2.4, 1.05);
hall.add(outside);
// Back-wall windows.
const windowMat = new THREE.MeshStandardMaterial({
color: 0x8bcfee,
emissive: 0x315d73,
emissiveIntensity: 1.2,
roughness: 0.3
});
for (const x of [-5.7, -1.9, 2.0, 5.8]) {
box(2.6, 1.65, 0.09, windowMat, x, 3.95, -5.94, hall);
box(0.12, 1.85, 0.18, mats.steel, x, 3.95, -5.83, hall);
box(2.8, 0.12, 0.18, mats.steel, x, 3.95, -5.83, hall);
}
// Structural columns and roof beams.
for (const x of [-7.5, -3.6, 0.3, 4.2, 8.1]) {
box(0.42, 6.1, 0.5, mats.steel, x, 3, -5.72, hall);
box(0.76, 0.28, 0.72, mats.dark, x, 0.15, -5.55, hall);
}
for (const z of [-3.7, 0.5, 4.6]) {
box(17.7, 0.32, 0.34, mats.steel, 0, 5.85, z, hall);
}
// Hanging lamps.
for (const x of [-6, -1.5, 3, 7]) {
box(0.045, 0.9, 0.045, mats.dark, x, 5.35, -1.4, hall);
box(1.1, 0.22, 0.65, mats.steel, x, 4.85, -1.4, hall);
box(0.85, 0.08, 0.48, material(0xffdd9a, {
emissive: 0xffa85c,
emissiveIntensity: 1.7
}), x, 4.72, -1.4, hall);
}
// Wall signage.
const hallSign = new THREE.Mesh(
new THREE.PlaneGeometry(6.4, 2.4),
new THREE.MeshBasicMaterial({
map: makeTextTexture("VOXEL HALL", "RAIN CHECK // FESTIVAL CREW")
})
);
hallSign.position.set(0.2, 3.45, -5.9);
hall.add(hallSign);
const baySign = new THREE.Mesh(
new THREE.PlaneGeometry(4.7, 1.15),
new THREE.MeshBasicMaterial({
map: makeTextTexture("BAY 03", "RAIN-SAFE LOADING", "#153a4e")
})
);
baySign.rotation.y = Math.PI / 2;
baySign.position.set(-8.88, 5.42, 1.05);
hall.add(baySign);
// Wet loading mat and puddle.
const wetMat = new THREE.Mesh(
new THREE.PlaneGeometry(4.3, 5.2),
new THREE.MeshStandardMaterial({
color: 0x27516b,
roughness: 0.16,
metalness: 0.22,
transparent: true,
opacity: 0.82
})
);
wetMat.rotation.x = -Math.PI / 2;
wetMat.position.set(-7.05, 0.035, 1.0);
hall.add(wetMat);
// Yellow route markers.
for (let i = 0; i < 7; i++) {
box(0.65, 0.035, 0.12, mats.orangeLight, -7 + i * 0.9, 0.04, 3.3, hall);
}
// Storage props.
for (let i = 0; i < 3; i++) {
const crate = new THREE.Group();
crate.position.set(6.4 + (i % 2) * 1.15, 0.4 + Math.floor(i / 2) * 0.85, -4.35);
hall.add(crate);
groupBox(crate, 1, 0.8, 1, i % 2 ? mats.woodDark : mats.wood, 0, 0, 0);
groupBox(crate, 1.08, 0.1, 1.08, mats.woodLight, 0, 0.35, 0);
groupBox(crate, 0.12, 0.88, 1.08, mats.woodLight, -0.3, 0, 0);
groupBox(crate, 0.12, 0.88, 1.08, mats.woodLight, 0.3, 0, 0);
}
// ---------------------------------------------------------------------
// Rain and puddle splashes
// ---------------------------------------------------------------------
const rainCount = 260;
const rainPositions = new Float32Array(rainCount * 6);
const rainData = [];
for (let i = 0; i < rainCount; i++) {
rainData.push({
x: -9.9 + Math.random() * 4.25,
y: Math.random() * 8,
z: -4.9 + Math.random() * 9.8,
speed: 0.65 + Math.random() * 0.8,
length: 0.25 + Math.random() * 0.45
});
}
const rainGeometry = new THREE.BufferGeometry();
rainGeometry.setAttribute(
"position",
new THREE.BufferAttribute(rainPositions, 3)
);
const rain = new THREE.LineSegments(
rainGeometry,
new THREE.LineBasicMaterial({
color: 0x8fe7ff,
transparent: true,
opacity: 0.52,
depthWrite: false
})
);
scene.add(rain);
const splashGeometry = new THREE.RingGeometry(0.13, 0.16, 20);
const splashes = [];
for (let i = 0; i < 14; i++) {
const splashMat = new THREE.MeshBasicMaterial({
color: 0x82dfff,
transparent: true,
opacity: 0,
side: THREE.DoubleSide,
depthWrite: false
});
const splash = new THREE.Mesh(splashGeometry, splashMat);
splash.rotation.x = -Math.PI / 2;
splash.position.set(
-8.7 + Math.random() * 3.2,
0.075,
-1.25 + Math.random() * 4.4
);
splash.userData.seed = Math.random();
scene.add(splash);
splashes.push(splash);
}
// ---------------------------------------------------------------------
// Voxel carrier robot
// ---------------------------------------------------------------------
const robot = new THREE.Group();
robot.position.set(-7.2, 0, 0.55);
scene.add(robot);
groupBox(robot, 0.8, 0.82, 0.78, mats.teal, 0, 1.25, 0);
groupBox(robot, 0.58, 0.2, 0.82, mats.cream, 0, 1.73, 0);
groupBox(robot, 0.64, 0.58, 0.66, mats.cream, 0.02, 2.05, 0);
groupBox(robot, 0.09, 0.12, 0.09, mats.steel, 0.02, 2.42, 0);
groupBox(robot, 0.17, 0.17, 0.17, mats.pink, 0.02, 2.55, 0);
// Face on the +X side, because the robot walks toward +X.
groupBox(robot, 0.055, 0.13, 0.13, mats.cyan, 0.36, 2.11, -0.16);
groupBox(robot, 0.055, 0.13, 0.13, mats.cyan, 0.36, 2.11, 0.16);
groupBox(robot, 0.045, 0.06, 0.27, mats.dark, 0.38, 1.93, 0);
// Backpack and belt.
groupBox(robot, 0.42, 0.7, 0.7, mats.pink, -0.54, 1.28, 0);
groupBox(robot, 0.9, 0.12, 0.84, mats.orange, 0, 0.9, 0);
const legPivots = [];
for (const z of [-0.22, 0.22]) {
const pivot = new THREE.Group();
pivot.position.set(0, 0.87, z);
robot.add(pivot);
groupBox(pivot, 0.32, 0.58, 0.29, mats.navy, 0, -0.3, 0);
groupBox(pivot, 0.48, 0.18, 0.34, mats.dark, 0.09, -0.64, 0);
legPivots.push(pivot);
}
const armPivots = [];
for (const z of [-0.57, 0.57]) {
const pivot = new THREE.Group();
pivot.position.set(0.08, 1.62, z);
robot.add(pivot);
groupBox(pivot, 0.28, 0.58, 0.28, mats.orange, 0.17, -0.25, 0);
groupBox(pivot, 0.3, 0.24, 0.3, mats.cream, 0.22, -0.6, 0);
armPivots.push(pivot);
}
// ---------------------------------------------------------------------
// Carry crate
// ---------------------------------------------------------------------
const crate = new THREE.Group();
scene.add(crate);
groupBox(crate, 1.8, 0.13, 1.4, mats.navy, 0, -0.63, 0);
groupBox(crate, 0.14, 1.18, 1.4, mats.tealDark, -0.83, -0.04, 0);
groupBox(crate, 0.14, 1.18, 1.4, mats.tealDark, 0.83, -0.04, 0);
groupBox(crate, 1.8, 1.18, 0.14, mats.tealDark, 0, -0.04, -0.63);
groupBox(crate, 1.8, 0.78, 0.14, mats.teal, 0, -0.25, 0.63);
// Corner reinforcements and crate label.
for (const x of [-0.79, 0.79]) {
for (const z of [-0.63, 0.63]) {
groupBox(crate, 0.2, 1.25, 0.2, mats.orange, x, -0.03, z);
}
}
const crateLabel = new THREE.Mesh(
new THREE.PlaneGeometry(1.08, 0.35),
new THREE.MeshBasicMaterial({
map: makeTextTexture("VOX KIT", "11 / 11", "#174b55")
})
);
crateLabel.position.set(0, -0.1, 0.71);
crate.add(crateLabel);
const lidPivot = new THREE.Group();
lidPivot.position.set(-0.9, 0.58, 0);
crate.add(lidPivot);
groupBox(lidPivot, 1.85, 0.12, 1.44, mats.navy, 0.92, 0, 0);
groupBox(lidPivot, 0.12, 0.15, 1.46, mats.orange, 1.77, 0, 0);
groupBox(lidPivot, 0.14, 0.15, 1.46, mats.orange, 0.12, 0, 0);
// ---------------------------------------------------------------------
// Booth components
// ---------------------------------------------------------------------
const booth = new THREE.Vector3(1.7, 0, -1.6);
function createDeck() {
const g = new THREE.Group();
scene.add(g);
for (let i = 0; i < 10; i++) {
groupBox(
g,
4.3,
0.15,
0.245,
i % 2 ? mats.woodLight : mats.wood,
0,
0,
(i - 4.5) * 0.255
);
}
groupBox(g, 4.35, 0.21, 0.12, mats.woodDark, 0, 0, 1.24);
groupBox(g, 4.35, 0.21, 0.12, mats.woodDark, 0, 0, -1.24);
return g;
}
function createPost() {
const g = new THREE.Group();
scene.add(g);
groupBox(g, 0.23, 2.62, 0.23, mats.teal, 0, 0, 0);
groupBox(g, 0.39, 0.18, 0.39, mats.cream, 0, -1.3, 0);
groupBox(g, 0.3, 0.16, 0.3, mats.orange, 0, 1.28, 0);
return g;
}
function createBackdrop() {
const g = new THREE.Group();
scene.add(g);
groupBox(g, 3.8, 1.85, 0.12, mats.navy, 0, 0, 0);
for (let x = 0; x < 10; x++) {
for (let y = 0; y < 5; y++) {
const palette = [mats.pink, mats.teal, mats.orange, mats.green];
groupBox(
g,
0.32,
0.3,
0.055,
palette[(x + y * 2) % palette.length],
(x - 4.5) * 0.36,
(y - 2) * 0.35,
0.085
);
}
}
return g;
}
function createCounter() {
const g = new THREE.Group();
scene.add(g);
groupBox(g, 3.15, 0.84, 0.68, mats.pink, 0, 0, 0);
groupBox(g, 3.35, 0.16, 0.82, mats.cream, 0, 0.49, 0.02);
groupBox(g, 1.25, 0.38, 0.08, mats.dark, -0.45, 0.05, 0.37);
groupBox(g, 0.62, 0.12, 0.08, mats.cyan, -0.45, 0.05, 0.42);
groupBox(g, 0.44, 0.44, 0.08, mats.orange, 1.03, -0.03, 0.38);
groupBox(g, 0.25, 0.09, 0.08, mats.cream, 1.03, -0.03, 0.43);
return g;
}
function createRoof() {
const g = new THREE.Group();
scene.add(g);
for (let x = 0; x < 8; x++) {
for (let z = 0; z < 6; z++) {
groupBox(
g,
0.51,
0.16,
0.41,
(x + z) % 2 ? mats.orange : mats.orangeLight,
(x - 3.5) * 0.53,
0,
(z - 2.5) * 0.43
);
}
}
groupBox(g, 4.35, 0.27, 0.13, mats.pink, 0, -0.08, 1.29);
groupBox(g, 4.35, 0.27, 0.13, mats.tealDark, 0, -0.08, -1.29);
return g;
}
function createBunting() {
const g = new THREE.Group();
scene.add(g);
groupBox(g, 4.0, 0.075, 0.075, mats.cream, 0, 0.18, 0);
const palette = [mats.pink, mats.orange, mats.green, mats.cyan];
for (let i = 0; i < 12; i++) {
const x = (i - 5.5) * 0.32;
const y = 0.18 - Math.abs(i - 5.5) * 0.025;
groupBox(g, 0.27, 0.25, 0.075, palette[i % palette.length], x, y - 0.12, 0);
groupBox(g, 0.15, 0.14, 0.075, palette[i % palette.length], x, y - 0.29, 0);
}
return g;
}
function createLanterns() {
const g = new THREE.Group();
scene.add(g);
for (const x of [-1.15, 0, 1.15]) {
groupBox(g, 0.045, 0.42, 0.045, mats.dark, x, 0.38, 0);
groupBox(g, 0.29, 0.3, 0.29, mats.cream, x, 0, 0);
groupBox(
g,
0.22,
0.23,
0.31,
material(0xffc65f, {
emissive: 0xff9a32,
emissiveIntensity: 1.4
}),
x,
0,
0
);
groupBox(g, 0.37, 0.08, 0.37, mats.orange, x, 0.19, 0);
groupBox(g, 0.37, 0.08, 0.37, mats.orange, x, -0.19, 0);
}
return g;
}
function createSign() {
const g = new THREE.Group();
scene.add(g);
groupBox(g, 2.7, 0.98, 0.16, mats.orange, 0, 0, 0);
groupBox(g, 2.42, 0.76, 0.18, mats.navy, 0, 0, 0.03);
const signTexture = makeTextTexture("VOXEL", "FESTIVAL", "#123047");
const signFace = new THREE.Mesh(
new THREE.PlaneGeometry(2.22, 0.62),
new THREE.MeshBasicMaterial({ map: signTexture })
);
signFace.position.z = 0.125;
g.add(signFace);
return g;
}
const pieces = [];
function addPiece(name, group, start, target, startScale = 1) {
group.position.set(...start);
group.scale.setScalar(startScale);
pieces.push({
name,
group,
start: new THREE.Vector3(...start),
target: new THREE.Vector3(...target),
startScale,
packedScale: 0.16,
startRotation: new THREE.Euler(
(Math.random() - 0.5) * 0.18,
(Math.random() - 0.5) * 0.45,
name.includes("post") ? Math.PI / 2 : (Math.random() - 0.5) * 0.08
),
packedRotation: new THREE.Euler(
(Math.random() - 0.5) * 0.25,
(Math.random() - 0.5) * 0.45,
(Math.random() - 0.5) * 0.25
),
targetRotation: new THREE.Euler(0, 0, 0)
});
}
addPiece(
"Wooden deck",
createDeck(),
[-7.25, 0.12, 2.55],
[booth.x, 0.09, booth.z]
);
addPiece(
"Front-left post",
createPost(),
[-8.35, 0.3, -1.6],
[booth.x - 1.82, 1.46, booth.z + 1.02]
);
addPiece(
"Front-right post",
createPost(),
[-7.7, 0.3, -0.85],
[booth.x + 1.82, 1.46, booth.z + 1.02]
);
addPiece(
"Back-left post",
createPost(),
[-6.85, 0.3, -1.75],
[booth.x - 1.82, 1.46, booth.z - 1.02]
);
addPiece(
"Back-right post",
createPost(),
[-6.4, 0.3, -0.8],
[booth.x + 1.82, 1.46, booth.z - 1.02]
);
addPiece(
"Pixel backdrop",
createBackdrop(),
[-8.05, 0.48, 0.25],
[booth.x, 1.62, booth.z - 1.08],
0.72
);
addPiece(
"Ticket counter",
createCounter(),
[-7.45, 0.42, 0.95],
[booth.x, 0.68, booth.z + 0.72]
);
addPiece(
"Striped canopy",
createRoof(),
[-7.35, 0.32, -1.35],
[booth.x, 2.91, booth.z],
0.72
);
addPiece(
"Festival bunting",
createBunting(),
[-6.15, 0.22, 2.75],
[booth.x, 2.55, booth.z + 1.34],
0.82
);
addPiece(
"Pixel lanterns",
createLanterns(),
[-8.25, 0.25, 1.9],
[booth.x, 2.38, booth.z + 1.3]
);
addPiece(
"Festival sign",
createSign(),
[-6.7, 0.22, -2.2],
[booth.x, 3.68, booth.z + 1.1],
0.72
);
// Miniature positions inside the crate.
const packedSlots = [
[-0.57, 0.28, -0.37],
[0.12, 0.30, -0.38],
[0.56, 0.28, -0.30],
[-0.55, 0.18, 0.35],
[-0.10, 0.17, 0.42],
[0.46, 0.08, 0.18],
[-0.38, -0.14, 0.03],
[0.05, -0.08, -0.10],
[0.55, -0.17, 0.43],
[-0.60, -0.18, -0.38],
[0.18, 0.39, 0.25]
].map((p) => new THREE.Vector3(...p));
// ---------------------------------------------------------------------
// Confetti
// ---------------------------------------------------------------------
const confettiCount = 72;
const confettiGeometry = new THREE.BoxGeometry(0.09, 0.09, 0.035);
const confettiMaterial = material(0xffffff, {
roughness: 0.55,
metalness: 0.05
});
const confetti = new THREE.InstancedMesh(
confettiGeometry,
confettiMaterial,
confettiCount
);
confetti.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
confetti.visible = false;
scene.add(confetti);
const confettiData = [];
const confettiColors = [
new THREE.Color(COLORS.pink),
new THREE.Color(COLORS.orange),
new THREE.Color(COLORS.green),
new THREE.Color(COLORS.cyan),
new THREE.Color(COLORS.cream)
];
for (let i = 0; i < confettiCount; i++) {
confettiData.push({
x: (Math.random() - 0.5) * 5.2,
z: (Math.random() - 0.5) * 4.4,
offset: Math.random(),
speed: 0.12 + Math.random() * 0.15,
spin: (Math.random() - 0.5) * 8,
angle: Math.random() * Math.PI * 2
});
confetti.setColorAt(i, confettiColors[i % confettiColors.length]);
}
confetti.instanceColor.needsUpdate = true;
const confettiDummy = new THREE.Object3D();
// ---------------------------------------------------------------------
// Timeline
// ---------------------------------------------------------------------
const PACK_END = 5.8;
const CARRY_END = 10.8;
const BUILD_START = 10.8;
const BUILD_END = 20.8;
const TOTAL = 24;
let timelineTime = 0;
let playing = true;
let autoCamera = true;
const phaseLabel = document.querySelector("#phaseLabel");
const description = document.querySelector("#description");
const placedCount = document.querySelector("#placedCount");
const scrubber = document.querySelector("#scrubber");
const playButton = document.querySelector("#playButton");
const replayButton = document.querySelector("#replayButton");
const autoButton = document.querySelector("#autoButton");
const chapterButtons = [...document.querySelectorAll(".chapter")];
const manifestRows = [];
pieces.forEach((piece, index) => {
const row = document.createElement("div");
row.className = "manifest-row";
row.innerHTML = `
<span class="name"><span class="box"></span>${piece.name}</span>
<span class="state">Loose</span>
`;
document.querySelector("#manifestList").appendChild(row);
manifestRows.push(row);
});
const clamp = THREE.MathUtils.clamp;
const lerp = THREE.MathUtils.lerp;
function smoothstep(a, b, value) {
const t = clamp((value - a) / (b - a), 0, 1);
return t * t * (3 - 2 * t);
}
function easeOutCubic(t) {
return 1 - Math.pow(1 - t, 3);
}
function easeInOutCubic(t) {
return t < 0.5
? 4 * t * t * t
: 1 - Math.pow(-2 * t + 2, 3) / 2;
}
function updatePieceTransforms(time) {
pieces.forEach((piece, index) => {
const packedPosition = crate.position.clone().add(packedSlots[index]);
const group = piece.group;
if (time < PACK_END) {
const local = clamp((time - index * 0.38) / 1.05, 0, 1);
const eased = easeInOutCubic(local);
group.position.lerpVectors(piece.start, packedPosition, eased);
group.scale.setScalar(
lerp(piece.startScale, piece.packedScale, eased)
);
group.rotation.x = lerp(
piece.startRotation.x,
piece.packedRotation.x,
eased
);
group.rotation.y = lerp(
piece.startRotation.y,
piece.packedRotation.y,
eased
);
group.rotation.z = lerp(
piece.startRotation.z,
piece.packedRotation.z,
eased
);
} else if (time < BUILD_START) {
group.position.copy(packedPosition);
group.scale.setScalar(piece.packedScale);
group.rotation.set(
piece.packedRotation.x,
piece.packedRotation.y,
piece.packedRotation.z
);
} else {
const local = clamp(
(time - BUILD_START - index * 0.45) / 1.35,
0,
1
);
const eased = easeOutCubic(local);
group.position.lerpVectors(
packedPosition,
piece.target,
eased
);
group.scale.setScalar(
lerp(piece.packedScale, 1, eased)
);
group.rotation.x = lerp(
piece.packedRotation.x,
piece.targetRotation.x,
eased
);
group.rotation.y = lerp(
piece.packedRotation.y,
piece.targetRotation.y,
eased
);
group.rotation.z = lerp(
piece.packedRotation.z,
piece.targetRotation.z,
eased
);
if (local >= 1) {
group.position.copy(piece.target);
group.scale.setScalar(1);
}
}
});
}
function updateCarrier(time) {
let robotX = -7.2;
let walking = 0;
if (time >= PACK_END && time < CARRY_END) {
const carryT = smoothstep(PACK_END, CARRY_END, time);
robotX = lerp(-7.2, -3.15, carryT);
walking = carryT;
} else if (time >= CARRY_END) {
robotX = -3.15;
}
const walkCycle = time * 8.2;
const bob = walking > 0 ? Math.abs(Math.sin(walkCycle)) * 0.055 : 0;
robot.position.set(robotX, bob, 0.55);
robot.rotation.z = walking > 0 ? Math.sin(walkCycle * 0.5) * 0.018 : 0;
legPivots[0].rotation.z = Math.sin(walkCycle) * 0.42 * walking;
legPivots[1].rotation.z = -Math.sin(walkCycle) * 0.42 * walking;
armPivots[0].rotation.z = -0.45 - Math.sin(walkCycle) * 0.15 * walking;
armPivots[1].rotation.z = -0.45 + Math.sin(walkCycle) * 0.15 * walking;
if (time >= BUILD_END) {
armPivots[1].rotation.z = -1.9 + Math.sin(time * 4) * 0.18;
}
crate.position.set(robotX + 0.96, 1.12 + bob, 0.55);
let lidAngle = 1.18;
if (time > PACK_END - 0.85 && time < PACK_END) {
lidAngle = lerp(
1.18,
0,
smoothstep(PACK_END - 0.85, PACK_END, time)
);
} else if (time >= PACK_END && time < BUILD_START) {
lidAngle = 0;
} else if (time >= BUILD_START) {
lidAngle = lerp(
0,
1.18,
smoothstep(BUILD_START, BUILD_START + 0.65, time)
);
}
lidPivot.rotation.z = lidAngle;
boothLight.intensity =
lerp(0, 7.5, smoothstep(BUILD_START + 3, BUILD_END, time));
}
function updateConfetti(time) {
confetti.visible = time >= BUILD_START + 3.5;
if (!confetti.visible) return;
confettiData.forEach((data, index) => {
const life = (data.offset + time * data.speed) % 1;
confettiDummy.position.set(
booth.x + data.x + Math.sin(time * 1.4 + data.angle) * 0.25,
5.3 - life * 5.6,
booth.z + data.z
);
confettiDummy.rotation.set(
time * data.spin,
data.angle + time * data.spin * 0.7,
time * data.spin * 0.4
);
confettiDummy.updateMatrix();
confetti.setMatrixAt(index, confettiDummy.matrix);
});
confetti.instanceMatrix.needsUpdate = true;
}
function updateRain(dt, elapsed) {
rainData.forEach((drop, index) => {
drop.y -= dt * 8.5 * drop.speed;
drop.x -= dt * 0.65;
if (drop.y < -0.1) {
drop.y = 6.8 + Math.random() * 2;
drop.x = -9.9 + Math.random() * 4.25;
drop.z = -4.9 + Math.random() * 9.8;
}
const offset = index * 6;
rainPositions[offset] = drop.x;
rainPositions[offset + 1] = drop.y;
rainPositions[offset + 2] = drop.z;
rainPositions[offset + 3] = drop.x - 0.08;
rainPositions[offset + 4] = drop.y + drop.length;
rainPositions[offset + 5] = drop.z + 0.025;
});
rainGeometry.attributes.position.needsUpdate = true;
splashes.forEach((splash) => {
const life = (elapsed * 1.5 + splash.userData.seed) % 1;
splash.scale.setScalar(0.3 + life * 2.1);
splash.material.opacity = (1 - life) * 0.5;
});
}
// ---------------------------------------------------------------------
// Direct camera controls
// ---------------------------------------------------------------------
const orbit = {
target: new THREE.Vector3(-6.7, 1.15, 0.7),
yaw: 0.62,
pitch: 0.41,
distance: 10.5
};
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
autoCamera = false;
updateAutoButton();
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
orbit.yaw -= dx * 0.005;
orbit.pitch = clamp(orbit.pitch + dy * 0.004, 0.12, 1.05);
});
renderer.domElement.addEventListener("pointerup", (event) => {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
});
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
orbit.distance = clamp(
orbit.distance * Math.exp(event.deltaY * 0.001),
5.5,
19
);
autoCamera = false;
updateAutoButton();
}, { passive: false });
const cameraShots = {
pack: {
target: new THREE.Vector3(-6.7, 1.15, 0.7),
yaw: 0.62,
pitch: 0.41,
distance: 10.5
},
carry: {
target: new THREE.Vector3(-4.8, 1.05, 0.45),
yaw: 0.52,
pitch: 0.38,
distance: 10.4
},
build: {
target: new THREE.Vector3(0.05, 1.4, -0.65),
yaw: 0.47,
pitch: 0.39,
distance: 10.7
},
fest: {
target: new THREE.Vector3(1.55, 1.65, -1.35),
yaw: 0.45,
pitch: 0.36,
distance: 8.9
}
};
function getCameraShot(time) {
if (time < PACK_END) return cameraShots.pack;
if (time < CARRY_END) return cameraShots.carry;
if (time < BUILD_END) return cameraShots.build;
return cameraShots.fest;
}
function updateCamera(dt) {
if (autoCamera) {
const shot = getCameraShot(timelineTime);
const blend = 1 - Math.exp(-dt * 1.8);
orbit.target.lerp(shot.target, blend);
orbit.yaw = lerp(orbit.yaw, shot.yaw, blend);
orbit.pitch = lerp(orbit.pitch, shot.pitch, blend);
orbit.distance = lerp(orbit.distance, shot.distance, blend);
}
const horizontal = Math.cos(orbit.pitch) * orbit.distance;
camera.position.set(
orbit.target.x + Math.sin(orbit.yaw) * horizontal,
orbit.target.y + Math.sin(orbit.pitch) * orbit.distance,
orbit.target.z + Math.cos(orbit.yaw) * horizontal
);
camera.lookAt(orbit.target);
}
function updateAutoButton() {
autoButton.textContent = autoCamera ? "AUTO CAM" : "FREE CAM";
autoButton.style.color = autoCamera ? "#64e5f2" : "#ff9d45";
}
// ---------------------------------------------------------------------
// UI and input
// ---------------------------------------------------------------------
playButton.addEventListener("click", () => {
playing = !playing;
playButton.textContent = playing ? "PAUSE" : "PLAY";
});
replayButton.addEventListener("click", () => {
timelineTime = 0;
playing = true;
playButton.textContent = "PAUSE";
});
autoButton.addEventListener("click", () => {
autoCamera = !autoCamera;
updateAutoButton();
});
chapterButtons.forEach((button) => {
button.addEventListener("click", () => {
timelineTime = Number(button.dataset.start) + 0.01;
playing = true;
playButton.textContent = "PAUSE";
});
});
scrubber.addEventListener("input", () => {
timelineTime = Number(scrubber.value) / 100;
});
window.addEventListener("keydown", (event) => {
if (event.code === "Space" && event.target === document.body) {
event.preventDefault();
playing = !playing;
playButton.textContent = playing ? "PAUSE" : "PLAY";
}
});
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
function updateUI() {
let phaseIndex = 0;
let phaseName = "PACK";
let copy = "Rain incoming — stow every part.";
if (timelineTime >= PACK_END && timelineTime < CARRY_END) {
phaseIndex = 1;
phaseName = "CARRY";
copy = "Crate secured — crossing the festival hall.";
} else if (timelineTime >= CARRY_END && timelineTime < BUILD_END) {
phaseIndex = 2;
phaseName = "REBUILD";
copy = "Eleven components returning to their festival positions.";
} else if (timelineTime >= BUILD_END) {
phaseIndex = 3;
phaseName = "FEST";
copy = "Indoor ready — the voxel festival booth is complete.";
}
phaseLabel.textContent =
`0${phaseIndex + 1} / ${phaseName}`;
description.textContent = copy;
chapterButtons.forEach((button, index) => {
button.classList.toggle("active", index === phaseIndex);
});
scrubber.value = String(Math.floor(timelineTime * 100));
scrubber.style.setProperty(
"--progress",
`${(timelineTime / TOTAL) * 100}%`
);
let placed = 0;
pieces.forEach((piece, index) => {
const packProgress = clamp((timelineTime - index * 0.38) / 1.05, 0, 1);
const buildProgress = clamp(
(timelineTime - BUILD_START - index * 0.45) / 1.35,
0,
1
);
const row = manifestRows[index];
const state = row.querySelector(".state");
row.classList.remove("packed", "placed");
if (buildProgress >= 1) {
row.classList.add("placed");
state.textContent = "Placed";
placed++;
} else if (packProgress >= 1) {
row.classList.add("packed");
state.textContent = "Packed";
} else {
state.textContent = "Loose";
}
});
placedCount.textContent = `${placed} / ${pieces.length}`;
}
// ---------------------------------------------------------------------
// Render loop
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
let elapsed = 0;
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
elapsed += dt;
if (playing) {
timelineTime = Math.min(TOTAL, timelineTime + dt);
if (timelineTime >= TOTAL) {
playing = false;
playButton.textContent = "PLAY";
}
}
updateCarrier(timelineTime);
updatePieceTransforms(timelineTime);
updateConfetti(timelineTime);
updateRain(dt, elapsed);
updateCamera(dt);
updateUI();
renderer.render(scene, camera);
}
updateAutoButton();
animate();
</script>
</body>
</html>
```