Prompt specification
Build or customize the Three.js 3D scene "Neighborhood Stage Assembly 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: Neighborhood Stage Assembly Scene
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/neighborhood-stage-assembly-scene-x3711
Scene Description Prompt:
Voxel neighbors carry stage panels and position supports together, leaving the finished platform stably supported. Build one HTML file using Three.js from cdnjs.
Working Three.js Starter (neighborhood-stage-assembly-scene-x3711):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Voxel Neighbors — Stage Platform</title>
<style>
:root {
color-scheme: light;
--ink: #17334d;
--panel: rgba(255, 255, 255, 0.78);
--line: rgba(23, 51, 77, 0.14);
--accent: #ff8a47;
--green: #27a879;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #cce8f7;
color: var(--ink);
font-family:
Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body::after {
content: "";
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 50% 38%, transparent 45%, rgba(26, 63, 88, 0.1)),
linear-gradient(rgba(255,255,255,0.025) 50%, rgba(21,53,73,0.025) 50%);
background-size: auto, 4px 4px;
mix-blend-mode: multiply;
z-index: 4;
}
#scene {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
outline: none;
}
#scene:active {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
z-index: 5;
pointer-events: none;
}
.title-card {
position: absolute;
top: 22px;
left: 22px;
max-width: min(390px, calc(100vw - 44px));
padding: 16px 18px 15px;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 16px 45px rgba(31, 78, 102, 0.13);
backdrop-filter: blur(14px) saturate(1.2);
}
.eyebrow {
margin-bottom: 6px;
color: #3b738d;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(20px, 2.4vw, 29px);
line-height: 1.05;
letter-spacing: -0.045em;
}
.subtitle {
margin-top: 8px;
color: #557185;
font-size: 12px;
line-height: 1.45;
}
.legend {
display: flex;
gap: 14px;
margin-top: 12px;
color: #557185;
font-size: 10px;
font-weight: 700;
}
.legend span {
display: flex;
align-items: center;
gap: 6px;
}
.dot {
width: 8px;
height: 8px;
border-radius: 2px;
background: var(--accent);
box-shadow: 0 0 0 3px rgba(255, 138, 71, 0.14);
}
.dot.blue {
background: #4774d1;
box-shadow: 0 0 0 3px rgba(71, 116, 209, 0.14);
}
.completion {
position: absolute;
top: 24px;
right: 24px;
display: flex;
align-items: center;
gap: 10px;
padding: 11px 14px;
border: 1px solid rgba(39, 168, 121, 0.24);
border-radius: 14px;
background: rgba(238, 255, 247, 0.9);
color: #167556;
box-shadow: 0 12px 32px rgba(30, 119, 85, 0.14);
font-size: 11px;
font-weight: 850;
letter-spacing: 0.09em;
text-transform: uppercase;
opacity: 0;
transform: translateY(-12px) scale(0.95);
transition: opacity 0.45s ease, transform 0.45s cubic-bezier(.2,.8,.2,1);
}
.completion.visible {
opacity: 1;
transform: translateY(0) scale(1);
}
.check {
display: grid;
width: 23px;
height: 23px;
place-items: center;
border-radius: 7px;
background: var(--green);
color: white;
font-size: 14px;
}
.bottom {
position: absolute;
right: 22px;
bottom: 22px;
left: 22px;
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 16px;
}
.timeline-card {
width: min(430px, 70vw);
padding: 13px 15px 12px;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
box-shadow: 0 16px 45px rgba(31, 78, 102, 0.13);
backdrop-filter: blur(14px) saturate(1.2);
}
.timeline-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 9px;
}
#status {
overflow: hidden;
font-size: 11px;
font-weight: 800;
text-overflow: ellipsis;
white-space: nowrap;
}
#time {
flex: 0 0 auto;
color: #6c8494;
font-size: 10px;
font-variant-numeric: tabular-nums;
}
.track {
height: 6px;
overflow: hidden;
border-radius: 99px;
background: rgba(23, 51, 77, 0.1);
}
#progress {
width: 0;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, #4774d1, #27a879);
transition: width 0.1s linear;
}
.controls {
display: flex;
gap: 8px;
pointer-events: auto;
}
button {
min-height: 40px;
padding: 0 14px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(255, 255, 255, 0.84);
color: var(--ink);
box-shadow: 0 10px 28px rgba(31, 78, 102, 0.11);
backdrop-filter: blur(12px);
cursor: pointer;
font: inherit;
font-size: 11px;
font-weight: 800;
transition: transform 0.16s ease, background 0.16s ease;
}
button:hover {
background: white;
transform: translateY(-2px);
}
button:active {
transform: translateY(0);
}
.hint {
position: absolute;
bottom: 29px;
left: 50%;
padding: 8px 11px;
border-radius: 10px;
background: rgba(255, 255, 255, 0.58);
color: #638093;
font-size: 10px;
font-weight: 700;
transform: translateX(-50%);
backdrop-filter: blur(8px);
}
@media (max-width: 760px) {
.title-card {
top: 12px;
left: 12px;
padding: 13px 14px;
}
.subtitle,
.legend {
display: none;
}
.completion {
top: 12px;
right: 12px;
padding: 9px 10px;
}
.bottom {
right: 12px;
bottom: 12px;
left: 12px;
}
.timeline-card {
width: 100%;
}
.hint {
display: none;
}
.controls button {
min-width: 40px;
padding: 0 11px;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive voxel stage construction scene"></canvas>
<div class="hud">
<section class="title-card">
<div class="eyebrow">Community Build 04</div>
<h1>Voxel Neighbors</h1>
<div class="subtitle">
Two builders carry modular deck panels and position a central support
before revealing the finished, ground-supported platform.
</div>
<div class="legend">
<span><i class="dot"></i> Builder</span>
<span><i class="dot blue"></i> Deck panel</span>
</div>
</section>
<div id="completion" class="completion">
<span class="check">✓</span>
<span>Platform secured · 10/10 supports</span>
</div>
<div class="bottom">
<div class="timeline-card">
<div class="timeline-head">
<span id="status">Lifting panel 01</span>
<span id="time">00:00</span>
</div>
<div class="track"><div id="progress"></div></div>
</div>
<div class="controls">
<button id="pause" type="button">Pause</button>
<button id="restart" type="button">Restart</button>
<button id="view" type="button">Reset view</button>
</div>
</div>
<div class="hint">Drag to orbit · Scroll to zoom · Space to pause</div>
</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.querySelector("#scene");
const statusElement = document.querySelector("#status");
const timeElement = document.querySelector("#time");
const progressElement = document.querySelector("#progress");
const completionElement = document.querySelector("#completion");
const pauseButton = document.querySelector("#pause");
const restartButton = document.querySelector("#restart");
const viewButton = document.querySelector("#view");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xcce8f7);
scene.fog = new THREE.Fog(0xcce8f7, 19, 38);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
80
);
const hemisphere = new THREE.HemisphereLight(0xe8f7ff, 0x6d9877, 2.1);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff1d2, 3.25);
sun.position.set(8, 15, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -14;
sun.shadow.camera.right = 14;
sun.shadow.camera.top = 13;
sun.shadow.camera.bottom = -13;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 40;
sun.shadow.bias = -0.00025;
scene.add(sun);
const rim = new THREE.DirectionalLight(0x9ecbff, 0.75);
rim.position.set(-9, 7, -8);
scene.add(rim);
const materials = {
grass: new THREE.MeshStandardMaterial({
color: 0x82bd8f,
roughness: 0.94
}),
grassDark: new THREE.MeshStandardMaterial({
color: 0x5e9c77,
roughness: 0.96
}),
soil: new THREE.MeshStandardMaterial({
color: 0xb98762,
roughness: 1
}),
path: new THREE.MeshStandardMaterial({
color: 0xe8d5b2,
roughness: 0.96
}),
trunk: new THREE.MeshStandardMaterial({
color: 0x8a6047,
roughness: 0.95
}),
leafA: new THREE.MeshStandardMaterial({
color: 0x4f9d69,
roughness: 0.9
}),
leafB: new THREE.MeshStandardMaterial({
color: 0x6fb77a,
roughness: 0.9
}),
cloud: new THREE.MeshStandardMaterial({
color: 0xf8fdff,
roughness: 1
}),
support: new THREE.MeshStandardMaterial({
color: 0x31516c,
roughness: 0.66,
metalness: 0.08
}),
supportCap: new THREE.MeshStandardMaterial({
color: 0x56738b,
roughness: 0.6,
metalness: 0.12
}),
stageBase: new THREE.MeshStandardMaterial({
color: 0x203d5a,
roughness: 0.72
}),
orange: new THREE.MeshStandardMaterial({
color: 0xff8a47,
roughness: 0.76
}),
blue: new THREE.MeshStandardMaterial({
color: 0x4774d1,
roughness: 0.76
}),
teal: new THREE.MeshStandardMaterial({
color: 0x2eaa91,
roughness: 0.76
}),
cream: new THREE.MeshStandardMaterial({
color: 0xffe7bd,
roughness: 0.8
}),
dark: new THREE.MeshStandardMaterial({
color: 0x223749,
roughness: 0.82
}),
metal: new THREE.MeshStandardMaterial({
color: 0x6f8798,
roughness: 0.45,
metalness: 0.35
}),
lamp: new THREE.MeshStandardMaterial({
color: 0xffd66d,
emissive: 0xff9f32,
emissiveIntensity: 1.8,
roughness: 0.45
})
};
const skinMaterials = [
new THREE.MeshStandardMaterial({ color: 0xf1bd8f, roughness: 0.85 }),
new THREE.MeshStandardMaterial({ color: 0xc98d67, roughness: 0.85 }),
new THREE.MeshStandardMaterial({ color: 0x8d5a45, roughness: 0.85 })
];
const panelPalette = [
[0x4774d1, 0x5682dd, 0x3d67c2],
[0x3e8fc2, 0x4b9dcc, 0x347faa],
[0x2eaa91, 0x42b89f, 0x28947e],
[0x7766c7, 0x8877d3, 0x6857b5]
];
function addBox(parent, sx, sy, sz, x, y, z, material, castShadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(sx, sy, sz),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
function lerp(a, b, t) {
return a + (b - a) * t;
}
function ease(t) {
t = clamp(t, 0, 1);
return t * t * (3 - 2 * t);
}
function easeOutBack(t) {
t = clamp(t, 0, 1);
const c1 = 1.70158;
const c3 = c1 + 1;
return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2);
}
// ---------------------------------------------------------------------
// Diorama environment
// ---------------------------------------------------------------------
const world = new THREE.Group();
scene.add(world);
addBox(world, 18.6, 0.55, 13.4, 0, -0.57, 0, materials.soil);
addBox(world, 18, 0.42, 12.8, 0, -0.18, 0, materials.grass);
addBox(world, 10.8, 0.08, 1.1, 0, 0.055, 4.7, materials.path);
for (let i = 0; i < 13; i++) {
const x = -6.2 + i * 1.02;
addBox(world, 0.82, 0.065, 0.82, x, 0.045, 4.7, materials.path);
}
function makeTree(x, z, scale = 1) {
const tree = new THREE.Group();
tree.position.set(x, 0, z);
tree.scale.setScalar(scale);
addBox(tree, 0.42, 1.8, 0.42, 0, 0.9, 0, materials.trunk);
addBox(tree, 1.6, 1.05, 1.6, 0, 2.08, 0, materials.leafA);
addBox(tree, 1.15, 0.9, 1.15, 0.1, 2.92, 0, materials.leafB);
addBox(tree, 0.85, 0.75, 0.85, -0.22, 3.48, 0.04, materials.leafA);
world.add(tree);
}
makeTree(-7.2, -3.9, 1.05);
makeTree(-5.7, -4.7, 0.78);
makeTree(6.9, -4.3, 1.0);
makeTree(5.8, -3.5, 0.7);
function makeCloud(x, y, z, scale = 1) {
const cloud = new THREE.Group();
cloud.position.set(x, y, z);
cloud.scale.setScalar(scale);
addBox(cloud, 1.8, 0.65, 0.75, 0, 0, 0, materials.cloud, false);
addBox(cloud, 1.0, 0.95, 0.85, -0.68, 0.18, 0, materials.cloud, false);
addBox(cloud, 1.25, 1.1, 0.9, 0.56, 0.25, 0, materials.cloud, false);
addBox(cloud, 0.8, 0.7, 0.8, 0.08, 0.62, 0, materials.cloud, false);
world.add(cloud);
}
makeCloud(-6.5, 8.2, -10, 1.3);
makeCloud(5.8, 7.2, -12, 0.9);
makeCloud(0.2, 9.2, -15, 1.5);
// Low boundary blocks make the miniature world feel contained.
for (let x = -8; x <= 8; x += 1) {
addBox(world, 0.85, 0.38, 0.34, x, 0.19, -5.75, materials.grassDark);
}
// Staging trestles under the waiting panels.
const panelSourceZ = 4.7;
const panelXs = [-3.75, -1.25, 1.25, 3.75];
for (const x of panelXs) {
for (const zOffset of [-0.8, 0.8]) {
addBox(world, 0.18, 0.3, 0.18, x, 0.15, panelSourceZ + zOffset, materials.trunk);
}
addBox(world, 2.1, 0.12, 0.22, x, 0.29, panelSourceZ - 0.8, materials.trunk);
addBox(world, 2.1, 0.12, 0.22, x, 0.29, panelSourceZ + 0.8, materials.trunk);
}
// Tool chest and safety blocks.
addBox(world, 0.8, 0.48, 0.48, -6.8, 0.24, 3.3, materials.orange);
addBox(world, 0.84, 0.1, 0.52, -6.8, 0.53, 3.3, materials.dark);
addBox(world, 0.24, 0.12, 0.1, -6.8, 0.59, 3.3, materials.metal);
for (const x of [-6.1, 6.3]) {
addBox(world, 0.52, 0.1, 0.52, x, 0.05, 2.8, materials.dark);
addBox(world, 0.32, 0.65, 0.32, x, 0.36, 2.8, materials.orange);
addBox(world, 0.38, 0.14, 0.38, x, 0.56, 2.8, materials.cream);
}
// ---------------------------------------------------------------------
// Support modules
// ---------------------------------------------------------------------
function makeSupport() {
const group = new THREE.Group();
addBox(group, 0.8, 0.14, 0.8, 0, 0.07, 0, materials.support);
addBox(group, 0.34, 1.0, 0.34, 0, 0.64, 0, materials.support);
addBox(group, 0.74, 0.12, 0.56, 0, 1.19, 0, materials.supportCap);
addBox(group, 0.09, 0.76, 0.09, -0.21, 0.58, 0, materials.metal);
addBox(group, 0.09, 0.76, 0.09, 0.21, 0.58, 0, materials.metal);
return group;
}
const supportXs = [-4.55, -2.5, 0, 2.5, 4.55];
const supportZs = [-0.85, 0.85];
for (const x of supportXs) {
for (const z of supportZs) {
// One support is deliberately installed by the builders.
if (x === 4.55 && z === -0.85) continue;
const support = makeSupport();
support.position.set(x, 0, z);
world.add(support);
}
}
const movingSupport = makeSupport();
movingSupport.position.set(5.8, 0, 2.6);
world.add(movingSupport);
// ---------------------------------------------------------------------
// Modular deck panels
// ---------------------------------------------------------------------
function makePanel(index) {
const group = new THREE.Group();
const palette = panelPalette[index];
addBox(group, 2.38, 0.12, 2.84, 0, 0.06, 0, materials.stageBase);
const cell = 0.45;
const gap = 0.025;
const cols = 5;
const rows = 6;
for (let col = 0; col < cols; col++) {
for (let row = 0; row < rows; row++) {
const colorIndex = (col + row * 2 + index) % palette.length;
const material = new THREE.MeshStandardMaterial({
color: palette[colorIndex],
roughness: 0.78
});
addBox(
group,
cell,
0.12,
cell,
(col - (cols - 1) / 2) * (cell + gap),
0.18,
(row - (rows - 1) / 2) * (cell + gap),
material
);
}
}
// Edge trims visually bind the small voxels into one panel.
addBox(group, 2.28, 0.07, 0.08, 0, 0.255, -1.3, materials.metal);
addBox(group, 2.28, 0.07, 0.08, 0, 0.255, 1.3, materials.metal);
group.position.set(panelXs[index], 0.28, panelSourceZ);
world.add(group);
return group;
}
const panels = panelXs.map((_, index) => makePanel(index));
// Warm lamps under the front edge of the completed platform.
for (const x of [-3.6, -1.2, 1.2, 3.6]) {
addBox(world, 0.22, 0.18, 0.12, x, 1.14, 1.42, materials.lamp, false);
}
// Completion pennants.
function makePennant(x, z, color) {
const group = new THREE.Group();
group.position.set(x, 1.49, z);
addBox(group, 0.08, 1.35, 0.08, 0, 0.675, 0, materials.metal);
addBox(group, 0.52, 0.28, 0.07, 0.27, 1.18, 0, color);
return group;
}
const pennantMaterial = new THREE.MeshStandardMaterial({
color: 0xff8a47,
roughness: 0.8
});
const pennants = [
makePennant(-4.35, -1.08, pennantMaterial),
makePennant(4.35, -1.08, pennantMaterial)
];
pennants.forEach((pennant) => {
pennant.scale.y = 0;
world.add(pennant);
});
// ---------------------------------------------------------------------
// Voxel builders
// ---------------------------------------------------------------------
function createWorker(shirtMaterial, skinMaterial, phase = 0) {
const root = new THREE.Group();
const leftLeg = new THREE.Group();
const rightLeg = new THREE.Group();
leftLeg.position.set(-0.18, 0.57, 0);
rightLeg.position.set(0.18, 0.57, 0);
root.add(leftLeg, rightLeg);
addBox(leftLeg, 0.25, 0.43, 0.28, 0, -0.2, 0, materials.dark);
addBox(rightLeg, 0.25, 0.43, 0.28, 0, -0.2, 0, materials.dark);
addBox(leftLeg, 0.29, 0.13, 0.4, 0, -0.44, 0.06, materials.dark);
addBox(rightLeg, 0.29, 0.13, 0.4, 0, -0.44, 0.06, materials.dark);
addBox(root, 0.66, 0.58, 0.4, 0, 0.86, 0, shirtMaterial);
addBox(root, 0.68, 0.13, 0.42, 0, 1.05, 0, materials.cream);
addBox(root, 0.54, 0.47, 0.5, 0, 1.39, 0.01, skinMaterial);
// Hair and simple face.
addBox(root, 0.57, 0.14, 0.53, 0, 1.65, 0, materials.dark);
addBox(root, 0.16, 0.28, 0.08, -0.12, 1.43, 0.27, materials.dark);
addBox(root, 0.16, 0.28, 0.08, 0.12, 1.43, 0.27, materials.dark);
const leftArm = new THREE.Group();
const rightArm = new THREE.Group();
leftArm.position.set(-0.42, 1.08, 0);
rightArm.position.set(0.42, 1.08, 0);
root.add(leftArm, rightArm);
addBox(leftArm, 0.18, 0.48, 0.22, 0, -0.2, 0, shirtMaterial);
addBox(rightArm, 0.18, 0.48, 0.22, 0, -0.2, 0, shirtMaterial);
addBox(leftArm, 0.18, 0.16, 0.2, 0, -0.46, 0, skinMaterial);
addBox(rightArm, 0.18, 0.16, 0.2, 0, -0.46, 0, skinMaterial);
// Tool belt.
addBox(root, 0.69, 0.11, 0.43, 0, 0.61, 0, materials.dark);
addBox(root, 0.14, 0.18, 0.08, 0.19, 0.62, 0.23, materials.metal);
return {
root,
leftArm,
rightArm,
leftLeg,
rightLeg,
phase
};
}
const builderA = createWorker(materials.orange, skinMaterials[0], 0);
const builderB = createWorker(materials.blue, skinMaterials[1], Math.PI);
world.add(builderA.root, builderB.root);
// A few neighbors watch from the edges.
const spectators = [
createWorker(materials.teal, skinMaterials[2], 0.4),
createWorker(materials.cream, skinMaterials[0], 1.7),
createWorker(materials.orange, skinMaterials[1], 2.5)
];
spectators[0].root.position.set(-5.7, 0, 2.8);
spectators[1].root.position.set(-3.5, 0, 3.4);
spectators[2].root.position.set(6.25, 0, 2.7);
spectators.forEach((worker) => world.add(worker.root));
// ---------------------------------------------------------------------
// Animation tracks
// ---------------------------------------------------------------------
const panelTasks = [
{
src: new THREE.Vector3(-3.75, 0.28, panelSourceZ),
dst: new THREE.Vector3(-3.75, 1.25, 0),
liftStart: 0,
liftEnd: 1.2,
moveEnd: 5.8,
lowerEnd: 7.4
},
{
src: new THREE.Vector3(-1.25, 0.28, panelSourceZ),
dst: new THREE.Vector3(-1.25, 1.25, 0),
liftStart: 18.2,
liftEnd: 19,
moveEnd: 22.8,
lowerEnd: 24.2
},
{
src: new THREE.Vector3(1.25, 0.28, panelSourceZ),
dst: new THREE.Vector3(1.25, 1.25, 0),
liftStart: 26.4,
liftEnd: 27.2,
moveEnd: 31,
lowerEnd: 32.4
},
{
src: new THREE.Vector3(3.75, 0.28, panelSourceZ),
dst: new THREE.Vector3(3.75, 1.25, 0),
liftStart: 34.8,
liftEnd: 35.6,
moveEnd: 39.4,
lowerEnd: 40.8
}
];
const workerATrack = [
{ t: 0, x: -7.35, z: 4.7 },
{ t: 7.4, x: -5.3, z: 0 },
{ t: 8.2, x: -5.3, z: 0 },
{ t: 10.2, x: 5.18, z: 2.6 },
{ t: 14.2, x: 3.93, z: -0.85 },
{ t: 16, x: 3.93, z: -0.85 },
{ t: 18.2, x: -4.05, z: 4.7 },
{ t: 24.2, x: -2.8, z: 0 },
{ t: 26.4, x: -1.35, z: 4.7 },
{ t: 32.4, x: -0.3, z: 0 },
{ t: 34.8, x: 2.2, z: 4.7 },
{ t: 40.8, x: 2.2, z: 0 },
{ t: 43, x: 1.2, z: 3 },
{ t: 46, x: 1.2, z: 3 }
];
const workerBTrack = [
{ t: 0, x: -4.25, z: 4.7 },
{ t: 7.4, x: -2.2, z: 0 },
{ t: 8.2, x: -2.2, z: 0 },
{ t: 10.2, x: 6.42, z: 2.6 },
{ t: 14.2, x: 5.17, z: -0.85 },
{ t: 16, x: 5.17, z: -0.85 },
{ t: 18.2, x: -1.55, z: 4.7 },
{ t: 24.2, x: 0, z: 0 },
{ t: 26.4, x: 1.75, z: 4.7 },
{ t: 32.4, x: 2.8, z: 0 },
{ t: 34.8, x: 5.3, z: 4.7 },
{ t: 40.8, x: 5.3, z: 0 },
{ t: 43, x: 4.8, z: 3 },
{ t: 46, x: 4.8, z: 3 }
];
function sampleTrack(track, time) {
if (time <= track[0].t) return track[0];
if (time >= track[track.length - 1].t) return track[track.length - 1];
for (let i = 0; i < track.length - 1; i++) {
const a = track[i];
const b = track[i + 1];
if (time >= a.t && time <= b.t) {
const amount = ease((time - a.t) / (b.t - a.t));
return {
x: lerp(a.x, b.x, amount),
z: lerp(a.z, b.z, amount)
};
}
}
return track[track.length - 1];
}
function updatePanel(panel, task, time) {
let x = task.src.x;
let y = task.src.y;
let z = task.src.z;
let wobble = 0;
if (time >= task.liftStart && time < task.liftEnd) {
const amount = ease((time - task.liftStart) / (task.liftEnd - task.liftStart));
y = lerp(task.src.y, 1.72, amount);
wobble = Math.sin(time * 10) * 0.012 * amount;
} else if (time >= task.liftEnd && time < task.moveEnd) {
const amount = ease((time - task.liftEnd) / (task.moveEnd - task.liftEnd));
x = lerp(task.src.x, task.dst.x, amount);
z = lerp(task.src.z, task.dst.z, amount);
y = 1.72 + Math.sin(time * 8) * 0.025;
wobble = Math.sin(time * 8) * 0.009;
} else if (time >= task.moveEnd && time < task.lowerEnd) {
const amount = ease((time - task.moveEnd) / (task.lowerEnd - task.moveEnd));
x = task.dst.x;
z = task.dst.z;
y = lerp(1.72, task.dst.y, amount);
wobble = Math.sin(time * 12) * 0.006 * (1 - amount);
} else if (time >= task.lowerEnd) {
x = task.dst.x;
y = task.dst.y;
z = task.dst.z;
}
panel.position.set(x, y, z);
panel.rotation.z = wobble;
}
function angleDifference(a, b) {
let difference = (b - a + Math.PI) % (Math.PI * 2) - Math.PI;
if (difference < -Math.PI) difference += Math.PI * 2;
return difference;
}
function animateWorker(worker, track, time, carrying, isBuilderA) {
const position = sampleTrack(track, time);
const previous = sampleTrack(track, Math.max(0, time - 0.05));
const dx = position.x - previous.x;
const dz = position.z - previous.z;
const moving = Math.hypot(dx, dz) > 0.003;
worker.root.position.set(position.x, 0, position.z);
if (moving) {
const desired = Math.atan2(dx, dz);
worker.root.rotation.y += angleDifference(worker.root.rotation.y, desired) * 0.18;
}
const gait = moving ? Math.sin(time * 9 + worker.phase) * 0.52 : 0;
worker.leftLeg.rotation.x = gait;
worker.rightLeg.rotation.x = -gait;
if (carrying) {
worker.leftArm.rotation.set(-0.18, 0, 2.78);
worker.rightArm.rotation.set(-0.18, 0, -2.78);
} else {
worker.leftArm.rotation.set(-gait * 0.72, 0, 0);
worker.rightArm.rotation.set(gait * 0.72, 0, 0);
}
worker.root.position.y = moving ? Math.abs(Math.sin(time * 9 + worker.phase)) * 0.025 : 0;
}
function isCarrying(time) {
return (
time < 7.4 ||
(time >= 10.2 && time < 15.8) ||
(time >= 18.2 && time < 24.2) ||
(time >= 26.4 && time < 32.4) ||
(time >= 34.8 && time < 40.8)
);
}
function updateMovingSupport(time) {
const source = new THREE.Vector3(5.8, 0, 2.6);
const destination = new THREE.Vector3(4.55, 0, -0.85);
if (time < 10.2) {
movingSupport.position.copy(source);
} else if (time < 14.2) {
const amount = ease((time - 10.2) / 4);
movingSupport.position.lerpVectors(source, destination, amount);
movingSupport.position.y = Math.sin(time * 10) * 0.025;
} else {
movingSupport.position.copy(destination);
movingSupport.position.y = 0;
}
movingSupport.rotation.y = 0;
}
function updatePennants(time) {
const amount = time < 41.2 ? 0 : easeOutBack((time - 41.2) / 1.5);
pennants.forEach((pennant, index) => {
pennant.scale.y = amount;
pennant.rotation.y = index === 0 ? -0.12 : 0.12;
});
}
function updateSpectators(time) {
spectators.forEach((worker, index) => {
const wave = time > 40.8 ? Math.sin(time * 7 + index * 1.3) * 0.85 : 0;
worker.leftArm.rotation.set(0, 0, 0.2 + wave);
worker.rightArm.rotation.set(0, 0, -0.2 - wave);
worker.root.position.y = time > 40.8 ? Math.abs(Math.sin(time * 5 + index)) * 0.035 : 0;
});
}
function formatTime(seconds) {
const minutes = Math.floor(seconds / 60);
const remainder = Math.floor(seconds % 60);
return `${String(minutes).padStart(2, "0")}:${String(remainder).padStart(2, "0")}`;
}
function updateInterface(time) {
const total = 45;
progressElement.style.width = `${clamp(time / total, 0, 1) * 100}%`;
timeElement.textContent = formatTime(time);
let status;
if (time < 7.4) {
status = "Lifting and placing panel 01";
} else if (time < 16) {
status = "Positioning the final support module";
} else if (time < 24.2) {
status = "Placing panel 02 on the frame";
} else if (time < 32.4) {
status = "Placing panel 03 on the frame";
} else if (time < 40.8) {
status = "Placing panel 04 on the frame";
} else if (time < 43) {
status = "Checking supports and final alignment";
} else {
status = "Platform complete · all supports locked";
}
statusElement.textContent = status;
completionElement.classList.toggle("visible", time >= 42.5);
}
// ---------------------------------------------------------------------
// Camera controls implemented without addons
// ---------------------------------------------------------------------
const cameraState = {
yaw: 0.62,
pitch: 0.53,
radius: 17.5,
target: new THREE.Vector3(0, 0.95, 1.15)
};
function resetCamera() {
cameraState.yaw = 0.62;
cameraState.pitch = 0.53;
cameraState.radius = 17.5;
cameraState.target.set(0, 0.95, 1.15);
}
function updateCamera() {
const horizontal = Math.cos(cameraState.pitch) * cameraState.radius;
camera.position.set(
cameraState.target.x + Math.sin(cameraState.yaw) * horizontal,
cameraState.target.y + Math.sin(cameraState.pitch) * cameraState.radius,
cameraState.target.z + Math.cos(cameraState.yaw) * horizontal
);
camera.lookAt(cameraState.target);
}
let dragging = false;
let pointerX = 0;
let pointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
cameraState.yaw -= dx * 0.006;
cameraState.pitch = clamp(cameraState.pitch + dy * 0.0045, 0.2, 1.18);
});
function endDrag(event) {
dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
cameraState.radius = clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
9,
28
);
}, { passive: false });
canvas.addEventListener("dblclick", resetCamera);
// ---------------------------------------------------------------------
// Playback
// ---------------------------------------------------------------------
let animationTime = 0;
let paused = false;
let previousTimestamp = performance.now();
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Play" : "Pause";
});
restartButton.addEventListener("click", () => {
animationTime = 0;
paused = false;
pauseButton.textContent = "Pause";
});
viewButton.addEventListener("click", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.code === "Space") {
event.preventDefault();
paused = !paused;
pauseButton.textContent = paused ? "Play" : "Pause";
}
if (event.code === "KeyR") {
animationTime = 0;
}
});
function animate(timestamp) {
requestAnimationFrame(animate);
const delta = Math.min((timestamp - previousTimestamp) / 1000, 0.05);
previousTimestamp = timestamp;
if (!paused) {
animationTime += delta * 1.18;
}
const time = animationTime;
panels.forEach((panel, index) => {
updatePanel(panel, panelTasks[index], time);
});
updateMovingSupport(time);
animateWorker(builderA, workerATrack, time, isCarrying(time), true);
animateWorker(builderB, workerBTrack, time, isCarrying(time), false);
updatePennants(time);
updateSpectators(time);
updateInterface(time);
updateCamera();
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
updateCamera();
requestAnimationFrame(animate);
</script>
</body>
</html>
```