Prompt specification
Build or customize the Three.js 3D scene "Two Volunteers One Hidden Task" 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: Two Volunteers One Hidden Task
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/two-volunteers-one-hidden-task-x3266
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts volunteers duplicating a delivery when completion information is missing. Reveal a shared status board and replay the same requests to demonstrate the changed coordination. Low-poly.
Working Three.js Starter (two-volunteers-one-hidden-task-x3266):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>One Request — Volunteer Coordination</title>
<style>
:root {
--ink: #173b35;
--paper: #fbf8ee;
--green: #246b57;
--lime: #d9ee78;
--coral: #f17459;
--blue: #668fca;
--muted: #718079;
--line: rgba(23, 59, 53, 0.14);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9eee6;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 5;
}
.panel {
background: rgba(251, 248, 238, 0.92);
border: 1px solid rgba(23, 59, 53, 0.13);
box-shadow: 0 14px 36px rgba(31, 66, 57, 0.12);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.story-panel {
position: absolute;
top: 24px;
left: 24px;
width: min(410px, calc(100vw - 48px));
padding: 22px;
border-radius: 20px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
color: var(--green);
font-size: 11px;
font-weight: 850;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 9px;
height: 9px;
border-radius: 3px;
background: var(--coral);
transform: rotate(12deg);
}
h1 {
max-width: 360px;
margin: 0;
font-size: clamp(27px, 3vw, 42px);
line-height: 0.98;
letter-spacing: -0.045em;
}
#description {
min-height: 58px;
margin: 14px 0 18px;
color: #50675f;
font-size: 14px;
line-height: 1.45;
}
.request-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding-top: 15px;
border-top: 1px solid var(--line);
}
.request-pill {
display: inline-flex;
align-items: center;
gap: 9px;
font-size: 12px;
font-weight: 800;
}
.request-icon {
display: grid;
width: 30px;
height: 30px;
place-items: center;
border-radius: 9px;
background: var(--lime);
color: var(--ink);
box-shadow: inset 0 -2px 0 rgba(23, 59, 53, 0.12);
}
#requestState {
color: var(--muted);
font-size: 11px;
font-weight: 750;
text-align: right;
}
.request-pulse {
animation: requestPulse 0.8s ease;
}
@keyframes requestPulse {
0% {
transform: scale(1);
}
35% {
transform: scale(1.06);
background: var(--lime);
}
100% {
transform: scale(1);
}
}
.metrics {
position: absolute;
top: 24px;
right: 24px;
display: grid;
grid-template-columns: repeat(2, 132px);
gap: 10px;
}
.metric {
min-height: 84px;
padding: 14px;
border-radius: 16px;
}
.metric strong {
display: block;
margin-bottom: 5px;
font-size: 26px;
line-height: 1;
letter-spacing: -0.04em;
}
.metric span {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
line-height: 1.25;
text-transform: uppercase;
}
.metric.alert strong {
color: var(--coral);
}
.metric.good strong {
color: var(--green);
}
.control-panel {
position: absolute;
bottom: 24px;
left: 24px;
width: min(430px, calc(100vw - 48px));
padding: 16px;
border-radius: 18px;
pointer-events: auto;
}
.button-row {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.button-row button {
min-height: 40px;
padding: 0 13px;
border: 1px solid rgba(23, 59, 53, 0.16);
border-radius: 11px;
background: #fffdf6;
color: var(--ink);
cursor: pointer;
font-size: 12px;
font-weight: 800;
transition: transform 0.15s ease, background 0.15s ease;
}
.button-row button:hover {
background: #eff7cf;
transform: translateY(-1px);
}
.button-row button.primary {
background: var(--ink);
color: white;
}
.button-row button.primary:hover {
background: #24564b;
}
.timeline {
height: 5px;
margin-top: 14px;
overflow: hidden;
border-radius: 99px;
background: rgba(23, 59, 53, 0.09);
}
#timelineFill {
width: 0;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, var(--coral), var(--lime));
transition: width 0.08s linear;
}
.timeline-caption {
display: flex;
justify-content: space-between;
gap: 12px;
margin-top: 8px;
color: var(--muted);
font-size: 10px;
font-weight: 700;
}
.feed-panel {
position: absolute;
right: 24px;
bottom: 24px;
width: min(330px, calc(100vw - 48px));
padding: 16px;
border-radius: 18px;
}
.feed-title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
color: var(--muted);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.live-dot {
display: inline-block;
width: 7px;
height: 7px;
margin-right: 5px;
border-radius: 50%;
background: var(--coral);
box-shadow: 0 0 0 4px rgba(241, 116, 89, 0.13);
}
#feed {
display: grid;
gap: 8px;
}
.feed-item {
display: grid;
grid-template-columns: 45px 1fr;
gap: 8px;
align-items: start;
padding-top: 8px;
border-top: 1px solid var(--line);
font-size: 11px;
line-height: 1.35;
}
.feed-item time {
color: var(--muted);
font-variant-numeric: tabular-nums;
font-weight: 750;
}
.feed-item.good {
color: var(--green);
}
.feed-item.warn {
color: #b54836;
}
.camera-hint {
position: absolute;
bottom: 26px;
left: 50%;
padding: 8px 12px;
border: 1px solid rgba(23, 59, 53, 0.12);
border-radius: 999px;
background: rgba(251, 248, 238, 0.72);
color: rgba(23, 59, 53, 0.68);
font-size: 10px;
font-weight: 750;
transform: translateX(-50%);
transition: opacity 0.5s ease;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #e9eee6;
transition: opacity 0.5s ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
.loader-card {
padding: 20px 26px;
border-radius: 16px;
background: var(--paper);
color: var(--ink);
font-size: 12px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
@media (max-width: 780px) {
.story-panel {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 16px;
}
#description {
min-height: 0;
margin-bottom: 12px;
}
.metrics {
top: auto;
right: 12px;
bottom: 12px;
grid-template-columns: repeat(2, 92px);
}
.metric {
min-height: 66px;
padding: 10px;
}
.metric strong {
font-size: 21px;
}
.control-panel {
bottom: 94px;
left: 12px;
width: calc(100vw - 24px);
}
.feed-panel,
.camera-hint {
display: none;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="hud">
<section class="story-panel panel">
<div class="eyebrow">Neighborhood delivery study · Scenario 04</div>
<h1 id="headline">Completion information is missing.</h1>
<p id="description">
The same request reaches two volunteers. Because neither can see that
the delivery is already being handled, both set out.
</p>
<div class="request-row">
<div class="request-pill">
<span class="request-icon">▣</span>
<span>REQ-042 · Grocery bag</span>
</div>
<span id="requestState">Dispatching</span>
</div>
</section>
<section class="metrics" aria-label="Scenario metrics">
<div class="metric panel alert" id="deliveryMetric">
<strong id="deliveryCount">0</strong>
<span>Deliveries created</span>
</div>
<div class="metric panel" id="dispatchMetric">
<strong id="dispatchCount">0</strong>
<span>Volunteers dispatched</span>
</div>
<div class="metric panel good" id="recordMetric">
<strong id="recordCount">0</strong>
<span>Shared records</span>
</div>
<div class="metric panel good" id="blockedMetric">
<strong id="blockedCount">0</strong>
<span>Duplicates blocked</span>
</div>
</section>
<section class="control-panel panel">
<div class="button-row">
<button class="primary" id="runAll">Run comparison</button>
<button id="runBlind">Replay missing completion</button>
<button id="runShared">Replay with shared board</button>
<button id="pause">Pause</button>
</div>
<div class="timeline"><div id="timelineFill"></div></div>
<div class="timeline-caption">
<span id="phaseLabel">Preparing scenario</span>
<span id="timeLabel">00:00</span>
</div>
</section>
<section class="feed-panel panel">
<div class="feed-title">
<span><span class="live-dot"></span>Coordination log</span>
<span>REQ-042</span>
</div>
<div id="feed" aria-live="polite"></div>
</section>
<div class="camera-hint" id="cameraHint">Drag to orbit · scroll to zoom</div>
</div>
<div id="loading">
<div class="loader-card">Building the neighborhood…</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 sceneHost = document.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9eee6);
scene.fog = new THREE.Fog(0xe9eee6, 18, 34);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
sceneHost.appendChild(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
70
);
const cameraTarget = new THREE.Vector3(0, 1.05, -0.45);
let cameraYaw = 0.48;
let cameraPitch = 0.47;
let cameraRadius = 14.7;
function updateCamera() {
const horizontal = Math.cos(cameraPitch) * cameraRadius;
camera.position.set(
cameraTarget.x + Math.sin(cameraYaw) * horizontal,
cameraTarget.y + Math.sin(cameraPitch) * cameraRadius,
cameraTarget.z + Math.cos(cameraYaw) * horizontal
);
camera.lookAt(cameraTarget);
}
updateCamera();
// Direct camera controls: no examples or addons are used.
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);
document.getElementById("cameraHint").style.opacity = "0";
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
cameraYaw -= dx * 0.006;
cameraPitch = THREE.MathUtils.clamp(
cameraPitch + dy * 0.0045,
0.24,
0.84
);
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined) {
try {
renderer.domElement.releasePointerCapture(event.pointerId);
} catch (_) {}
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraRadius = THREE.MathUtils.clamp(
cameraRadius * Math.exp(event.deltaY * 0.001),
8.5,
22
);
},
{ passive: false }
);
const hemisphere = new THREE.HemisphereLight(0xf8fff1, 0x6f8978, 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff2ce, 3.0);
sun.position.set(-6, 11, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -13;
sun.shadow.camera.right = 13;
sun.shadow.camera.top = 13;
sun.shadow.camera.bottom = -13;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 32;
sun.shadow.bias = -0.0006;
scene.add(sun);
const palette = {
ink: 0x173b35,
green: 0x246b57,
lightGreen: 0x8ebc84,
lime: 0xd9ee78,
coral: 0xf17459,
blue: 0x668fca,
cream: 0xf7f1dc,
paper: 0xfffaf0,
wood: 0x9a6845,
soil: 0xc5a978,
dark: 0x263c38
};
function material(color, extra = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0.02,
flatShading: true,
...extra
});
}
const mats = {
ink: material(palette.ink),
green: material(palette.green),
lightGreen: material(palette.lightGreen),
lime: material(palette.lime),
coral: material(palette.coral),
blue: material(palette.blue),
cream: material(palette.cream),
paper: material(palette.paper),
wood: material(palette.wood),
soil: material(palette.soil),
dark: material(palette.dark),
window: material(0xb9e2dc, {
emissive: 0x7ab8ad,
emissiveIntensity: 0.12
})
};
function mesh(geometry, mat, parent = scene) {
const object = new THREE.Mesh(geometry, mat);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function box(parent, size, position, mat) {
const object = mesh(new THREE.BoxGeometry(...size), mat, parent);
object.position.set(...position);
return object;
}
function cylinder(parent, radiusTop, radiusBottom, height, sides, position, mat) {
const object = mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
sides
),
mat,
parent
);
object.position.set(...position);
return object;
}
function roundedRect(ctx, x, y, w, h, radius) {
const r = Math.min(radius, w / 2, h / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + w, y, x + w, y + h, r);
ctx.arcTo(x + w, y + h, x, y + h, r);
ctx.arcTo(x, y + h, x, y, r);
ctx.arcTo(x, y, x + w, y, r);
ctx.closePath();
}
function createTextSprite(
text,
{
width = 2.3,
height = 0.48,
background = "#173b35",
foreground = "#fffaf0",
fontSize = 46
} = {}
) {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 160;
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false,
toneMapped: false
})
);
sprite.scale.set(width, height, 1);
sprite.renderOrder = 20;
sprite.userData.canvas = canvas;
sprite.userData.texture = texture;
sprite.userData.style = { background, foreground, fontSize };
setSpriteText(sprite, text);
return sprite;
}
function setSpriteText(sprite, text) {
const canvas = sprite.userData.canvas;
const ctx = canvas.getContext("2d");
const style = sprite.userData.style;
ctx.clearRect(0, 0, canvas.width, canvas.height);
roundedRect(ctx, 6, 8, 756, 144, 38);
ctx.fillStyle = style.background;
ctx.fill();
ctx.fillStyle = style.foreground;
ctx.font = `800 ${style.fontSize}px Arial, sans-serif`;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 384, 82, 720);
sprite.userData.texture.needsUpdate = true;
}
// Ground and neighborhood layout.
const ground = mesh(
new THREE.PlaneGeometry(30, 24),
material(0xdce6d4)
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.04;
ground.castShadow = false;
const path = box(
scene,
[15.5, 0.08, 2.15],
[0.3, 0.015, 1.0],
material(0xe9dfc6)
);
path.castShadow = false;
const pathEdge = box(
scene,
[15.5, 0.11, 0.13],
[0.3, 0.04, 0.02],
material(0xc5b895)
);
pathEdge.castShadow = false;
const gardenPatch = mesh(
new THREE.CircleGeometry(3.8, 7),
material(0xb8cfa5)
);
gardenPatch.rotation.x = -Math.PI / 2;
gardenPatch.position.set(-4.3, -0.018, 2.8);
gardenPatch.castShadow = false;
function createTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.scale.setScalar(scale);
scene.add(group);
cylinder(group, 0.13, 0.2, 1.55, 5, [0, 0.77, 0], mats.wood);
const crown = mesh(
new THREE.IcosahedronGeometry(0.85, 0),
material(0x6e9f69),
group
);
crown.position.y = 1.85;
crown.scale.set(0.9, 1.12, 0.9);
const crown2 = mesh(
new THREE.IcosahedronGeometry(0.55, 0),
material(0x8ebc78),
group
);
crown2.position.set(0.42, 2.18, 0.05);
}
[
[-7.2, 3.8, 0.85],
[-6.3, -3.8, 1.05],
[6.7, 3.9, 0.9],
[7.2, -3.7, 1.1],
[-0.2, 4.8, 0.72],
[2.0, -5.5, 0.78]
].forEach((args) => createTree(...args));
function createBuilding({
x,
z,
width,
depth,
height,
wall,
roof,
doorColor = palette.ink
}) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
box(group, [width, height, depth], [0, height / 2, 0], wall);
const roofMesh = mesh(
new THREE.ConeGeometry(width * 0.74, 1.05, 4),
roof,
group
);
roofMesh.position.y = height + 0.48;
roofMesh.rotation.y = Math.PI / 4;
roofMesh.scale.z = depth / width;
box(
group,
[0.72, 1.35, 0.12],
[0, 0.68, depth / 2 + 0.07],
material(doorColor)
);
[-width * 0.3, width * 0.3].forEach((windowX) => {
box(
group,
[0.72, 0.65, 0.1],
[windowX, height * 0.62, depth / 2 + 0.08],
mats.window
);
});
box(
group,
[width + 0.15, 0.12, 0.12],
[0, height * 0.39, depth / 2 + 0.1],
material(0xf3e7cc)
);
return group;
}
createBuilding({
x: -4.45,
z: -1.75,
width: 3.35,
depth: 2.55,
height: 2.25,
wall: material(0xe7c49c),
roof: material(0x8e5949),
doorColor: palette.green
});
createBuilding({
x: 5.05,
z: -1.35,
width: 2.75,
depth: 1.95,
height: 2.0,
wall: material(0xf0dfbd),
roof: material(0x5b7867),
doorColor: palette.coral
});
// Depot parcel stacks.
for (let i = 0; i < 4; i++) {
const parcel = box(
scene,
[0.52, 0.42, 0.52],
[-2.95 + (i % 2) * 0.65, 0.22 + Math.floor(i / 2) * 0.43, -0.45],
i % 2 ? mats.lime : mats.cream
);
parcel.rotation.y = (i % 3) * 0.12;
}
// Recipient porch and a small resident.
box(
scene,
[2.55, 0.22, 1.25],
[5.0, 0.11, 0.08],
material(0xc9b78f)
);
const resident = new THREE.Group();
resident.position.set(5.72, 0, -0.06);
scene.add(resident);
cylinder(resident, 0.24, 0.32, 0.68, 6, [0, 0.94, 0], mats.coral);
mesh(new THREE.IcosahedronGeometry(0.23, 1), material(0xd8a579), resident)
.position.set(0, 1.51, 0);
const residentArm = box(
resident,
[0.13, 0.55, 0.13],
[0.33, 1.05, 0],
mats.coral
);
residentArm.rotation.z = -0.55;
// Shared status board.
const boardGroup = new THREE.Group();
boardGroup.position.set(0, -2.7, -3.7);
scene.add(boardGroup);
box(boardGroup, [0.18, 2.3, 0.18], [-1.78, 1.05, 0], mats.wood);
box(boardGroup, [0.18, 2.3, 0.18], [1.78, 1.05, 0], mats.wood);
box(boardGroup, [4.72, 2.45, 0.18], [0, 2.45, 0], mats.ink);
const boardCanvas = document.createElement("canvas");
boardCanvas.width = 1024;
boardCanvas.height = 512;
const boardTexture = new THREE.CanvasTexture(boardCanvas);
boardTexture.colorSpace = THREE.SRGBColorSpace;
boardTexture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const boardFace = new THREE.Mesh(
new THREE.PlaneGeometry(4.5, 2.25),
new THREE.MeshBasicMaterial({
map: boardTexture,
toneMapped: false
})
);
boardFace.position.set(0, 2.45, 0.105);
boardGroup.add(boardFace);
const boardLightMaterial = new THREE.MeshBasicMaterial({
color: palette.lime,
toneMapped: false
});
const boardLight = mesh(
new THREE.SphereGeometry(0.095, 8, 6),
boardLightMaterial,
boardGroup
);
boardLight.position.set(2.08, 3.48, 0.19);
let boardState = "waiting";
function drawBoard() {
const ctx = boardCanvas.getContext("2d");
ctx.fillStyle = "#173b35";
ctx.fillRect(0, 0, 1024, 512);
ctx.strokeStyle = "rgba(217,238,120,0.09)";
ctx.lineWidth = 1;
for (let x = 0; x < 1024; x += 64) {
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, 512);
ctx.stroke();
}
for (let y = 0; y < 512; y += 64) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(1024, y);
ctx.stroke();
}
ctx.fillStyle = "#d9ee78";
ctx.fillRect(38, 32, 12, 12);
ctx.fillStyle = "#d9ee78";
ctx.font = "800 43px Arial, sans-serif";
ctx.fillText("SHARED DELIVERY STATUS", 70, 69);
ctx.fillStyle = "#8da79d";
ctx.font = "700 22px Arial, sans-serif";
ctx.fillText("REQ-042 / GROCERY BAG", 40, 126);
ctx.strokeStyle = "rgba(255,255,255,0.16)";
ctx.beginPath();
ctx.moveTo(40, 151);
ctx.lineTo(984, 151);
ctx.stroke();
ctx.fillStyle = "#7f9a91";
ctx.font = "700 19px Arial, sans-serif";
ctx.fillText("VOLUNTEER", 42, 193);
ctx.fillText("STATUS", 448, 193);
ctx.fillText("TIME", 854, 193);
let mayaStatus = "AVAILABLE";
let mayaTime = "—";
let noahStatus = "AVAILABLE";
let noahTime = "—";
let footer = "CHECK THE BOARD BEFORE DISPATCHING";
let footerColor = "#d9ee78";
if (boardState === "claimed") {
mayaStatus = "CLAIMED";
mayaTime = "10:41";
noahStatus = "WAITING";
footer = "ONE CLAIM · THE OTHER VOLUNTEER WAITS";
} else if (boardState === "complete") {
mayaStatus = "COMPLETED";
mayaTime = "10:43";
noahStatus = "SKIPPED";
footer = "COMPLETION IS VISIBLE TO EVERYONE";
} else if (boardState === "replay") {
mayaStatus = "COMPLETED";
mayaTime = "10:43";
noahStatus = "BLOCKED";
noahTime = "10:44";
footer = "ALREADY COMPLETE · NO SECOND DISPATCH";
footerColor = "#f5a78f";
}
function drawRow(y, name, status, time, accent) {
roundedRect(ctx, 40, y - 43, 944, 83, 18);
ctx.fillStyle = "rgba(255,255,255,0.055)";
ctx.fill();
ctx.fillStyle = accent;
ctx.beginPath();
ctx.arc(68, y - 2, 9, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = "#fffaf0";
ctx.font = "800 25px Arial, sans-serif";
ctx.fillText(name, 95, y + 7);
ctx.fillStyle =
status === "BLOCKED" || status === "SKIPPED"
? "#f5a78f"
: status === "COMPLETED"
? "#d9ee78"
: "#fffaf0";
ctx.font = "800 23px Arial, sans-serif";
ctx.fillText(status, 448, y + 7);
ctx.fillStyle = "#a8b9b3";
ctx.font = "700 22px Arial, sans-serif";
ctx.fillText(time, 874, y + 7);
}
drawRow(251, "MAYA CHEN", mayaStatus, mayaTime, "#d9ee78");
drawRow(356, "NOAH PATEL", noahStatus, noahTime, "#668fca");
roundedRect(ctx, 40, 426, 944, 56, 17);
ctx.fillStyle = "rgba(217,238,120,0.08)";
ctx.fill();
ctx.fillStyle = footerColor;
ctx.font = "800 22px Arial, sans-serif";
ctx.fillText(footer, 68, 462);
boardTexture.needsUpdate = true;
const lightColor = {
waiting: palette.lime,
claimed: 0xf3bd63,
complete: palette.lime,
replay: palette.coral
}[boardState];
boardLightMaterial.color.set(lightColor);
}
drawBoard();
// Reusable low-poly parcel.
function createParcel(scale = 1) {
const group = new THREE.Group();
box(group, [0.62, 0.5, 0.56], [0, 0, 0], mats.lime);
box(group, [0.11, 0.515, 0.575], [0, 0, 0], mats.coral);
box(group, [0.635, 0.11, 0.575], [0, 0.02, 0], mats.coral);
group.scale.setScalar(scale);
return group;
}
const mayaRoute = new THREE.CatmullRomCurve3([
new THREE.Vector3(-2.65, 0.08, 2.05),
new THREE.Vector3(-2.05, 0.08, 0.78),
new THREE.Vector3(-0.25, 0.08, 0.78),
new THREE.Vector3(2.35, 0.08, 0.78),
new THREE.Vector3(4.35, 0.08, 0.42)
]);
const noahRoute = new THREE.CatmullRomCurve3([
new THREE.Vector3(-1.25, 0.08, 2.85),
new THREE.Vector3(-0.25, 0.08, 2.18),
new THREE.Vector3(1.45, 0.08, 1.88),
new THREE.Vector3(3.35, 0.08, 1.3),
new THREE.Vector3(5.02, 0.08, 0.85)
]);
function createPerson({
name,
color,
route,
start,
skin = 0xd6a276
}) {
const root = new THREE.Group();
root.position.copy(start);
scene.add(root);
cylinder(root, 0.26, 0.36, 0.72, 6, [0, 1.08, 0], material(color));
cylinder(root, 0.2, 0.22, 0.18, 6, [0, 1.51, 0], material(skin));
const head = mesh(
new THREE.IcosahedronGeometry(0.24, 1),
material(skin),
root
);
head.position.set(0, 1.65, 0);
const hair = mesh(
new THREE.IcosahedronGeometry(0.245, 1),
mats.dark,
root
);
hair.position.set(0, 1.72, -0.025);
hair.scale.set(1, 0.7, 0.95);
const eyeGeometry = new THREE.BoxGeometry(0.045, 0.045, 0.035);
[-0.075, 0.075].forEach((x) => {
const eye = mesh(eyeGeometry, mats.ink, root);
eye.position.set(x, 1.66, 0.225);
});
const leftLeg = new THREE.Group();
const rightLeg = new THREE.Group();
leftLeg.position.set(-0.16, 0.76, 0);
rightLeg.position.set(0.16, 0.76, 0);
root.add(leftLeg, rightLeg);
box(leftLeg, [0.18, 0.67, 0.21], [0, -0.33, 0], mats.ink);
box(rightLeg, [0.18, 0.67, 0.21], [0, -0.33, 0], mats.ink);
const leftArm = new THREE.Group();
const rightArm = new THREE.Group();
leftArm.position.set(-0.36, 1.39, 0);
rightArm.position.set(0.36, 1.39, 0);
root.add(leftArm, rightArm);
box(leftArm, [0.15, 0.62, 0.16], [0, -0.28, 0], material(color));
box(rightArm, [0.15, 0.62, 0.16], [0, -0.28, 0], material(color));
const carried = createParcel(0.92);
carried.position.set(0.34, 1.04, 0.43);
carried.visible = false;
root.add(carried);
const nameLabel = createTextSprite(name, {
width: 1.8,
height: 0.38,
background: "#173b35",
foreground: "#fffaf0",
fontSize: 40
});
nameLabel.position.set(0, 2.05, 0);
root.add(nameLabel);
const statusLabel = createTextSprite("READY", {
width: 2.65,
height: 0.48,
background: "#fffaf0",
foreground: "#173b35",
fontSize: 37
});
statusLabel.position.set(0, 2.58, 0);
root.add(statusLabel);
return {
root,
route,
start,
leftLeg,
rightLeg,
leftArm,
rightArm,
carried,
statusLabel
};
}
const maya = createPerson({
name: "MAYA",
color: palette.coral,
route: mayaRoute,
start: mayaRoute.points[0],
skin: 0xd19a70
});
const noah = createPerson({
name: "NOAH",
color: palette.blue,
route: noahRoute,
start: noahRoute.points[0],
skin: 0xe1b58a
});
function createRouteLine(curve, color) {
const geometry = new THREE.BufferGeometry().setFromPoints(
curve.getPoints(90)
);
const line = new THREE.Line(
geometry,
new THREE.LineDashedMaterial({
color,
dashSize: 0.28,
gapSize: 0.17,
transparent: true,
opacity: 0.72
})
);
line.computeLineDistances();
line.visible = false;
scene.add(line);
return line;
}
const mayaLine = createRouteLine(mayaRoute, palette.coral);
const noahLine = createRouteLine(noahRoute, palette.blue);
const deliveredPackages = [];
function setStatus(person, text, tone = "normal") {
const style = {
normal: { background: "#fffaf0", foreground: "#173b35" },
good: { background: "#d9ee78", foreground: "#173b35" },
warn: { background: "#f17459", foreground: "#fffaf0" },
waiting: { background: "#e3ecf8", foreground: "#28527f" }
}[tone];
person.statusLabel.userData.style = {
...person.statusLabel.userData.style,
...style
};
setSpriteText(person.statusLabel, text);
}
function setCarried(person, visible, scale = 1) {
person.carried.visible = visible;
person.carried.scale.setScalar(0.92 * scale);
}
function posePerson(person, progress, time, walking) {
const p = THREE.MathUtils.clamp(progress, 0, 1);
const point = person.route.getPointAt(p);
const tangent = person.route.getTangentAt(Math.min(p, 0.999));
person.root.position.copy(point);
person.root.rotation.y = Math.atan2(tangent.x, tangent.z);
const swing = walking ? Math.sin(time * 9.5) * 0.58 : 0;
person.leftLeg.rotation.x = swing;
person.rightLeg.rotation.x = -swing;
person.leftArm.rotation.x = -swing * 0.65;
person.rightArm.rotation.x = swing * 0.65;
}
function deliverParcel(person, labelText = "REQ-042") {
const parcel = createParcel(1.08);
const destination = person.route.getPointAt(1);
parcel.position.set(
destination.x + (person === maya ? -0.12 : 0.18),
0.35,
destination.z + (person === maya ? -0.06 : 0.18)
);
parcel.rotation.y = person === maya ? -0.08 : 0.12;
const label = createTextSprite(labelText, {
width: 1.18,
height: 0.3,
background: "#fffaf0",
foreground: "#173b35",
fontSize: 39
});
label.position.set(0, 0.55, 0.02);
parcel.add(label);
parcel.scale.setScalar(0.01);
parcel.userData.birth = performance.now() / 1000;
scene.add(parcel);
deliveredPackages.push(parcel);
}
function resetWorld() {
maya.root.position.copy(maya.start);
noah.root.position.copy(noah.start);
maya.root.rotation.y = 0;
noah.root.rotation.y = 0;
posePerson(maya, 0, 0, false);
posePerson(noah, 0, 0, false);
setCarried(maya, false);
setCarried(noah, false);
setStatus(maya, "READY");
setStatus(noah, "READY");
mayaLine.visible = false;
noahLine.visible = false;
deliveredPackages.forEach((parcel) => scene.remove(parcel));
deliveredPackages.length = 0;
}
// HUD and event log.
const headline = document.getElementById("headline");
const description = document.getElementById("description");
const requestState = document.getElementById("requestState");
const requestPill = document.querySelector(".request-pill");
const feed = document.getElementById("feed");
const timelineFill = document.getElementById("timelineFill");
const phaseLabel = document.getElementById("phaseLabel");
const timeLabel = document.getElementById("timeLabel");
const metricDelivery = document.getElementById("deliveryMetric");
const metricDispatch = document.getElementById("dispatchMetric");
const metricRecord = document.getElementById("recordMetric");
const metricBlocked = document.getElementById("blockedMetric");
function setMetrics({
deliveries = 0,
dispatched = 0,
records = 0,
blocked = 0
}) {
document.getElementById("deliveryCount").textContent = deliveries;
document.getElementById("dispatchCount").textContent = dispatched;
document.getElementById("recordCount").textContent = records;
document.getElementById("blockedCount").textContent = blocked;
metricDelivery.classList.toggle("alert", deliveries > 1);
metricDelivery.classList.toggle("good", deliveries === 1);
metricDispatch.classList.toggle("alert", dispatched > 1);
metricDispatch.classList.toggle("good", dispatched === 1);
metricRecord.classList.toggle("good", records > 0);
metricBlocked.classList.toggle("good", blocked > 0);
}
function addFeed(text, tone = "neutral", time = "10:41") {
const item = document.createElement("div");
item.className = `feed-item ${tone}`;
const stamp = document.createElement("time");
stamp.textContent = time;
const copy = document.createElement("div");
copy.textContent = text;
item.append(stamp, copy);
feed.prepend(item);
while (feed.children.length > 5) {
feed.lastElementChild.remove();
}
}
function pulseRequest() {
requestPill.classList.remove("request-pulse");
void requestPill.offsetWidth;
requestPill.classList.add("request-pulse");
}
function setStory(title, copy, requestText) {
headline.textContent = title;
description.textContent = copy;
requestState.textContent = requestText;
}
addFeed("REQ-042 created for the same recipient.", "neutral", "10:40");
// Scenario state machine.
let modeQueue = [];
let activeMode = null;
let modeTime = 0;
let paused = false;
let boardVisible = false;
let boardReveal = 0;
let blindPicked = false;
let blindDropped = false;
let sharedClaimed = false;
let sharedDropped = false;
let sharedReplayed = false;
const modeDurations = {
blind: 11,
reveal: 2,
shared: 10
};
function startBlind() {
resetWorld();
boardVisible = false;
boardReveal = 0;
boardState = "waiting";
drawBoard();
blindPicked = false;
blindDropped = false;
setStory(
"Completion information is missing.",
"The same request reaches both volunteers. Because neither can see that the delivery is already being handled, both set out.",
"Dispatching"
);
setMetrics({ deliveries: 0, dispatched: 2, records: 0, blocked: 0 });
setStatus(maya, "REQ-042 · SENT", "warn");
setStatus(noah, "REQ-042 · SENT", "warn");
addFeed(
"REQ-042 dispatched to Maya and Noah; no completion record.",
"warn",
"10:41"
);
}
function updateBlind(t) {
if (!blindPicked && t >= 1.3) {
blindPicked = true;
setCarried(maya, true);
setCarried(noah, true);
mayaLine.visible = true;
noahLine.visible = true;
addFeed(
"Both volunteers accepted the same request.",
"warn",
"10:41"
);
}
if (t >= 2) {
const p = (t - 2) / 6.2;
posePerson(maya, p, t, p < 1);
posePerson(noah, p, t, p < 1);
}
if (!blindDropped && t >= 8.3) {
blindDropped = true;
setCarried(maya, false);
setCarried(noah, false);
deliverParcel(maya);
deliverParcel(noah);
setStatus(maya, "DELIVERED · REQ-042", "warn");
setStatus(noah, "DELIVERED · REQ-042", "warn");
setMetrics({ deliveries: 2, dispatched: 2, records: 0, blocked: 0 });
setStory(
"The same delivery arrived twice.",
"Each volunteer completed a valid-looking route. The missing completion signal made the duplicate invisible until both packages reached the porch.",
"Duplicate confirmed"
);
addFeed(
"Two REQ-042 packages arrived at the recipient.",
"warn",
"10:43"
);
}
if (t >= 9.3 && requestState.textContent !== "Duplicate") {
requestState.textContent = "Duplicate";
addFeed(
"Completion information was never shared with the second volunteer.",
"warn",
"10:44"
);
}
}
function startReveal() {
boardVisible = true;
boardState = "waiting";
drawBoard();
setStory(
"Now give everyone the same status.",
"The shared board becomes the coordination point. A volunteer can now see a claim before accepting the same request.",
"Board revealed"
);
addFeed(
"Shared delivery status board revealed.",
"good",
"10:45"
);
}
function updateReveal(t) {
if (t > 0.7) {
requestState.textContent = "Checking shared status";
}
}
function startShared() {
resetWorld();
boardVisible = true;
boardState = "waiting";
drawBoard();
sharedClaimed = false;
sharedDropped = false;
sharedReplayed = false;
setStatus(maya, "CHECKING BOARD", "waiting");
setStatus(noah, "CHECKING BOARD", "waiting");
setStory(
"Replay the same request with shared status.",
"This is the same REQ-042, but Maya's claim is visible before Noah can accept it. The request is coordinated rather than duplicated.",
"Checking board"
);
setMetrics({ deliveries: 0, dispatched: 0, records: 0, blocked: 0 });
pulseRequest();
addFeed(
"REQ-042 replayed — checking shared board first.",
"good",
"10:46"
);
}
function updateShared(t) {
if (!sharedClaimed && t >= 1.25) {
sharedClaimed = true;
boardState = "claimed";
drawBoard();
setCarried(maya, true);
mayaLine.visible = true;
setStatus(maya, "CLAIMED · REQ-042", "good");
setStatus(noah, "WAITING · NO CLAIM", "waiting");
setMetrics({ deliveries: 0, dispatched: 1, records: 1, blocked: 0 });
addFeed(
"Maya claimed REQ-042 on the shared board.",
"good",
"10:46"
);
addFeed(
"Noah sees the claim and waits.",
"good",
"10:47"
);
}
if (t >= 2.15) {
const p = (t - 2.15) / 5.55;
posePerson(maya, p, t, p < 1);
}
if (!sharedDropped && t >= 7.8) {
sharedDropped = true;
setCarried(maya, false);
deliverParcel(maya);
boardState = "complete";
drawBoard();
setStatus(maya, "COMPLETED · REQ-042", "good");
setStatus(noah, "NO DUPLICATE", "good");
setMetrics({ deliveries: 1, dispatched: 1, records: 1, blocked: 0 });
requestState.textContent = "Completed once";
setStory(
"One request. One claim. One delivery.",
"Maya's completion is visible on the board. Noah can confidently wait instead of carrying the same package.",
"Completed once"
);
addFeed(
"Maya completed REQ-042; completion is now shared.",
"good",
"10:48"
);
}
if (!sharedReplayed && t >= 9.25) {
sharedReplayed = true;
boardState = "replay";
drawBoard();
setStatus(maya, "ALREADY COMPLETE", "good");
setStatus(noah, "ALREADY COMPLETE", "good");
setMetrics({ deliveries: 1, dispatched: 1, records: 1, blocked: 1 });
requestState.textContent = "Replay blocked safely";
setStory(
"The replay is safely blocked.",
"The exact same request is received again, but the shared completion record says it is done. No second package is created.",
"Already complete"
);
pulseRequest();
addFeed(
"REQ-042 replay received — board says already complete.",
"good",
"10:49"
);
addFeed(
"Duplicate dispatch blocked. Delivery total remains one.",
"good",
"10:49"
);
}
}
const modes = {
blind: { start: startBlind, update: updateBlind },
reveal: { start: startReveal, update: updateReveal },
shared: { start: startShared, update: updateShared }
};
function nextMode() {
if (!modeQueue.length) {
activeMode = null;
phaseLabel.textContent = "Comparison complete";
timelineFill.style.width = "100%";
setMetrics({ deliveries: 1, dispatched: 1, records: 1, blocked: 1 });
setStory(
"Better coordination, not extra work.",
"The outcome changes from two deliveries to one: the shared board exposes claims and completion before another volunteer accepts the same request.",
"1 delivery · 0 duplicates"
);
addFeed(
"Comparison complete: 2 deliveries → 1 delivery.",
"good",
"10:50"
);
return;
}
activeMode = modeQueue.shift();
modeTime = 0;
modes[activeMode].start();
}
function runScenario(queue) {
modeQueue = [...queue];
modeTime = 0;
activeMode = null;
nextMode();
}
document.getElementById("runAll").addEventListener("click", () => {
runScenario(["blind", "reveal", "shared"]);
});
document.getElementById("runBlind").addEventListener("click", () => {
runScenario(["blind"]);
});
document.getElementById("runShared").addEventListener("click", () => {
runScenario(["reveal", "shared"]);
});
document.getElementById("pause").addEventListener("click", (event) => {
paused = !paused;
event.currentTarget.textContent = paused ? "Resume" : "Pause";
});
window.addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "r") {
runScenario(["blind", "reveal", "shared"]);
}
});
function damp(current, target, lambda, dt) {
return THREE.MathUtils.lerp(
current,
target,
1 - Math.exp(-lambda * dt)
);
}
function easeOutBack(value) {
const c1 = 1.70158;
const c3 = c1 + 1;
return 1 + c3 * Math.pow(value - 1, 3) + c1 * Math.pow(value - 1, 2);
}
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
if (!paused && activeMode) {
modeTime += dt;
modes[activeMode].update(modeTime);
const duration = modeDurations[activeMode];
const progress = THREE.MathUtils.clamp(modeTime / duration, 0, 1);
timelineFill.style.width = `${progress * 100}%`;
const phaseNames = {
blind: "Without shared completion",
reveal: "Revealing shared status",
shared: "Coordinated replay"
};
phaseLabel.textContent = phaseNames[activeMode];
timeLabel.textContent = `00:${String(
Math.floor(modeTime)
).padStart(2, "0")}`;
if (modeTime >= duration) {
nextMode();
}
}
boardReveal = damp(
boardReveal,
boardVisible ? 1 : 0,
4.8,
dt
);
boardGroup.visible = boardReveal > 0.005;
boardGroup.position.y = -2.7 * (1 - boardReveal);
const now = performance.now() / 1000;
deliveredPackages.forEach((parcel) => {
const age = now - parcel.userData.birth;
const scale = Math.min(1, Math.max(0, age / 0.55));
parcel.scale.setScalar(Math.max(0.01, easeOutBack(scale)));
});
const bob = Math.sin(performance.now() * 0.0012) * 0.035;
boardLight.position.y = 3.48 + bob;
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);
});
runScenario(["blind", "reveal", "shared"]);
animate();
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("hidden");
});
</script>
</body>
</html>
```