Prompt specification
Build or customize the Three.js 3D scene "Task blocks with dependency connectors" 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: Task blocks with dependency connectors
Category: Algorithms & Systems · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/task-blocks-with-dependency-connectors-x1901
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows task scheduling with dependencies. Build a small directed acyclic task graph with duration blocks and one shared worker track; distinguish prerequisite edges from physical proximity on the board. Low-poly.
Working Three.js Starter (task-blocks-with-dependency-connectors-x1901):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dependency Rail — Shared Worker Scheduler</title>
<style>
:root {
color-scheme: dark;
--bg: #07131b;
--panel: rgba(10, 25, 34, 0.88);
--panel-border: rgba(139, 190, 209, 0.15);
--text: #e8f4f7;
--muted: #7f9aa6;
--cyan: #52dcff;
--amber: #ffb23e;
--green: #58d7b2;
--slate: #738995;
--pink: #ef79b1;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
select {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 52% 46%, transparent 32%, rgba(0, 7, 12, 0.22) 75%),
linear-gradient(to bottom, rgba(4, 12, 18, 0.18), transparent 20%, transparent 70%, rgba(4, 12, 18, 0.45));
z-index: 1;
}
.topbar {
position: fixed;
z-index: 10;
top: 0;
left: 0;
right: 0;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 24px;
padding: 24px 26px;
pointer-events: none;
}
.brand {
max-width: 410px;
pointer-events: none;
text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
color: var(--cyan);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.22em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 24px;
height: 1px;
background: currentColor;
box-shadow: 0 0 8px currentColor;
}
h1 {
margin: 0;
font-size: clamp(27px, 3vw, 42px);
line-height: 1;
letter-spacing: -0.045em;
font-weight: 760;
}
.brand p {
max-width: 360px;
margin: 11px 0 0;
color: #9bb3bd;
font-size: 12px;
line-height: 1.55;
}
.control-cluster {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 11px;
pointer-events: auto;
}
.controls {
display: flex;
align-items: center;
gap: 8px;
padding: 8px;
border: 1px solid var(--panel-border);
border-radius: 13px;
background: var(--panel);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
backdrop-filter: blur(14px);
}
.controls button,
.controls select {
height: 36px;
border: 1px solid rgba(139, 190, 209, 0.16);
border-radius: 8px;
background: rgba(255, 255, 255, 0.035);
color: #c8dbe1;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.03em;
}
.controls button {
min-width: 72px;
padding: 0 13px;
cursor: pointer;
transition: 160ms ease;
}
.controls button:hover {
border-color: rgba(82, 220, 255, 0.45);
background: rgba(82, 220, 255, 0.08);
color: white;
}
#playButton {
border-color: rgba(255, 178, 62, 0.32);
background: rgba(255, 178, 62, 0.12);
color: #ffd591;
}
.controls select {
padding: 0 28px 0 10px;
cursor: pointer;
}
.worker-status {
display: flex;
align-items: center;
gap: 9px;
padding: 8px 12px;
border: 1px solid var(--panel-border);
border-radius: 999px;
background: rgba(8, 22, 30, 0.76);
color: #a9c0c9;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
backdrop-filter: blur(12px);
}
.status-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--amber);
box-shadow: 0 0 10px var(--amber);
animation: statusPulse 1.3s ease-in-out infinite;
}
@keyframes statusPulse {
50% {
opacity: 0.45;
transform: scale(0.75);
}
}
.side-panel {
position: fixed;
z-index: 9;
top: 144px;
left: 24px;
width: 258px;
max-height: calc(100vh - 270px);
overflow: hidden;
border: 1px solid var(--panel-border);
border-radius: 15px;
background: var(--panel);
box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
backdrop-filter: blur(18px);
}
.panel-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 10px;
padding: 16px 16px 13px;
border-bottom: 1px solid rgba(139, 190, 209, 0.1);
}
.panel-kicker {
margin-bottom: 4px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.panel-head h2 {
margin: 0;
font-size: 14px;
letter-spacing: -0.02em;
}
.completion {
color: var(--green);
font-size: 11px;
font-weight: 800;
white-space: nowrap;
}
.task-list {
max-height: calc(100vh - 368px);
overflow-y: auto;
padding: 7px;
scrollbar-width: thin;
scrollbar-color: #29414d transparent;
}
.task-row {
position: relative;
display: grid;
grid-template-columns: 30px 1fr auto;
gap: 10px;
align-items: center;
padding: 10px 9px;
border: 1px solid transparent;
border-radius: 9px;
cursor: pointer;
transition: 150ms ease;
}
.task-row:hover,
.task-row.selected {
border-color: rgba(82, 220, 255, 0.16);
background: rgba(82, 220, 255, 0.045);
}
.task-index {
display: grid;
place-items: center;
width: 28px;
height: 28px;
border: 1px solid color-mix(in srgb, var(--task-color), transparent 65%);
border-radius: 7px;
color: var(--task-color);
background: color-mix(in srgb, var(--task-color), transparent 90%);
font-size: 10px;
font-weight: 850;
}
.task-copy {
min-width: 0;
}
.task-name {
overflow: hidden;
color: #dce9ed;
font-size: 11px;
font-weight: 760;
text-overflow: ellipsis;
white-space: nowrap;
}
.task-deps {
overflow: hidden;
margin-top: 3px;
color: #66818d;
font-size: 9px;
text-overflow: ellipsis;
white-space: nowrap;
}
.task-state {
color: #78939e;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.task-row.active {
background: rgba(255, 178, 62, 0.07);
}
.task-row.active .task-state {
color: var(--amber);
}
.task-row.done .task-state {
color: var(--green);
}
.panel-note {
padding: 11px 15px 13px;
border-top: 1px solid rgba(139, 190, 209, 0.1);
color: #66818d;
font-size: 9px;
line-height: 1.55;
}
.legend {
position: fixed;
z-index: 9;
right: 25px;
bottom: 132px;
width: 230px;
padding: 13px 15px;
border: 1px solid var(--panel-border);
border-radius: 13px;
background: rgba(9, 23, 31, 0.8);
backdrop-filter: blur(14px);
box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
}
.legend-title {
margin-bottom: 10px;
color: #7f9aa6;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.legend-item {
display: grid;
grid-template-columns: 35px 1fr;
gap: 10px;
align-items: center;
margin-top: 8px;
color: #a7bcc4;
font-size: 10px;
}
.legend-swatch {
position: relative;
height: 10px;
}
.legend-swatch.dependency {
height: 2px;
background: var(--cyan);
box-shadow: 0 0 7px rgba(82, 220, 255, 0.7);
}
.legend-swatch.dependency::after {
content: "";
position: absolute;
right: -1px;
top: -3px;
border-top: 4px solid transparent;
border-bottom: 4px solid transparent;
border-left: 6px solid var(--cyan);
}
.legend-swatch.track {
height: 4px;
border-radius: 4px;
background: var(--amber);
box-shadow: 0 0 7px rgba(255, 178, 62, 0.55);
}
.legend-swatch.proximity {
height: 0;
border-top: 2px dashed var(--slate);
}
.timeline-panel {
position: fixed;
z-index: 9;
left: 306px;
right: 25px;
bottom: 22px;
padding: 13px 16px 12px;
border: 1px solid var(--panel-border);
border-radius: 14px;
background: rgba(8, 22, 30, 0.88);
box-shadow: 0 20px 55px rgba(0, 0, 0, 0.34);
backdrop-filter: blur(16px);
}
.timeline-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 9px;
}
.timeline-title {
color: #9cb2bb;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.timeline-time {
color: #dcebef;
font-size: 11px;
font-variant-numeric: tabular-nums;
font-weight: 750;
}
.timeline-time span {
color: #627d89;
font-weight: 500;
}
.timeline-track {
position: relative;
height: 34px;
overflow: hidden;
border: 1px solid rgba(139, 190, 209, 0.1);
border-radius: 8px;
background: rgba(255, 255, 255, 0.025);
}
.timeline-segment {
position: absolute;
top: 4px;
bottom: 4px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
border-right: 2px solid #0a1921;
cursor: pointer;
}
.timeline-task {
padding: 9px 6px 0;
color: rgba(4, 16, 21, 0.86);
font-size: 8px;
font-weight: 900;
letter-spacing: 0.035em;
text-transform: uppercase;
}
.timeline-task.done {
filter: saturate(0.72) brightness(1.12);
}
.timeline-task.active {
box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.48);
}
.timeline-transit {
background: repeating-linear-gradient(
-45deg,
rgba(115, 137, 149, 0.16),
rgba(115, 137, 149, 0.16) 4px,
rgba(115, 137, 149, 0.05) 4px,
rgba(115, 137, 149, 0.05) 8px
);
}
.playhead {
position: absolute;
z-index: 3;
top: -2px;
bottom: -2px;
width: 2px;
background: white;
box-shadow: 0 0 10px rgba(255, 255, 255, 0.85);
pointer-events: none;
}
.playhead::before {
content: "";
position: absolute;
top: 0;
left: -3px;
border-top: 5px solid white;
border-right: 4px solid transparent;
border-left: 4px solid transparent;
}
.timeline-foot {
display: flex;
justify-content: space-between;
margin-top: 7px;
color: #5f7984;
font-size: 8px;
letter-spacing: 0.04em;
}
#labels {
position: fixed;
inset: 0;
z-index: 5;
overflow: hidden;
pointer-events: none;
}
.task-label {
position: absolute;
display: flex;
align-items: center;
gap: 7px;
min-width: 96px;
padding: 6px 8px;
transform: translate(-50%, -100%);
border: 1px solid rgba(137, 186, 201, 0.2);
border-radius: 7px;
background: rgba(6, 19, 26, 0.86);
color: #d6e6eb;
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.025em;
white-space: nowrap;
pointer-events: auto;
cursor: pointer;
backdrop-filter: blur(8px);
transition: border-color 150ms ease, box-shadow 150ms ease;
}
.task-label:hover,
.task-label.selected {
border-color: rgba(82, 220, 255, 0.65);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.34), 0 0 15px rgba(82, 220, 255, 0.12);
}
.task-label.active {
border-color: rgba(255, 178, 62, 0.8);
box-shadow: 0 0 18px rgba(255, 178, 62, 0.18);
}
.task-label.done {
border-color: rgba(88, 215, 178, 0.5);
}
.label-dot {
width: 6px;
height: 6px;
flex: 0 0 auto;
border-radius: 2px;
background: var(--task-color);
box-shadow: 0 0 7px var(--task-color);
}
.label-duration {
margin-left: auto;
color: #78939e;
font-size: 8px;
font-variant-numeric: tabular-nums;
}
.proximity-label {
position: absolute;
padding: 3px 5px;
transform: translate(-50%, -50%);
border: 1px dashed rgba(115, 137, 149, 0.6);
border-radius: 4px;
background: rgba(7, 19, 26, 0.78);
color: #8299a3;
font-size: 7px;
font-weight: 850;
letter-spacing: 0.1em;
pointer-events: none;
}
.hint {
position: fixed;
z-index: 7;
left: 50%;
bottom: 118px;
transform: translateX(-50%);
color: rgba(151, 178, 188, 0.5);
font-size: 8px;
letter-spacing: 0.08em;
pointer-events: none;
white-space: nowrap;
}
@media (max-width: 900px) {
.side-panel {
display: none;
}
.timeline-panel {
left: 20px;
}
.legend {
bottom: 124px;
right: 20px;
}
.hint {
display: none;
}
}
@media (max-width: 620px) {
.topbar {
padding: 17px;
}
.brand p,
.worker-status {
display: none;
}
.controls {
gap: 5px;
padding: 6px;
}
.controls button {
min-width: 42px;
padding: 0 8px;
}
.controls select {
width: 60px;
padding-left: 7px;
}
.legend {
display: none;
}
.timeline-panel {
left: 12px;
right: 12px;
bottom: 12px;
}
.task-label {
min-width: 72px;
padding: 5px 6px;
font-size: 8px;
}
.label-duration {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive three-dimensional dependency scheduler"></canvas>
<div class="vignette"></div>
<div id="labels"></div>
<header class="topbar">
<div class="brand">
<div class="eyebrow">Resource flow / DAG 06</div>
<h1>Dependency Rail</h1>
<p>
One shared worker follows a dependency-safe sequence.
Prerequisites float above the board; physical proximity stays on the board.
</p>
</div>
<div class="control-cluster">
<div class="worker-status">
<span class="status-dot"></span>
<span id="workerStatus">Worker 01 · Ready</span>
</div>
<div class="controls">
<button id="playButton" type="button">▶ Play</button>
<button id="resetButton" type="button" title="Reset simulation">Reset</button>
<select id="speedSelect" aria-label="Simulation speed">
<option value="0.5">0.5×</option>
<option value="1" selected>1×</option>
<option value="2">2×</option>
<option value="4">4×</option>
</select>
</div>
</div>
</header>
<aside class="side-panel">
<div class="panel-head">
<div>
<div class="panel-kicker">Shared resource</div>
<h2>Task queue</h2>
</div>
<div id="completionMetric" class="completion">0 / 6</div>
</div>
<div id="taskList" class="task-list"></div>
<div class="panel-note">
The schedule is topologically ordered. Worker 01 may execute only one task
at a time; gaps in the timeline represent travel along the rail.
</div>
</aside>
<div class="legend">
<div class="legend-title">Reading the board</div>
<div class="legend-item">
<div class="legend-swatch dependency"></div>
<span>Elevated arrow · prerequisite</span>
</div>
<div class="legend-item">
<div class="legend-swatch track"></div>
<span>Amber rail · worker travel</span>
</div>
<div class="legend-item">
<div class="legend-swatch proximity"></div>
<span>Dashed line · proximity only</span>
</div>
</div>
<div class="hint">DRAG TO ORBIT · SHIFT-DRAG TO PAN · SCROLL TO ZOOM · SPACE TO PLAY</div>
<section class="timeline-panel">
<div class="timeline-head">
<div class="timeline-title">Shared worker schedule</div>
<div class="timeline-time">
<span id="currentTime">00:00.0</span>
<span> / <span id="totalTime">00:00.0</span></span>
</div>
</div>
<div id="timelineTrack" class="timeline-track">
<div id="playhead" class="playhead" style="left: 0%"></div>
</div>
<div class="timeline-foot">
<span>Tasks run sequentially · striped gaps are worker transit</span>
<span>Click a segment to seek</span>
</div>
</section>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Scene setup
// -------------------------------------------------------------------------
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
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;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07131b);
scene.fog = new THREE.Fog(0x07131b, 21, 42);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraState = {
theta: 0.48,
phi: 1.02,
radius: 19.5,
target: new THREE.Vector3(0, 0.45, 0)
};
const hemisphere = new THREE.HemisphereLight(0xbcecff, 0x15242c, 2.2);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff1dc, 3.1);
keyLight.position.set(6, 12, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -12;
keyLight.shadow.camera.right = 12;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.normalBias = 0.03;
scene.add(keyLight);
const cyanFill = new THREE.PointLight(0x4bd8ff, 24, 25, 2);
cyanFill.position.set(-7, 6, -4);
scene.add(cyanFill);
const amberFill = new THREE.PointLight(0xff9e35, 18, 18, 2);
amberFill.position.set(6, 4, 5);
scene.add(amberFill);
// -------------------------------------------------------------------------
// Data and scheduler
// -------------------------------------------------------------------------
const taskColors = {
intake: 0x6da9ff,
concept: 0x9a87ff,
build: 0xff8e5c,
surface: 0xffca58,
integrate: 0x52d6b0,
release: 0xef79b1
};
const tasks = [
{
id: "intake",
name: "Intake",
duration: 2,
deps: [],
position: [-5.3, 1.5]
},
{
id: "concept",
name: "Concept",
duration: 4,
deps: ["intake"],
position: [4.2, 2.2]
},
{
id: "build",
name: "Build core",
duration: 5,
deps: ["concept"],
position: [-3.6, -2.4]
},
{
id: "surface",
name: "Surface pass",
duration: 3,
deps: ["concept"],
position: [5.15, -1.65]
},
{
id: "integrate",
name: "Integrate",
duration: 4,
deps: ["build", "surface"],
position: [0.05, 0.1]
},
{
id: "release",
name: "Release",
duration: 2,
deps: ["integrate"],
position: [2.6, 3.85]
}
];
const byId = Object.fromEntries(tasks.map(task => [task.id, task]));
function topologicalOrder(items) {
const indegree = Object.fromEntries(items.map(task => [task.id, task.deps.length]));
const queue = items.filter(task => task.deps.length === 0).map(task => task.id);
const result = [];
while (queue.length) {
const id = queue.shift();
result.push(id);
for (const task of items) {
if (!task.deps.includes(id)) continue;
indegree[task.id] -= 1;
if (indegree[task.id] === 0) queue.push(task.id);
}
}
return result.map(id => byId[id]);
}
const order = topologicalOrder(tasks);
const TRANSIT_TIME = 0.85;
const transits = [];
let scheduleCursor = 0;
order.forEach((task, index) => {
if (index > 0) {
const transit = {
from: order[index - 1],
to: task,
start: scheduleCursor,
end: scheduleCursor + TRANSIT_TIME
};
transits.push(transit);
scheduleCursor = transit.end;
}
task.start = scheduleCursor;
task.end = scheduleCursor + task.duration;
task.pathT = index / Math.max(1, order.length - 1);
scheduleCursor = task.end;
});
const totalDuration = scheduleCursor;
let simulationTime = 0;
let playing = false;
let playbackSpeed = 1;
let selectedTaskId = "integrate";
// -------------------------------------------------------------------------
// Board
// -------------------------------------------------------------------------
const boardGroup = new THREE.Group();
scene.add(boardGroup);
const boardMaterial = new THREE.MeshStandardMaterial({
color: 0x0d2029,
roughness: 0.88,
metalness: 0.08
});
const board = new THREE.Mesh(
new THREE.BoxGeometry(16, 0.42, 10.8),
boardMaterial
);
board.position.y = -0.26;
board.receiveShadow = true;
boardGroup.add(board);
const lowerDeck = new THREE.Mesh(
new THREE.BoxGeometry(16.35, 0.26, 11.15),
new THREE.MeshStandardMaterial({
color: 0x07151d,
roughness: 0.75,
metalness: 0.2
})
);
lowerDeck.position.y = -0.58;
lowerDeck.castShadow = true;
lowerDeck.receiveShadow = true;
boardGroup.add(lowerDeck);
const boardEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(board.geometry),
new THREE.LineBasicMaterial({
color: 0x284653,
transparent: true,
opacity: 0.7
})
);
boardEdges.position.copy(board.position);
boardGroup.add(boardEdges);
const gridPositions = [];
for (let x = -8; x <= 8; x += 2) {
gridPositions.push(x, -0.035, -5.35, x, -0.035, 5.35);
}
for (let z = -5; z <= 5; z += 2) {
gridPositions.push(-7.95, -0.035, z, 7.95, -0.035, z);
}
const gridGeometry = new THREE.BufferGeometry();
gridGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(gridPositions, 3)
);
const grid = new THREE.LineSegments(
gridGeometry,
new THREE.LineBasicMaterial({
color: 0x1b3945,
transparent: true,
opacity: 0.42
})
);
boardGroup.add(grid);
const boltMaterial = new THREE.MeshStandardMaterial({
color: 0x41606c,
roughness: 0.4,
metalness: 0.65
});
for (const x of [-7.55, 7.55]) {
for (const z of [-4.95, 4.95]) {
const bolt = new THREE.Mesh(
new THREE.CylinderGeometry(0.11, 0.11, 0.07, 6),
boltMaterial
);
bolt.position.set(x, 0.01, z);
boardGroup.add(bolt);
}
}
for (const x of [-6.5, 6.5]) {
for (const z of [-4.2, 4.2]) {
const foot = new THREE.Mesh(
new THREE.CylinderGeometry(0.23, 0.3, 0.65, 6),
new THREE.MeshStandardMaterial({
color: 0x0a171e,
roughness: 0.72,
metalness: 0.2
})
);
foot.position.set(x, -0.9, z);
foot.castShadow = true;
boardGroup.add(foot);
}
}
// -------------------------------------------------------------------------
// Shared worker rail
// -------------------------------------------------------------------------
const railPoints = order.map(task =>
new THREE.Vector3(task.position[0], 0.09, task.position[1])
);
const railCurve = new THREE.CatmullRomCurve3(
railPoints,
false,
"catmullrom",
0.08
);
const railShadow = new THREE.Mesh(
new THREE.TubeGeometry(railCurve, 190, 0.14, 4, false),
new THREE.MeshStandardMaterial({
color: 0x33434a,
roughness: 0.62,
metalness: 0.35
})
);
railShadow.receiveShadow = true;
boardGroup.add(railShadow);
const rail = new THREE.Mesh(
new THREE.TubeGeometry(railCurve, 190, 0.058, 4, false),
new THREE.MeshStandardMaterial({
color: 0xffb23e,
emissive: 0x8b3f05,
emissiveIntensity: 0.75,
roughness: 0.36,
metalness: 0.18
})
);
boardGroup.add(rail);
for (const point of railPoints) {
const station = new THREE.Mesh(
new THREE.TorusGeometry(0.23, 0.026, 4, 16),
new THREE.MeshBasicMaterial({
color: 0xffc15b,
transparent: true,
opacity: 0.85
})
);
station.rotation.x = Math.PI / 2;
station.position.copy(point);
station.position.y = 0.012;
boardGroup.add(station);
}
// -------------------------------------------------------------------------
// Task blocks
// -------------------------------------------------------------------------
const taskMeshes = [];
const taskVisuals = {};
for (const task of tasks) {
const width = 1.2 + task.duration * 0.3;
const depth = 1.24;
const group = new THREE.Group();
group.position.set(task.position[0], 0, task.position[1]);
boardGroup.add(group);
const stem = new THREE.Mesh(
new THREE.CylinderGeometry(0.11, 0.17, 0.58, 6),
new THREE.MeshStandardMaterial({
color: 0x263d47,
roughness: 0.65,
metalness: 0.3
})
);
stem.position.y = 0.3;
stem.castShadow = true;
group.add(stem);
const topMaterial = new THREE.MeshStandardMaterial({
color: 0x47616d,
emissive: 0x10252d,
emissiveIntensity: 0.45,
roughness: 0.64,
metalness: 0.12
});
const sideMaterial = new THREE.MeshStandardMaterial({
color: 0x182c35,
roughness: 0.78,
metalness: 0.18
});
const blockGeometry = new THREE.BoxGeometry(width, 0.42, depth);
const block = new THREE.Mesh(
blockGeometry,
[
sideMaterial,
sideMaterial,
topMaterial,
sideMaterial,
sideMaterial,
sideMaterial
]
);
block.position.y = 0.84;
block.castShadow = true;
block.receiveShadow = true;
block.userData.taskId = task.id;
group.add(block);
taskMeshes.push(block);
const outlineMaterial = new THREE.LineBasicMaterial({
color: 0x5c7c88,
transparent: true,
opacity: 0.62
});
const outline = new THREE.LineSegments(
new THREE.EdgesGeometry(blockGeometry),
outlineMaterial
);
outline.position.copy(block.position);
group.add(outline);
const progressMaterial = new THREE.MeshBasicMaterial({
color: taskColors[task.id],
transparent: true,
opacity: 0.95
});
const progress = new THREE.Mesh(
new THREE.BoxGeometry(1, 0.035, 0.105),
progressMaterial
);
progress.position.set(-width / 2, 1.065, -0.37);
progress.scale.x = 0.001;
group.add(progress);
const haloMaterial = new THREE.MeshBasicMaterial({
color: 0xffb23e,
transparent: true,
opacity: 0,
side: THREE.DoubleSide,
depthWrite: false
});
const halo = new THREE.Mesh(
new THREE.RingGeometry(0.58, 0.68, 24),
haloMaterial
);
halo.rotation.x = -Math.PI / 2;
halo.position.set(task.position[0], 0.018, task.position[1]);
boardGroup.add(halo);
taskVisuals[task.id] = {
group,
width,
block,
topMaterial,
sideMaterial,
outlineMaterial,
progress,
progressMaterial,
halo,
haloMaterial,
status: "pending",
progressValue: 0
};
}
// -------------------------------------------------------------------------
// Elevated prerequisite arrows
// -------------------------------------------------------------------------
const dependencyEdges = [];
for (const task of tasks) {
for (const dependencyId of task.deps) {
const from = byId[dependencyId];
const to = task;
const start = new THREE.Vector3(
from.position[0],
1.18,
from.position[1]
);
const end = new THREE.Vector3(
to.position[0],
1.18,
to.position[1]
);
const midpoint = start.clone().add(end).multiplyScalar(0.5);
const distance = start.distanceTo(end);
midpoint.y = 2.65 + distance * 0.14;
midpoint.x += (dependencyEdges.length % 2 === 0 ? -0.22 : 0.22);
const curve = new THREE.QuadraticBezierCurve3(
start,
midpoint,
end
);
const material = new THREE.MeshBasicMaterial({
color: 0x52dcff,
transparent: true,
opacity: 0.78,
depthTest: false,
depthWrite: false
});
const tube = new THREE.Mesh(
new THREE.TubeGeometry(curve, 48, 0.035, 5, false),
material
);
tube.renderOrder = 20;
boardGroup.add(tube);
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.14, 0.36, 5),
material
);
arrow.position.copy(curve.getPoint(1));
arrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
curve.getTangent(1).normalize()
);
arrow.renderOrder = 21;
boardGroup.add(arrow);
dependencyEdges.push({
from: dependencyId,
to: task.id,
material,
curve
});
}
}
// -------------------------------------------------------------------------
// Physical proximity links: board-level and intentionally non-prerequisite
// -------------------------------------------------------------------------
const proximityPairs = [
["intake", "build"],
["concept", "surface"],
["build", "integrate"],
["concept", "release"]
];
const proximityEdges = [];
for (const [fromId, toId] of proximityPairs) {
const from = byId[fromId];
const to = byId[toId];
const start = new THREE.Vector3(
from.position[0],
0.025,
from.position[1]
);
const end = new THREE.Vector3(
to.position[0],
0.025,
to.position[1]
);
const material = new THREE.LineDashedMaterial({
color: 0x738995,
dashSize: 0.18,
gapSize: 0.14,
transparent: true,
opacity: 0.62
});
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([start, end]),
material
);
line.computeLineDistances();
boardGroup.add(line);
const label = document.createElement("div");
label.className = "proximity-label";
label.textContent = "NEAR · ONLY";
document.querySelector("#labels").appendChild(label);
proximityEdges.push({
from: fromId,
to: toId,
material,
label,
midpoint: start.clone().add(end).multiplyScalar(0.5)
});
}
// -------------------------------------------------------------------------
// Worker model
// -------------------------------------------------------------------------
const worker = new THREE.Group();
boardGroup.add(worker);
const workerRig = new THREE.Group();
worker.add(workerRig);
const workerBody = new THREE.Mesh(
new THREE.CylinderGeometry(0.16, 0.21, 0.28, 6),
new THREE.MeshStandardMaterial({
color: 0xff8a28,
emissive: 0x5c1d00,
emissiveIntensity: 0.55,
roughness: 0.5
})
);
workerBody.position.y = 0.15;
workerBody.castShadow = true;
workerRig.add(workerBody);
const workerHead = new THREE.Mesh(
new THREE.SphereGeometry(0.115, 8, 5),
new THREE.MeshStandardMaterial({
color: 0xe5c3a1,
roughness: 0.82
})
);
workerHead.position.y = 0.36;
workerHead.castShadow = true;
workerRig.add(workerHead);
const helmet = new THREE.Mesh(
new THREE.CylinderGeometry(0.175, 0.19, 0.07, 8),
new THREE.MeshStandardMaterial({
color: 0xffca54,
emissive: 0x6d3900,
emissiveIntensity: 0.35,
roughness: 0.44
})
);
helmet.position.y = 0.445;
helmet.castShadow = true;
workerRig.add(helmet);
const workerRing = new THREE.Mesh(
new THREE.TorusGeometry(0.26, 0.027, 4, 16),
new THREE.MeshBasicMaterial({
color: 0xffc15b,
transparent: true,
opacity: 0.92
})
);
workerRing.rotation.x = Math.PI / 2;
workerRing.position.y = 0.02;
workerRig.add(workerRing);
const workerLight = new THREE.PointLight(0xff9d35, 9, 4, 2);
workerLight.position.y = 0.55;
workerRig.add(workerLight);
// -------------------------------------------------------------------------
// DOM task list, labels and timeline
// -------------------------------------------------------------------------
const taskListElement = document.querySelector("#taskList");
const labelsElement = document.querySelector("#labels");
const listRows = new Map();
const taskLabels = new Map();
tasks.forEach((task, index) => {
const row = document.createElement("div");
row.className = "task-row";
row.style.setProperty("--task-color", `#${taskColors[task.id].toString(16).padStart(6, "0")}`);
row.dataset.taskId = task.id;
const dependencyText = task.deps.length
? `after ${task.deps.map(id => byId[id].name).join(" + ")}`
: "ready · no prerequisite";
row.innerHTML = `
<div class="task-index">${String(index + 1).padStart(2, "0")}</div>
<div class="task-copy">
<div class="task-name">${task.name}</div>
<div class="task-deps">${dependencyText}</div>
</div>
<div class="task-state">${task.duration}u</div>
`;
row.addEventListener("click", () => selectTask(task.id));
taskListElement.appendChild(row);
listRows.set(task.id, row);
const label = document.createElement("button");
label.type = "button";
label.className = "task-label";
label.style.setProperty("--task-color", `#${taskColors[task.id].toString(16).padStart(6, "0")}`);
label.innerHTML = `
<span class="label-dot"></span>
<span>${task.name}</span>
<span class="label-duration">${task.duration}u</span>
`;
label.addEventListener("click", () => selectTask(task.id));
labelsElement.appendChild(label);
taskLabels.set(task.id, label);
});
const timelineTrack = document.querySelector("#timelineTrack");
const playhead = document.querySelector("#playhead");
const timelineTaskElements = new Map();
for (const transit of transits) {
const segment = document.createElement("div");
segment.className = "timeline-segment timeline-transit";
segment.style.left = `${(transit.start / totalDuration) * 100}%`;
segment.style.width = `${((transit.end - transit.start) / totalDuration) * 100}%`;
segment.title = `Travel: ${transit.from.name} → ${transit.to.name}`;
segment.addEventListener("click", () => seekTo(transit.start));
timelineTrack.appendChild(segment);
}
for (const task of order) {
const segment = document.createElement("div");
segment.className = "timeline-segment timeline-task";
segment.style.left = `${(task.start / totalDuration) * 100}%`;
segment.style.width = `${((task.end - task.start) / totalDuration) * 100}%`;
segment.style.background = `#${taskColors[task.id].toString(16).padStart(6, "0")}`;
segment.textContent = task.name;
segment.title = `${task.name} · ${task.duration} units`;
segment.addEventListener("click", () => seekTo(task.start));
timelineTrack.appendChild(segment);
timelineTaskElements.set(task.id, segment);
}
function formatTime(value) {
const minutes = Math.floor(value / 60);
const seconds = (value % 60).toFixed(1).padStart(4, "0");
return `${String(minutes).padStart(2, "0")}:${seconds}`;
}
document.querySelector("#totalTime").textContent = formatTime(totalDuration);
// -------------------------------------------------------------------------
// Selection and visual emphasis
// -------------------------------------------------------------------------
function selectTask(id) {
selectedTaskId = id;
for (const [taskId, row] of listRows) {
row.classList.toggle("selected", taskId === id);
}
for (const [taskId, label] of taskLabels) {
label.classList.toggle("selected", taskId === id);
}
for (const edge of dependencyEdges) {
const related = edge.from === id || edge.to === id;
edge.material.opacity = related ? 1 : 0.16;
edge.material.color.set(related ? 0x9beeff : 0x52dcff);
}
for (const edge of proximityEdges) {
const related = edge.from === id || edge.to === id;
edge.material.opacity = related ? 0.92 : 0.42;
edge.material.color.set(related ? 0xa2b3ba : 0x738995);
}
}
// -------------------------------------------------------------------------
// Simulation updates
// -------------------------------------------------------------------------
const pendingColor = new THREE.Color(0x47616d);
const activeColor = new THREE.Color(0xffb23e);
const doneColor = new THREE.Color(0x52d6b0);
const activeSideColor = new THREE.Color(0x644521);
const doneSideColor = new THREE.Color(0x1d5148);
const pendingSideColor = new THREE.Color(0x182c35);
function updateSimulation(now) {
let activeTask = null;
let activeTransit = null;
for (const task of tasks) {
let status = "pending";
let progress = 0;
if (simulationTime >= task.end) {
status = "done";
progress = 1;
} else if (simulationTime >= task.start) {
status = "active";
progress = (simulationTime - task.start) / task.duration;
activeTask = task;
}
const visual = taskVisuals[task.id];
visual.status = status;
visual.progressValue = progress;
if (status === "done") {
visual.topMaterial.color.copy(doneColor);
visual.topMaterial.emissive.set(0x0b3d32);
visual.sideMaterial.color.copy(doneSideColor);
visual.outlineMaterial.color.set(0x62b9a3);
visual.progressMaterial.color.set(taskColors[task.id]);
visual.progressMaterial.opacity = 0.86;
} else if (status === "active") {
visual.topMaterial.color.copy(activeColor);
visual.topMaterial.emissive.set(0x603000);
visual.sideMaterial.color.copy(activeSideColor);
visual.outlineMaterial.color.set(0xffce72);
visual.progressMaterial.color.set(0xffdc85);
visual.progressMaterial.opacity = 1;
} else {
visual.topMaterial.color.copy(pendingColor);
visual.topMaterial.emissive.set(0x10252d);
visual.sideMaterial.color.copy(pendingSideColor);
visual.outlineMaterial.color.set(0x5c7c88);
visual.progressMaterial.color.set(taskColors[task.id]);
visual.progressMaterial.opacity = 0.62;
}
visual.progress.scale.x = Math.max(0.001, visual.width * progress);
visual.progress.position.x =
-visual.width / 2 + (visual.width * progress) / 2;
visual.progress.visible = progress > 0.001;
const isSelected = task.id === selectedTaskId;
visual.outlineMaterial.opacity = isSelected ? 1 : 0.58;
visual.outlineMaterial.color.set(
isSelected ? 0x9beeff : status === "active" ? 0xffce72 : 0x5c7c88
);
const pulse = 1 + Math.sin(now * 0.004) * 0.08;
visual.haloMaterial.opacity = status === "active" ? 0.42 : 0;
visual.halo.scale.setScalar(status === "active" ? pulse : 1);
const row = listRows.get(task.id);
row.classList.toggle("active", status === "active");
row.classList.toggle("done", status === "done");
row.querySelector(".task-state").textContent =
status === "active"
? "RUN"
: status === "done"
? "DONE"
: `${task.duration}u`;
const label = taskLabels.get(task.id);
label.classList.toggle("active", status === "active");
label.classList.toggle("done", status === "done");
const timelineSegment = timelineTaskElements.get(task.id);
timelineSegment.classList.toggle("active", status === "active");
timelineSegment.classList.toggle("done", status === "done");
}
for (const transit of transits) {
if (
simulationTime >= transit.start &&
simulationTime < transit.end
) {
activeTransit = transit;
break;
}
}
if (activeTransit) {
const raw = (simulationTime - activeTransit.start) /
(activeTransit.end - activeTransit.start);
const eased = raw * raw * (3 - 2 * raw);
const globalT =
activeTransit.from.pathT +
(activeTransit.to.pathT - activeTransit.from.pathT) * eased;
const point = railCurve.getPoint(globalT);
const tangent = railCurve.getTangent(globalT).normalize();
worker.position.copy(point);
worker.rotation.y = Math.atan2(tangent.x, tangent.z);
workerRig.position.y = 0;
} else if (activeTask) {
const point = railCurve.getPoint(activeTask.pathT);
const tangent = railCurve.getTangent(activeTask.pathT).normalize();
worker.position.copy(point);
worker.rotation.y = Math.atan2(tangent.x, tangent.z);
workerRig.position.y = 0.025 + Math.sin(now * 0.012) * 0.018;
}
const completedCount = tasks.filter(task => task.end <= simulationTime).length;
document.querySelector("#completionMetric").textContent =
`${completedCount} / ${tasks.length}`;
const workerStatus = document.querySelector("#workerStatus");
if (simulationTime >= totalDuration) {
workerStatus.textContent = "Worker 01 · Complete";
} else if (activeTransit) {
workerStatus.textContent = `Worker 01 · → ${activeTransit.to.name}`;
} else if (activeTask) {
workerStatus.textContent = `Worker 01 · ${activeTask.name}`;
} else {
workerStatus.textContent = "Worker 01 · Ready";
}
document.querySelector("#currentTime").textContent =
formatTime(simulationTime);
playhead.style.left =
`${Math.min(100, (simulationTime / totalDuration) * 100)}%`;
}
// -------------------------------------------------------------------------
// Controls
// -------------------------------------------------------------------------
const playButton = document.querySelector("#playButton");
const resetButton = document.querySelector("#resetButton");
const speedSelect = document.querySelector("#speedSelect");
function updatePlayButton() {
playButton.textContent = playing ? "Ⅱ Pause" : "▶ Play";
}
function togglePlayback() {
if (simulationTime >= totalDuration) {
simulationTime = 0;
}
playing = !playing;
updatePlayButton();
}
function resetSimulation() {
simulationTime = 0;
playing = false;
updatePlayButton();
}
function seekTo(value) {
simulationTime = THREE.MathUtils.clamp(value, 0, totalDuration);
playing = false;
updatePlayButton();
}
playButton.addEventListener("click", togglePlayback);
resetButton.addEventListener("click", resetSimulation);
speedSelect.addEventListener("change", event => {
playbackSpeed = Number(event.target.value);
});
// -------------------------------------------------------------------------
// Direct camera controls — no external controls/addons
// -------------------------------------------------------------------------
let dragging = false;
let pointerMode = "orbit";
let pointerX = 0;
let pointerY = 0;
let pointerTravel = 0;
const raycaster = new THREE.Raycaster();
const pointerNdc = new THREE.Vector2();
canvas.addEventListener("pointerdown", event => {
dragging = true;
pointerMode = event.shiftKey || event.button === 2 || event.button === 1
? "pan"
: "orbit";
pointerX = event.clientX;
pointerY = event.clientY;
pointerTravel = 0;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerTravel += Math.abs(dx) + Math.abs(dy);
pointerX = event.clientX;
pointerY = event.clientY;
if (pointerMode === "orbit") {
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.006,
0.3,
1.43
);
} else {
const forward = new THREE.Vector3();
camera.getWorldDirection(forward);
forward.y = 0;
forward.normalize();
const right = new THREE.Vector3()
.crossVectors(forward, new THREE.Vector3(0, 1, 0))
.normalize();
const scale = cameraState.radius * 0.0016;
cameraState.target.addScaledVector(right, -dx * scale);
cameraState.target.addScaledVector(forward, dy * scale);
}
});
canvas.addEventListener("pointerup", event => {
dragging = false;
if (pointerTravel < 5) {
const rect = canvas.getBoundingClientRect();
pointerNdc.x =
((event.clientX - rect.left) / rect.width) * 2 - 1;
pointerNdc.y =
-((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointerNdc, camera);
const hits = raycaster.intersectObjects(taskMeshes, false);
if (hits.length) {
selectTask(hits[0].object.userData.taskId);
}
}
});
canvas.addEventListener("pointercancel", () => {
dragging = false;
});
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("wheel", event => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
10,
30
);
}, { passive: false });
function resetCamera() {
cameraState.theta = 0.48;
cameraState.phi = 1.02;
cameraState.radius = 19.5;
cameraState.target.set(0, 0.45, 0);
}
canvas.addEventListener("dblclick", resetCamera);
function focusSelectedTask() {
const task = byId[selectedTaskId];
cameraState.target.set(task.position[0], 0.5, task.position[1]);
cameraState.radius = 11;
}
window.addEventListener("keydown", event => {
if (["INPUT", "SELECT", "TEXTAREA"].includes(event.target.tagName)) return;
if (event.code === "Space") {
event.preventDefault();
togglePlayback();
} else if (event.key.toLowerCase() === "r") {
resetSimulation();
} else if (event.key.toLowerCase() === "f") {
focusSelectedTask();
}
});
function updateCamera() {
const spherical = new THREE.Spherical(
cameraState.radius,
cameraState.phi,
cameraState.theta
);
camera.position.setFromSpherical(spherical).add(cameraState.target);
camera.lookAt(cameraState.target);
}
// -------------------------------------------------------------------------
// Projected DOM labels
// -------------------------------------------------------------------------
const projectionVector = new THREE.Vector3();
function projectElement(element, worldPosition) {
projectionVector.copy(worldPosition).project(camera);
const visible =
projectionVector.z > -1 &&
projectionVector.z < 1 &&
Math.abs(projectionVector.x) < 1.2 &&
Math.abs(projectionVector.y) < 1.2;
element.style.display = visible ? "flex" : "none";
if (!visible) return;
const x = (projectionVector.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projectionVector.y * 0.5 + 0.5) * window.innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
function updateLabels() {
for (const task of tasks) {
const position = new THREE.Vector3(
task.position[0],
1.55,
task.position[1]
);
projectElement(taskLabels.get(task.id), position);
}
for (const edge of proximityEdges) {
projectElement(edge.label, edge.midpoint);
}
}
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
function onResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", onResize);
selectTask(selectedTaskId);
updateCamera();
let previousTime = performance.now();
function animate(now) {
const delta = Math.min((now - previousTime) / 1000, 0.05);
previousTime = now;
if (playing) {
simulationTime = Math.min(
totalDuration,
simulationTime + delta * playbackSpeed
);
if (simulationTime >= totalDuration) {
playing = false;
updatePlayButton();
}
}
updateCamera();
updateSimulation(now);
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```