Prompt specification
Build or customize the Three.js 3D scene "Volunteer Absence Replanning" 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: Volunteer Absence Replanning
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/volunteer-absence-replanning-x3280
Scene Description Prompt:
Create a standalone voxel scene in one HTML file using Three.js from cdnjs. Run a fictional event setup schedule, then remove one volunteer. Let users reassign tasks and identify infeasible deadlines under unchanged task durations and skill requirements.
Working Three.js Starter (volunteer-absence-replanning-x3280):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Voxel Ops — Event Setup Scheduler</title>
<style>
:root {
--bg: #07101c;
--panel: #0c1726;
--panel-2: #101e30;
--panel-3: #14263a;
--line: #20344c;
--text: #edf5ff;
--muted: #8da2b9;
--teal: #54dfc0;
--teal-dark: #1b8e7b;
--orange: #ffb454;
--red: #ff6474;
--blue: #76a9ff;
--purple: #a990ff;
--shadow: 0 18px 45px rgba(0, 0, 0, .28);
}
* { 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; }
button {
border: 0;
cursor: pointer;
}
button:disabled {
cursor: not-allowed;
opacity: .46;
}
.topbar {
height: 70px;
display: flex;
align-items: center;
gap: 20px;
padding: 0 22px;
border-bottom: 1px solid var(--line);
background: #091422;
position: relative;
z-index: 10;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
min-width: 230px;
}
.brand-icon {
width: 36px;
height: 36px;
position: relative;
transform: rotate(30deg) skewY(-8deg);
}
.brand-icon::before,
.brand-icon::after {
content: "";
position: absolute;
inset: 0;
border: 2px solid var(--teal);
}
.brand-icon::after {
transform: translate(7px, 7px);
border-color: var(--blue);
}
.brand-name {
font-size: 15px;
font-weight: 900;
letter-spacing: .14em;
}
.brand-sub {
margin-top: 3px;
color: var(--muted);
font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .12em;
}
.event-meta {
display: flex;
align-items: center;
gap: 9px;
flex: 1;
}
.meta-chip {
border: 1px solid var(--line);
background: var(--panel);
padding: 8px 10px;
color: var(--muted);
font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .06em;
white-space: nowrap;
}
.meta-chip strong {
color: var(--text);
margin-left: 5px;
}
.top-actions {
display: flex;
align-items: center;
gap: 9px;
}
.button {
min-height: 38px;
padding: 0 14px;
color: var(--text);
background: var(--panel-2);
border: 1px solid var(--line);
font-weight: 800;
font-size: 12px;
letter-spacing: .03em;
transition: .16s ease;
}
.button:hover:not(:disabled) {
border-color: #3a5777;
transform: translateY(-1px);
}
.button.primary {
color: #061511;
background: var(--teal);
border-color: var(--teal);
}
.button.danger {
color: #ffecef;
background: #4b1f2a;
border-color: #874052;
}
.button.small {
min-height: 30px;
padding: 0 10px;
font-size: 11px;
}
.layout {
height: calc(100vh - 70px);
display: grid;
grid-template-columns: 390px minmax(0, 1fr);
}
.sidebar {
overflow-y: auto;
background: var(--panel);
border-right: 1px solid var(--line);
padding: 16px;
scrollbar-width: thin;
scrollbar-color: #30465f transparent;
}
.section {
margin-bottom: 18px;
}
.section-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 0 9px;
}
.section-heading h2 {
margin: 0;
color: #cbd9e9;
font: 800 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .14em;
text-transform: uppercase;
}
.section-count {
color: var(--muted);
font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.scenario {
border: 1px solid #285166;
background:
linear-gradient(135deg, rgba(84, 223, 192, .09), transparent 55%),
var(--panel-2);
padding: 14px;
box-shadow: var(--shadow);
}
.scenario-kicker {
display: flex;
align-items: center;
gap: 8px;
color: var(--teal);
font: 800 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .12em;
}
.status-dot {
width: 8px;
height: 8px;
background: currentColor;
box-shadow: 0 0 12px currentColor;
}
.scenario h1 {
margin: 11px 0 7px;
font-size: 18px;
line-height: 1.25;
}
.scenario p {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.scenario-actions {
display: flex;
gap: 8px;
margin-top: 13px;
}
.crew-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.crew-card {
min-height: 108px;
padding: 10px;
border: 1px solid var(--line);
background: #0e1b2b;
position: relative;
}
.crew-card.removed {
border-style: dashed;
border-color: #704051;
background: rgba(255, 100, 116, .05);
opacity: .8;
}
.crew-top {
display: flex;
align-items: center;
gap: 8px;
}
.avatar {
width: 29px;
height: 29px;
display: grid;
place-items: center;
color: #08111c;
font-weight: 950;
font-size: 11px;
box-shadow: inset 0 -7px 0 rgba(0, 0, 0, .12);
}
.crew-name {
font-size: 11px;
font-weight: 850;
line-height: 1.2;
}
.crew-shift {
margin-top: 2px;
color: var(--muted);
font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.crew-remove {
position: absolute;
top: 5px;
right: 5px;
width: 23px;
height: 23px;
color: var(--muted);
background: transparent;
font-weight: 900;
}
.crew-remove:hover:not(:disabled) {
color: var(--red);
background: rgba(255, 100, 116, .08);
}
.skills {
display: flex;
flex-wrap: wrap;
gap: 4px;
margin-top: 9px;
}
.skill {
padding: 3px 5px;
color: #afc1d6;
background: #15263a;
font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
text-transform: uppercase;
letter-spacing: .04em;
}
.crew-load {
margin-top: 8px;
color: var(--muted);
font-size: 9px;
}
.task-list {
display: grid;
gap: 8px;
}
.task-card {
border: 1px solid var(--line);
background: #0e1b2b;
padding: 11px;
transition: border-color .16s ease, transform .16s ease;
}
.task-card:hover {
border-color: #36516e;
}
.task-card.selected {
border-color: var(--blue);
box-shadow: 0 0 0 1px rgba(118, 169, 255, .12);
}
.task-card-head {
display: flex;
justify-content: space-between;
gap: 8px;
align-items: flex-start;
}
.task-title {
font-size: 12px;
font-weight: 850;
line-height: 1.25;
}
.task-fixed {
margin-top: 4px;
color: var(--muted);
font: 700 9px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.task-badge {
flex: 0 0 auto;
padding: 5px 6px;
font: 900 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .07em;
}
.task-badge.scheduled {
color: var(--teal);
background: rgba(84, 223, 192, .11);
}
.task-badge.unassigned {
color: var(--orange);
background: rgba(255, 180, 84, .11);
}
.task-badge.infeasible {
color: var(--red);
background: rgba(255, 100, 116, .12);
}
.task-badge.blocked {
color: #a9b7c9;
background: rgba(169, 183, 201, .1);
}
.task-select {
width: 100%;
height: 34px;
margin-top: 10px;
padding: 0 28px 0 9px;
color: var(--text);
background: #14253a;
border: 1px solid #2a4059;
border-radius: 0;
font-size: 10px;
font-weight: 700;
outline: none;
}
.task-select:focus {
border-color: var(--blue);
}
.task-detail {
min-height: 14px;
margin-top: 7px;
color: var(--muted);
font: 600 9px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.task-detail.bad { color: var(--red); }
.task-detail.warn { color: var(--orange); }
.task-detail.good { color: var(--teal); }
.analysis {
padding: 13px;
border: 1px solid var(--line);
background: #0e1b2b;
}
.analysis.ok {
border-color: rgba(84, 223, 192, .38);
}
.analysis.bad {
border-color: rgba(255, 100, 116, .42);
}
.analysis-title {
display: flex;
align-items: center;
gap: 8px;
font-size: 12px;
font-weight: 900;
}
.analysis-title.ok { color: var(--teal); }
.analysis-title.bad { color: var(--red); }
.analysis-copy {
margin-top: 8px;
color: var(--muted);
font-size: 10px;
line-height: 1.55;
}
.issue-list {
margin: 9px 0 0;
padding: 0;
list-style: none;
display: grid;
gap: 6px;
}
.issue-list li {
padding-left: 10px;
border-left: 2px solid var(--orange);
color: #c8d4e2;
font-size: 10px;
line-height: 1.4;
}
.candidate-list {
display: grid;
gap: 5px;
margin-top: 10px;
}
.candidate {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
padding: 7px;
background: #14253a;
font-size: 9px;
}
.candidate strong {
display: block;
margin-bottom: 2px;
font-size: 10px;
}
.candidate .candidate-result.ok { color: var(--teal); }
.candidate .candidate-result.bad { color: var(--red); }
.suggestion {
margin-top: 10px;
width: 100%;
}
.workspace {
min-width: 0;
min-height: 0;
display: grid;
grid-template-rows: minmax(0, 1fr) 190px;
}
.viewport {
position: relative;
min-height: 0;
overflow: hidden;
background: #081321;
}
#scene {
position: absolute;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.scene-heading {
position: absolute;
top: 20px;
left: 22px;
pointer-events: none;
}
.scene-eyebrow {
color: var(--teal);
font: 800 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .15em;
}
.scene-heading h2 {
margin: 7px 0 0;
font-size: 22px;
text-shadow: 0 3px 14px rgba(0, 0, 0, .45);
}
.metrics {
display: flex;
gap: 7px;
margin-top: 13px;
}
.metric {
min-width: 82px;
padding: 8px 10px;
border: 1px solid rgba(85, 111, 139, .65);
background: rgba(8, 19, 33, .83);
backdrop-filter: blur(9px);
}
.metric-label {
color: var(--muted);
font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .08em;
}
.metric-value {
margin-top: 4px;
font: 900 16px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.metric-value.good { color: var(--teal); }
.metric-value.warn { color: var(--orange); }
.metric-value.bad { color: var(--red); }
.camera-controls {
position: absolute;
top: 20px;
right: 20px;
display: grid;
gap: 5px;
}
.camera-controls button {
width: 36px;
height: 36px;
color: var(--text);
background: rgba(13, 28, 45, .88);
border: 1px solid #324a65;
font-size: 16px;
font-weight: 900;
}
.camera-controls button:hover {
color: var(--teal);
border-color: var(--teal);
}
.scene-legend {
position: absolute;
left: 22px;
bottom: 18px;
display: flex;
flex-wrap: wrap;
gap: 10px;
padding: 9px 11px;
border: 1px solid rgba(61, 86, 112, .55);
background: rgba(8, 19, 33, .78);
backdrop-filter: blur(8px);
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 6px;
color: #b9c9dc;
font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.legend-swatch {
width: 9px;
height: 9px;
background: var(--swatch);
}
.gantt-panel {
border-top: 1px solid var(--line);
background: #0a1523;
padding: 12px 18px 13px;
min-width: 0;
overflow: hidden;
}
.gantt-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 7px;
}
.gantt-head h3 {
margin: 0;
font: 900 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .1em;
text-transform: uppercase;
}
.gantt-head span {
color: var(--muted);
font: 600 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.gantt-grid {
display: grid;
grid-template-columns: 118px minmax(0, 1fr);
column-gap: 10px;
align-items: center;
}
.time-axis {
position: relative;
height: 15px;
grid-column: 2;
color: var(--muted);
font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.time-axis span {
position: absolute;
transform: translateX(-50%);
}
.time-axis span:first-child { transform: none; }
.time-axis span:last-child { transform: translateX(-100%); }
.gantt-row {
display: contents;
}
.gantt-label {
height: 22px;
display: flex;
align-items: center;
color: #b7c6d7;
font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.gantt-track {
height: 22px;
position: relative;
background:
linear-gradient(90deg,
rgba(255,255,255,.045) 1px,
transparent 1px) 0 0 / 33.333% 100%;
border-left: 1px solid #25394f;
border-right: 1px solid #25394f;
}
.gantt-bar {
position: absolute;
top: 5px;
height: 12px;
min-width: 3px;
background: var(--bar-color);
box-shadow: 0 0 12px color-mix(in srgb, var(--bar-color) 45%, transparent);
}
.gantt-deadline {
position: absolute;
top: 2px;
width: 1px;
height: 18px;
background: #dbe7f6;
opacity: .78;
}
.gantt-empty {
position: absolute;
top: 5px;
left: 5px;
color: var(--orange);
font: 900 8px/12px ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .08em;
}
.loading {
position: absolute;
inset: 0;
display: grid;
place-items: center;
color: var(--muted);
background: #081321;
font: 800 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .12em;
z-index: 4;
}
@media (max-width: 1050px) {
.layout { grid-template-columns: 340px minmax(0, 1fr); }
.event-meta .meta-chip:nth-child(3) { display: none; }
.crew-grid { grid-template-columns: 1fr; }
.scene-heading h2 { font-size: 18px; }
.metrics { flex-wrap: wrap; max-width: 300px; }
}
@media (max-width: 780px) {
html, body { height: auto; overflow: auto; }
.topbar { height: auto; min-height: 70px; flex-wrap: wrap; padding: 12px; }
.event-meta { display: none; }
.top-actions { margin-left: auto; }
.layout { height: auto; display: flex; flex-direction: column; }
.sidebar { order: 2; overflow: visible; border-right: 0; }
.workspace { order: 1; height: 720px; grid-template-rows: 540px 180px; }
.crew-grid { grid-template-columns: 1fr 1fr; }
.scene-heading { left: 14px; top: 14px; }
.scene-legend { left: 12px; bottom: 12px; }
.camera-controls { right: 12px; top: 12px; }
}
</style>
</head>
<body>
<header class="topbar">
<div class="brand">
<div class="brand-icon" aria-hidden="true"></div>
<div>
<div class="brand-name">VOXEL OPS</div>
<div class="brand-sub">EVENT SETUP CONTROL</div>
</div>
</div>
<div class="event-meta">
<div class="meta-chip">EVENT <strong>LF-26 / HALL B</strong></div>
<div class="meta-chip">DOORS <strong>18:00</strong></div>
<div class="meta-chip">CLOCK <strong>08:00–11:15</strong></div>
</div>
<div class="top-actions">
<button class="button" id="resetBtn">Reset scenario</button>
<button class="button danger" id="removeBtn">Remove Jordan Lee</button>
</div>
</header>
<main class="layout">
<aside class="sidebar">
<section class="section">
<div class="section-heading">
<h2>Scenario</h2>
<span class="section-count" id="scenarioCount">01 / 02</span>
</div>
<div class="scenario" id="scenario"></div>
</section>
<section class="section">
<div class="section-heading">
<h2>Volunteer crew</h2>
<span class="section-count" id="crewCount"></span>
</div>
<div class="crew-grid" id="crewList"></div>
</section>
<section class="section">
<div class="section-heading">
<h2>Setup schedule</h2>
<span class="section-count">FIXED RULES</span>
</div>
<div class="task-list" id="taskList"></div>
</section>
<section class="section">
<div class="analysis" id="analysis"></div>
</section>
</aside>
<section class="workspace">
<div class="viewport" id="viewport">
<div id="scene"></div>
<div class="scene-heading">
<div class="scene-eyebrow">LUMENFEST 2026 · EAST HALL</div>
<h2>Live setup floor</h2>
<div class="metrics">
<div class="metric">
<div class="metric-label">ON TIME</div>
<div class="metric-value good" id="metricOnTime">6/6</div>
</div>
<div class="metric">
<div class="metric-label">UNRESOLVED</div>
<div class="metric-value warn" id="metricUnresolved">0</div>
</div>
<div class="metric">
<div class="metric-label">DEADLINE MISS</div>
<div class="metric-value bad" id="metricMiss">0</div>
</div>
</div>
</div>
<div class="camera-controls" aria-label="Camera controls">
<button id="zoomIn" title="Zoom in">+</button>
<button id="zoomOut" title="Zoom out">−</button>
<button id="resetCamera" title="Reset camera">↺</button>
</div>
<div class="scene-legend">
<div class="legend-item"><span class="legend-swatch" style="--swatch:#54dfc0"></span>ON TIME</div>
<div class="legend-item"><span class="legend-swatch" style="--swatch:#ffb454"></span>UNASSIGNED</div>
<div class="legend-item"><span class="legend-swatch" style="--swatch:#ff6474"></span>DEADLINE MISS</div>
<div class="legend-item"><span class="legend-swatch" style="--swatch:#8998ad"></span>BLOCKED</div>
</div>
<div class="loading" id="loading">BUILDING VOXEL FLOOR…</div>
</div>
<section class="gantt-panel">
<div class="gantt-head">
<h3>Hard-deadline timeline</h3>
<span>08:00 → 11:00 · FIXED DURATIONS</span>
</div>
<div class="gantt-grid" id="gantt"></div>
</section>
</section>
</main>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Fictional scheduling model
// -------------------------------------------------------------------------
const CREW = [
{
id: "maya",
name: "Maya Chen",
initials: "MC",
color: "#76a9ff",
skills: ["Carpentry", "Rigging"],
shiftStart: 0,
shiftEnd: 195
},
{
id: "jordan",
name: "Jordan Lee",
initials: "JL",
color: "#ffb454",
skills: ["Electrical"],
shiftStart: 0,
shiftEnd: 195
},
{
id: "priya",
name: "Priya Shah",
initials: "PS",
color: "#a990ff",
skills: ["Audio", "Lighting", "Safety"],
shiftStart: 0,
shiftEnd: 195
},
{
id: "nina",
name: "Nina Flores",
initials: "NF",
color: "#54dfc0",
skills: ["Electrical", "General"],
shiftStart: 0,
shiftEnd: 195
},
{
id: "eli",
name: "Eli Stone",
initials: "ES",
color: "#ff8ca3",
skills: ["Electrical", "Lighting", "General"],
shiftStart: 15,
shiftEnd: 195
}
];
const TASKS = [
{
id: "deck",
name: "Build stage deck",
short: "DECK",
duration: 50,
deadline: 50,
skill: "Carpentry",
dependencies: [],
marker: [-5.0, 0, -1.5]
},
{
id: "frame",
name: "Secure stage frame",
short: "FRAME",
duration: 40,
deadline: 95,
skill: "Rigging",
dependencies: ["deck"],
marker: [-10.0, 0, -4.5]
},
{
id: "power",
name: "Route power drop",
short: "POWER",
duration: 35,
deadline: 35,
skill: "Electrical",
dependencies: [],
marker: [-1.0, 0, 3.8]
},
{
id: "speakers",
name: "Position PA speakers",
short: "PA",
duration: 30,
deadline: 100,
skill: "Audio",
dependencies: ["power"],
marker: [5.0, 0, 4.5]
},
{
id: "truss",
name: "Hang light truss",
short: "TRUSS",
duration: 45,
deadline: 140,
skill: "Lighting",
dependencies: ["frame", "power"],
marker: [8.8, 0, -1.0]
},
{
id: "safety",
name: "Final safety check",
short: "CHECK",
duration: 25,
deadline: 165,
skill: "Safety",
dependencies: ["truss", "speakers"],
marker: [0.0, 0, 1.8]
}
];
const DEFAULT_ASSIGNMENTS = {
deck: "maya",
frame: "maya",
power: "jordan",
speakers: "priya",
truss: "priya",
safety: "priya"
};
const state = {
assignments: { ...DEFAULT_ASSIGNMENTS },
removed: new Set(),
selectedTask: "power"
};
const crewById = Object.fromEntries(CREW.map(c => [c.id, c]));
const taskById = Object.fromEntries(TASKS.map(t => [t.id, t]));
const PROJECT_START = 8 * 60;
const TIMELINE_MINUTES = 180;
const STATUS_COLORS = {
scheduled: "#54dfc0",
unassigned: "#ffb454",
infeasible: "#ff6474",
blocked: "#8998ad"
};
function formatTime(minutes) {
if (minutes === null || minutes === undefined) return "—";
const total = PROJECT_START + Math.round(minutes);
const h = Math.floor(total / 60);
const m = total % 60;
return `${String(h).padStart(2, "0")}:${String(m).padStart(2, "0")}`;
}
function qualifiedCrew(taskId, removed = state.removed) {
const task = taskById[taskId];
return CREW.filter(c =>
!removed.has(c.id) && c.skills.includes(task.skill)
);
}
function topologicalTasks() {
const ordered = [];
const visited = new Set();
const visiting = new Set();
function visit(id) {
if (visited.has(id)) return;
if (visiting.has(id)) return;
visiting.add(id);
for (const dep of taskById[id].dependencies) visit(dep);
visiting.delete(id);
visited.add(id);
ordered.push(id);
}
// The authored order intentionally allows useful parallel work.
TASKS.forEach(task => visit(task.id));
return ordered;
}
function calculateSchedule(
assignments = state.assignments,
removed = state.removed
) {
const results = {};
const freeAt = {};
const order = topologicalTasks();
for (const id of order) {
const task = taskById[id];
const assigneeId = assignments[id] || null;
const assignee = assigneeId ? crewById[assigneeId] : null;
const unresolvedDependency = task.dependencies.find(depId => {
const dep = results[depId];
return !dep || !dep.canPerform;
});
if (!assigneeId || removed.has(assigneeId)) {
results[id] = {
id,
status: "unassigned",
reason: "No active assignee",
start: null,
end: null,
slack: null,
canPerform: false
};
continue;
}
if (!assignee.skills.includes(task.skill)) {
results[id] = {
id,
status: "infeasible",
reason: `${assignee.name} lacks ${task.skill}`,
start: null,
end: null,
slack: null,
canPerform: false
};
continue;
}
if (unresolvedDependency) {
const depTask = taskById[unresolvedDependency];
results[id] = {
id,
status: "blocked",
reason: `Waiting for ${depTask.name}`,
start: null,
end: null,
slack: null,
canPerform: false
};
continue;
}
const dependencyEnd = task.dependencies.length
? Math.max(...task.dependencies.map(depId => results[depId].end))
: 0;
const crewFreeAt = freeAt[assigneeId] || 0;
const start = Math.max(
dependencyEnd,
assignee.shiftStart,
crewFreeAt
);
const end = start + task.duration;
freeAt[assigneeId] = end;
const slack = task.deadline - end;
const status = slack < 0 ? "infeasible" : "scheduled";
results[id] = {
id,
status,
reason: slack < 0
? `Finishes ${Math.abs(slack)} min after the hard deadline`
: `${slack} min deadline slack`,
start,
end,
slack,
canPerform: true
};
}
return results;
}
function candidateEvaluations(taskId, assignments = state.assignments) {
const task = taskById[taskId];
return qualifiedCrew(taskId).map(candidate => {
const trialAssignments = {
...assignments,
[taskId]: candidate.id
};
const trialSchedule = calculateSchedule(trialAssignments, state.removed);
const result = trialSchedule[taskId];
const otherProblems = Object.values(trialSchedule).filter(r =>
r.id !== taskId && r.status !== "scheduled"
).length;
return {
crew: candidate,
result,
viable: result.status === "scheduled" && otherProblems === 0
};
});
}
function buildSuggestion() {
let assignments = { ...state.assignments };
const suggestion = [];
for (const task of TASKS) {
if (assignments[task.id]) continue;
const candidates = candidateEvaluations(task.id, assignments);
const best = candidates
.filter(c => c.viable)
.sort((a, b) => a.result.end - b.result.end)[0];
if (best) {
assignments[task.id] = best.crew.id;
suggestion.push({ taskId: task.id, crewId: best.crew.id });
}
}
return suggestion;
}
// -------------------------------------------------------------------------
// UI rendering
// -------------------------------------------------------------------------
const scenarioEl = document.querySelector("#scenario");
const scenarioCountEl = document.querySelector("#scenarioCount");
const crewListEl = document.querySelector("#crewList");
const crewCountEl = document.querySelector("#crewCount");
const taskListEl = document.querySelector("#taskList");
const analysisEl = document.querySelector("#analysis");
const removeBtn = document.querySelector("#removeBtn");
const ganttEl = document.querySelector("#gantt");
function renderScenario(schedule) {
const removedId = [...state.removed][0];
const unresolved = Object.values(schedule).filter(r => r.status !== "scheduled").length;
if (!removedId) {
scenarioCountEl.textContent = "01 / 02";
scenarioEl.innerHTML = `
<div class="scenario-kicker">
<span class="status-dot"></span>
BASELINE RUN COMPLETE
</div>
<h1>All six setup tasks meet their deadlines.</h1>
<p>
The fictional LumenFest schedule has been evaluated. Remove one
volunteer to inject a staffing change and release their assignments.
</p>
<div class="scenario-actions">
<button class="button danger small" data-remove-primary="jordan">
Remove Jordan Lee
</button>
</div>
`;
} else {
const removedCrew = crewById[removedId];
const released = TASKS.filter(t =>
DEFAULT_ASSIGNMENTS[t.id] === removedId
);
scenarioCountEl.textContent = "02 / 02";
scenarioEl.innerHTML = `
<div class="scenario-kicker" style="color:var(--orange)">
<span class="status-dot"></span>
STAFFING CHANGE APPLIED
</div>
<h1>${removedCrew.name} is off shift.</h1>
<p>
${released.length} assignment${released.length === 1 ? " was" : "s were"}
released. Reassign the work using another qualified volunteer.
Durations, prerequisites, and skill requirements remain unchanged.
</p>
<div class="scenario-actions">
<button class="button small" data-restore="${removedId}">
Restore ${removedCrew.name.split(" ")[0]}
</button>
<span class="meta-chip">${unresolved} UNRESOLVED</span>
</div>
`;
}
removeBtn.disabled = state.removed.size > 0;
removeBtn.textContent = state.removed.size
? `${crewById[[...state.removed][0]].name} removed`
: "Remove Jordan Lee";
}
function renderCrew(schedule) {
const activeCount = CREW.length - state.removed.size;
crewCountEl.textContent = `${activeCount}/${CREW.length} ACTIVE`;
crewListEl.innerHTML = CREW.map(crew => {
const removed = state.removed.has(crew.id);
const assigned = TASKS.filter(t => state.assignments[t.id] === crew.id);
const releasedCount = TASKS.filter(t =>
DEFAULT_ASSIGNMENTS[t.id] === crew.id && !state.assignments[t.id]
).length;
const shift = `${formatTime(crew.shiftStart)}–${formatTime(crew.shiftEnd)}`;
return `
<article class="crew-card ${removed ? "removed" : ""}">
${
removed
? `<button class="crew-remove" data-restore="${crew.id}" title="Restore volunteer">↺</button>`
: `<button
class="crew-remove"
data-remove="${crew.id}"
title="Remove volunteer"
${state.removed.size ? "disabled" : ""}
>×</button>`
}
<div class="crew-top">
<div class="avatar" style="background:${crew.color}">${crew.initials}</div>
<div>
<div class="crew-name">${crew.name}</div>
<div class="crew-shift">${removed ? "OFF SHIFT" : shift}</div>
</div>
</div>
<div class="skills">
${crew.skills.map(skill =>
`<span class="skill">${skill}</span>`
).join("")}
</div>
<div class="crew-load">
${
removed
? `${releasedCount} task${releasedCount === 1 ? "" : "s"} released`
: assigned.length
? `${assigned.length} assigned · ${assigned.map(t => t.short).join(", ")}`
: "Standby · available for reassignment"
}
</div>
</article>
`;
}).join("");
}
function taskStatusBadge(result) {
const labels = {
scheduled: "ON TIME",
unassigned: "UNASSIGNED",
infeasible: "DEADLINE MISS",
blocked: "BLOCKED"
};
return `<span class="task-badge ${result.status}">${labels[result.status]}</span>`;
}
function renderTasks(schedule) {
taskListEl.innerHTML = TASKS.map(task => {
const result = schedule[task.id];
const selected = state.selectedTask === task.id;
const current = state.assignments[task.id];
const options = CREW.filter(c => !state.removed.has(c.id)).map(crew => {
const qualified = crew.skills.includes(task.skill);
const selectedAttr = current === crew.id ? "selected" : "";
const disabled = qualified ? "" : "disabled";
const suffix = qualified
? task.skill
: `lacks ${task.skill}`;
return `
<option value="${crew.id}" ${selectedAttr} ${disabled}>
${crew.name} · ${suffix}
</option>
`;
}).join("");
let detail = "";
let detailClass = "";
if (result.status === "scheduled") {
detail = `${formatTime(result.start)}–${formatTime(result.end)} · ${result.reason}`;
detailClass = "good";
} else if (result.status === "infeasible") {
detail = result.start === null
? result.reason
: `${formatTime(result.start)}–${formatTime(result.end)} · ${result.reason}`;
detailClass = "bad";
} else if (result.status === "blocked") {
detail = result.reason;
detailClass = "warn";
} else {
detail = "Released assignment · choose an active qualified volunteer";
detailClass = "warn";
}
const candidateHint = !current && qualifiedCrew(task.id).length
? candidateEvaluations(task.id)
.map(c => `${c.crew.name.split(" ")[0]}: ${
c.viable ? "meets deadline" : "misses deadline"
}`)
.join(" · ")
: "";
return `
<article
class="task-card ${selected ? "selected" : ""}"
data-select-task="${task.id}"
>
<div class="task-card-head">
<div>
<div class="task-title">${task.name}</div>
<div class="task-fixed">
${task.duration} MIN · ${task.skill.toUpperCase()} · DUE ${formatTime(task.deadline)}
</div>
</div>
${taskStatusBadge(result)}
</div>
<select
class="task-select"
data-assign-task="${task.id}"
aria-label="Assign ${task.name}"
>
<option value="" ${!current ? "selected" : ""}>Choose qualified crew…</option>
${options}
</select>
<div class="task-detail ${detailClass}">
${detail}
${candidateHint ? `<br>${candidateHint}` : ""}
</div>
</article>
`;
}).join("");
}
function renderAnalysis(schedule) {
const problems = TASKS
.map(task => ({ task, result: schedule[task.id] }))
.filter(item => item.result.status !== "scheduled");
if (!problems.length) {
analysisEl.className = "analysis ok";
analysisEl.innerHTML = `
<div class="analysis-title ok">
<span class="status-dot"></span>
FEASIBLE SCHEDULE CONFIRMED
</div>
<div class="analysis-copy">
Every task can meet its hard deadline with the current assignments.
The solver respected fixed durations, required skills, volunteer shifts,
task dependencies, and volunteer workload.
</div>
`;
return;
}
const suggestion = buildSuggestion();
const unassignedTasks = problems.filter(p => p.result.status === "unassigned");
const candidateRows = unassignedTasks.flatMap(item => {
const candidates = candidateEvaluations(item.task.id);
if (!candidates.length) return [];
return [
`<div class="candidate-list">`,
...candidates.map(candidate => `
<div class="candidate">
<div>
<strong>${candidate.crew.name}</strong>
<span style="color:var(--muted)">
${candidate.crew.shiftStart > 0
? `Shift starts ${formatTime(candidate.crew.shiftStart)}`
: `Shift starts ${formatTime(candidate.crew.shiftStart)}`}
</span>
</div>
<div class="candidate-result ${candidate.viable ? "ok" : "bad"}">
${
candidate.result.status === "scheduled"
? `Meets by ${candidate.result.slack}m`
: candidate.result.reason
}
</div>
</div>
`),
`</div>`
];
}).join("");
analysisEl.className = "analysis bad";
analysisEl.innerHTML = `
<div class="analysis-title bad">
<span class="status-dot"></span>
${problems.length} UNRESOLVED CONSTRAINT${problems.length === 1 ? "" : "S"}
</div>
<div class="analysis-copy">
The schedule cannot be certified until the following assignments or
deadlines are resolved. Task duration and skill requirements are fixed.
</div>
<ul class="issue-list">
${problems.map(({ task, result }) => `
<li>
<strong>${task.name}</strong> —
${result.status === "unassigned"
? "no active assignee"
: result.status === "blocked"
? result.reason
: result.reason}
</li>
`).join("")}
</ul>
${candidateRows}
${
suggestion.length
? `<button class="button primary small suggestion" id="applySuggestion">
Apply suggested staffing (${suggestion.length})
</button>`
: ""
}
`;
}
function renderMetrics(schedule) {
const values = Object.values(schedule);
const onTime = values.filter(r => r.status === "scheduled").length;
const unresolved = values.filter(r => r.status !== "scheduled").length;
const misses = values.filter(r => r.status === "infeasible").length;
document.querySelector("#metricOnTime").textContent = `${onTime}/${TASKS.length}`;
document.querySelector("#metricUnresolved").textContent = unresolved;
document.querySelector("#metricMiss").textContent = misses;
document.querySelector("#metricUnresolved").className =
`metric-value ${unresolved ? "warn" : "good"}`;
}
function renderGantt(schedule) {
const axis = `
<div class="time-axis">
<span style="left:0%">08:00</span>
<span style="left:33.333%">09:00</span>
<span style="left:66.666%">10:00</span>
<span style="left:100%">11:00</span>
</div>
`;
const rows = TASKS.map(task => {
const result = schedule[task.id];
const bar = result.start === null
? `<div class="gantt-empty">UNASSIGNED</div>`
: `
<div
class="gantt-bar"
style="
left:${result.start / TIMELINE_MINUTES * 100}%;
width:${task.duration / TIMELINE_MINUTES * 100}%;
--bar-color:${STATUS_COLORS[result.status]};
"
title="${task.name}: ${formatTime(result.start)}–${formatTime(result.end)}"
></div>
`;
return `
<div class="gantt-row">
<div class="gantt-label" title="${task.name}">${task.short} · ${task.name}</div>
<div class="gantt-track">
${bar}
<div
class="gantt-deadline"
style="left:${task.deadline / TIMELINE_MINUTES * 100}%"
title="Deadline ${formatTime(task.deadline)}"
></div>
</div>
</div>
`;
}).join("");
ganttEl.innerHTML = axis + rows;
}
// -------------------------------------------------------------------------
// Three.js voxel scene
// -------------------------------------------------------------------------
const sceneHost = document.querySelector("#scene");
const viewport = document.querySelector("#viewport");
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.setClearColor(0x081321, 1);
sceneHost.appendChild(renderer.domElement);
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel event setup floor. Drag to orbit, scroll to zoom, and click task markers."
);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x081321);
scene.fog = new THREE.Fog(0x081321, 32, 55);
const camera = new THREE.PerspectiveCamera(43, 1, 0.1, 120);
const cameraState = {
theta: 0.72,
phi: 0.92,
radius: 29,
target: new THREE.Vector3(0, 0.5, 0)
};
const hemisphere = new THREE.HemisphereLight(0xa8cfff, 0x172033, 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff3dc, 3.1);
sun.position.set(-10, 18, 11);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -20;
sun.shadow.camera.right = 20;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 50;
sun.shadow.bias = -0.0007;
scene.add(sun);
const rim = new THREE.DirectionalLight(0x4c8cff, 1.4);
rim.position.set(12, 9, -12);
scene.add(rim);
const world = new THREE.Group();
const dynamicGroup = new THREE.Group();
scene.add(world, dynamicGroup);
const staticMaterials = new Map();
function staticMaterial(color) {
if (!staticMaterials.has(color)) {
staticMaterials.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.08
})
);
}
return staticMaterials.get(color);
}
function box(
parent,
width,
height,
depth,
color,
x = 0,
y = 0,
z = 0
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
staticMaterial(color)
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeTextSprite(text, accent = "#54dfc0", compact = false) {
const lines = text.split("\n");
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = compact ? 100 : 150;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "rgba(7, 16, 28, .91)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, 12, canvas.height);
ctx.strokeStyle = "rgba(125, 159, 193, .65)";
ctx.lineWidth = 4;
ctx.strokeRect(2, 2, canvas.width - 4, canvas.height - 4);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
if (lines.length === 1) {
ctx.fillStyle = "#edf5ff";
ctx.font = "900 36px monospace";
ctx.fillText(lines[0], canvas.width / 2 + 5, canvas.height / 2);
} else {
ctx.fillStyle = accent;
ctx.font = "900 33px monospace";
ctx.fillText(lines[0], canvas.width / 2 + 5, 47);
ctx.fillStyle = "#edf5ff";
ctx.font = "800 30px monospace";
ctx.fillText(lines[1], canvas.width / 2 + 5, 103);
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(compact ? 2.1 : 4.0, compact ? 0.42 : 1.17, 1);
sprite.renderOrder = 10;
return sprite;
}
function buildStaticScene() {
// Main floor slab.
box(world, 24.5, 0.55, 17.0, "#111d2c", 0, -0.36, 0);
// Pixel-tiled floor using two instanced meshes.
const tileGeometry = new THREE.BoxGeometry(1.42, 0.09, 1.42);
const tileA = new THREE.InstancedMesh(
tileGeometry,
staticMaterial("#1b2c3e"),
80
);
const tileB = new THREE.InstancedMesh(
tileGeometry,
staticMaterial("#203247"),
80
);
const matrix = new THREE.Matrix4();
let a = 0;
let b = 0;
for (let z = 0; z < 10; z++) {
for (let x = 0; x < 16; x++) {
matrix.makeTranslation(
(x - 7.5) * 1.5,
-0.045,
(z - 4.5) * 1.5
);
if ((x + z) % 2 === 0) {
tileA.setMatrixAt(a++, matrix);
} else {
tileB.setMatrixAt(b++, matrix);
}
}
}
tileA.instanceMatrix.needsUpdate = true;
tileB.instanceMatrix.needsUpdate = true;
tileA.receiveShadow = true;
tileB.receiveShadow = true;
world.add(tileA, tileB);
// Hall walls and structural columns.
box(world, 24.5, 6.3, 0.4, "#17263a", 0, 2.75, -8.2);
box(world, 0.4, 6.3, 16.8, "#142337", -12.1, 2.75, 0);
for (let x = -10; x <= 10; x += 5) {
box(world, 0.35, 6, 0.55, "#29405b", x, 2.7, -7.85);
}
for (let z = -6; z <= 6; z += 6) {
box(world, 0.55, 6, 0.35, "#29405b", -11.8, 2.7, z);
}
// Stage platform.
box(world, 7.4, 0.65, 4.3, "#3b4b5c", -7.2, 0.32, -4.3);
box(world, 7.0, 0.18, 3.9, "#536477", -7.2, 0.73, -4.3);
box(world, 2.0, 0.35, 1.0, "#2e3d4f", -7.2, 0.17, -1.85);
box(world, 2.6, 0.2, 0.75, "#394b60", -7.2, 0.10, -1.25);
// Stage frame.
for (const x of [-10.1, -4.3]) {
for (const z of [-5.7, -2.9]) {
box(world, 0.22, 4.3, 0.22, "#8a5260", x, 2.15, z);
}
}
box(world, 6.1, 0.22, 0.22, "#8a5260", -7.2, 4.2, -5.7);
box(world, 6.1, 0.22, 0.22, "#8a5260", -7.2, 4.2, -2.9);
box(world, 0.22, 0.22, 3.0, "#8a5260", -10.1, 4.2, -4.3);
box(world, 0.22, 0.22, 3.0, "#8a5260", -4.3, 4.2, -4.3);
// Light truss zone.
for (const x of [5.6, 9.4]) {
box(world, 0.28, 4.7, 0.28, "#596b83", x, 2.35, -4.7);
box(world, 0.9, 0.18, 0.9, "#34465c", x, 0.05, -4.7);
}
box(world, 4.2, 0.25, 0.25, "#596b83", 7.5, 4.55, -4.7);
box(world, 4.2, 0.25, 0.25, "#596b83", 7.5, 3.95, -4.7);
for (const x of [6.2, 7.5, 8.8]) {
box(world, 0.55, 0.48, 0.55, "#242d3a", x, 3.65, -4.35);
box(world, 0.34, 0.12, 0.04, "#f0d47c", x, 3.60, -4.05);
}
// PA speakers.
for (const x of [6.1, 8.3]) {
box(world, 1.0, 0.25, 0.8, "#263446", x, 0.12, 3.2);
box(world, 0.8, 2.4, 0.65, "#182231", x, 1.35, 3.2);
box(world, 0.5, 0.5, 0.05, "#0c121c", x, 1.8, 3.54);
box(world, 0.28, 0.28, 0.05, "#4b6078", x, 1.25, 3.54);
}
// Electrical distribution zone.
box(world, 1.7, 1.15, 1.2, "#b5763d", -1.8, 0.57, 5.4);
box(world, 1.2, 0.22, 0.8, "#35485d", -1.8, 1.25, 5.4);
box(world, 0.55, 0.38, 0.08, "#f1c86a", -1.8, 0.75, 6.03);
box(world, 0.8, 0.8, 0.8, "#2e4358", 0.1, 0.4, 5.5);
box(world, 0.6, 0.6, 0.6, "#40566e", 0.1, 1.05, 5.5);
// Voxel cable route.
for (let x = -1; x <= 4; x += 0.65) {
box(world, 0.48, 0.07, 0.22, "#d78b3e", x, 0.05, 4.7);
}
for (let z = 4.7; z >= -1; z -= 0.65) {
box(world, 0.22, 0.07, 0.48, "#d78b3e", 4.1, 0.05, z);
}
// Safety checkpoint.
for (const x of [-1.4, 1.4]) {
box(world, 0.18, 1.2, 0.18, "#53b79d", x, 0.6, -0.5);
box(world, 0.18, 1.2, 0.18, "#53b79d", x, 0.6, 1.1);
box(world, 0.18, 0.18, 1.7, "#53b79d", x, 1.12, 0.3);
}
// Front standby bench.
box(world, 4.2, 0.35, 0.8, "#34475d", 2.8, 0.48, 7.0);
box(world, 0.25, 0.55, 0.65, "#24364b", 1.0, 0.28, 7.0);
box(world, 0.25, 0.55, 0.65, "#24364b", 4.6, 0.28, 7.0);
// Venue sign.
const sign = makeTextSprite("LUMENFEST / HALL B", "#54dfc0", true);
sign.position.set(1.0, 4.65, -7.78);
sign.scale.set(6.2, 1.21, 1);
world.add(sign);
}
let markerPickables = [];
let selectionOutline = null;
function clearDynamicGroup() {
dynamicGroup.traverse(object => {
if (object.geometry) object.geometry.dispose();
if (object.material) {
const materials = Array.isArray(object.material)
? object.material
: [object.material];
for (const material of materials) {
if (material.map) material.map.dispose();
material.dispose();
}
}
});
dynamicGroup.clear();
markerPickables = [];
selectionOutline = null;
}
function addVoxelPerson(group, color, initials, small = false) {
const person = new THREE.Group();
const skin = "#e6b894";
const pants = "#26354a";
const makePart = (w, h, d, matColor, x, y, z) => {
const material = new THREE.MeshStandardMaterial({
color: matColor,
roughness: 0.9
});
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
person.add(mesh);
};
makePart(0.30, 0.48, 0.25, color, -0.17, 0.34, 0);
makePart(0.30, 0.48, 0.25, color, 0.17, 0.34, 0);
makePart(0.67, 0.66, 0.38, color, 0, 0.92, 0);
makePart(0.18, 0.63, 0.20, color, -0.46, 0.91, 0);
makePart(0.18, 0.63, 0.20, color, 0.46, 0.91, 0);
makePart(0.42, 0.42, 0.40, skin, 0, 1.48, 0);
makePart(0.46, 0.15, 0.43, "#27354a", 0, 1.72, 0);
const badge = makeTextSprite(initials, color, true);
badge.position.set(0, 2.02, 0);
badge.scale.set(0.78, 0.31, 1);
person.add(badge);
if (small) person.scale.setScalar(0.88);
group.add(person);
return person;
}
function renderSceneDynamics(schedule) {
clearDynamicGroup();
for (const task of TASKS) {
const result = schedule[task.id];
const color = STATUS_COLORS[result.status];
const marker = new THREE.Group();
marker.position.set(...task.marker);
const platformMaterial = new THREE.MeshStandardMaterial({
color: "#20344a",
roughness: 0.9
});
const platform = new THREE.Mesh(
new THREE.BoxGeometry(2.25, 0.16, 1.35),
platformMaterial
);
platform.position.y = 0.08;
platform.receiveShadow = true;
marker.add(platform);
const beaconMaterial = new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.32,
roughness: 0.55
});
const beacon = new THREE.Mesh(
new THREE.BoxGeometry(1.18, 0.72, 0.88),
beaconMaterial
);
beacon.position.y = 0.52;
beacon.castShadow = true;
beacon.userData.taskId = task.id;
marker.add(beacon);
markerPickables.push(beacon);
const postMaterial = new THREE.MeshStandardMaterial({
color: "#536b83",
roughness: 0.8
});
const post = new THREE.Mesh(
new THREE.BoxGeometry(0.12, 1.1, 0.12),
postMaterial
);
post.position.set(-0.78, 0.65, -0.45);
marker.add(post);
const statusText = result.status === "scheduled"
? `${formatTime(result.start)}–${formatTime(result.end)}`
: result.status === "infeasible"
? `MISS ${formatTime(task.deadline)}`
: result.status === "blocked"
? "WAITING"
: "UNASSIGNED";
const label = makeTextSprite(`${task.short} ${statusText}`, color);
label.position.set(0, 2.0, 0);
marker.add(label);
if (state.selectedTask === task.id) {
selectionOutline = new THREE.Group();
const outlineMaterial = new THREE.MeshBasicMaterial({
color: "#edf7ff",
transparent: true,
opacity: 0.9
});
const corner = (x, z, horizontal) => {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(
horizontal ? 0.75 : 0.08,
0.08,
horizontal ? 0.08 : 0.75
),
outlineMaterial
);
mesh.position.set(x, 0.19, z);
selectionOutline.add(mesh);
};
corner(-0.98, -0.53, true);
corner(0.98, -0.53, true);
corner(-0.98, 0.53, true);
corner(0.98, 0.53, true);
marker.add(selectionOutline);
}
dynamicGroup.add(marker);
}
const crewOffsets = [
[-0.85, -0.25],
[0.85, -0.25],
[-0.85, 0.45],
[0.85, 0.45],
[0, 0.8]
];
CREW.forEach((crew, crewIndex) => {
if (state.removed.has(crew.id)) return;
const assignedTasks = TASKS.filter(task =>
state.assignments[task.id] === crew.id
);
let position;
if (assignedTasks.length) {
const primaryTask = assignedTasks[assignedTasks.length - 1];
const [offsetX, offsetZ] = crewOffsets[crewIndex];
position = [
taskById[primaryTask.id].marker[0] + offsetX,
0,
taskById[primaryTask.id].marker[1] + offsetZ
];
} else {
position = [-4.6 + crewIndex * 2.3, 0, 7.65];
}
const personGroup = new THREE.Group();
personGroup.position.set(...position);
dynamicGroup.add(personGroup);
addVoxelPerson(personGroup, crew.color, crew.initials);
});
}
buildStaticScene();
// -------------------------------------------------------------------------
// Direct camera controls — no OrbitControls or other addons
// -------------------------------------------------------------------------
function updateCamera() {
const { theta, phi, radius, target } = cameraState;
const horizontal = Math.sin(phi) * radius;
camera.position.set(
target.x + horizontal * Math.cos(theta),
target.y + Math.cos(phi) * radius,
target.z + horizontal * Math.sin(theta)
);
camera.lookAt(target);
}
function resetCamera() {
cameraState.theta = 0.72;
cameraState.phi = 0.92;
cameraState.radius = 29;
cameraState.target.set(0, 0.5, 0);
updateCamera();
}
updateCamera();
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const dragState = {
active: false,
pointerId: null,
startX: 0,
startY: 0,
lastX: 0,
lastY: 0,
moved: false
};
renderer.domElement.addEventListener("pointerdown", event => {
if (event.button !== 0) return;
dragState.active = true;
dragState.pointerId = event.pointerId;
dragState.startX = dragState.lastX = event.clientX;
dragState.startY = dragState.lastY = event.clientY;
dragState.moved = false;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragState.active || event.pointerId !== dragState.pointerId) return;
const dx = event.clientX - dragState.lastX;
const dy = event.clientY - dragState.lastY;
if (
Math.abs(event.clientX - dragState.startX) +
Math.abs(event.clientY - dragState.startY) > 4
) {
dragState.moved = true;
}
cameraState.theta -= dx * 0.007;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi + dy * 0.006,
0.38,
1.36
);
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius,
17,
43
);
dragState.lastX = event.clientX;
dragState.lastY = event.clientY;
updateCamera();
});
renderer.domElement.addEventListener("pointerup", event => {
if (!dragState.active || event.pointerId !== dragState.pointerId) return;
if (!dragState.moved) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(markerPickables, false);
if (hits.length) {
const taskId = hits[0].object.userData.taskId;
state.selectedTask = taskId;
renderAll();
}
}
dragState.active = false;
dragState.pointerId = null;
});
renderer.domElement.addEventListener("pointercancel", () => {
dragState.active = false;
dragState.pointerId = null;
});
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
17,
43
);
updateCamera();
}, { passive: false });
document.querySelector("#zoomIn").addEventListener("click", () => {
cameraState.radius = Math.max(17, cameraState.radius * 0.86);
updateCamera();
});
document.querySelector("#zoomOut").addEventListener("click", () => {
cameraState.radius = Math.min(43, cameraState.radius * 1.16);
updateCamera();
});
document.querySelector("#resetCamera").addEventListener("click", resetCamera);
// -------------------------------------------------------------------------
// Interaction and state updates
// -------------------------------------------------------------------------
function removeVolunteer(id) {
if (state.removed.size) return;
state.removed.add(id);
for (const task of TASKS) {
if (state.assignments[task.id] === id) {
state.assignments[task.id] = null;
}
}
renderAll();
}
function restoreVolunteer(id) {
state.removed.delete(id);
// The task is not silently reassigned; the user may choose the restored
// volunteer again from the qualified assignment menu.
renderAll();
}
function resetScenario() {
state.assignments = { ...DEFAULT_ASSIGNMENTS };
state.removed.clear();
state.selectedTask = "power";
renderAll();
}
document.querySelector("#resetBtn").addEventListener("click", resetScenario);
removeBtn.addEventListener("click", () => removeVolunteer("jordan"));
scenarioEl.addEventListener("click", event => {
const removeButton = event.target.closest("[data-remove-primary]");
const restoreButton = event.target.closest("[data-restore]");
if (removeButton) removeVolunteer(removeButton.dataset.removePrimary);
if (restoreButton) restoreVolunteer(restoreButton.dataset.restore);
});
crewListEl.addEventListener("click", event => {
const removeButton = event.target.closest("[data-remove]");
const restoreButton = event.target.closest("[data-restore]");
if (removeButton) removeVolunteer(removeButton.dataset.remove);
if (restoreButton) restoreVolunteer(restoreButton.dataset.restore);
});
taskListEl.addEventListener("click", event => {
const card = event.target.closest("[data-select-task]");
const select = event.target.closest("select");
if (select) return;
if (card) {
state.selectedTask = card.dataset.selectTask;
renderAll();
}
});
taskListEl.addEventListener("change", event => {
const select = event.target.closest("[data-assign-task]");
if (!select) return;
const taskId = select.dataset.assignTask;
const crewId = select.value || null;
if (crewId) {
const crew = crewById[crewId];
const task = taskById[taskId];
if (
state.removed.has(crewId) ||
!crew.skills.includes(task.skill)
) {
return;
}
}
state.assignments[taskId] = crewId;
state.selectedTask = taskId;
renderAll();
});
analysisEl.addEventListener("click", event => {
if (!event.target.closest("#applySuggestion")) return;
const suggestion = buildSuggestion();
for (const item of suggestion) {
state.assignments[item.taskId] = item.crewId;
}
renderAll();
});
function renderAll() {
const schedule = calculateSchedule();
renderScenario(schedule);
renderCrew(schedule);
renderTasks(schedule);
renderAnalysis(schedule);
renderMetrics(schedule);
renderGantt(schedule);
renderSceneDynamics(schedule);
}
renderAll();
// -------------------------------------------------------------------------
// Resize and animation
// -------------------------------------------------------------------------
function resizeRenderer() {
const width = Math.max(1, sceneHost.clientWidth);
const height = Math.max(1, sceneHost.clientHeight);
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
if ("ResizeObserver" in window) {
new ResizeObserver(resizeRenderer).observe(sceneHost);
} else {
window.addEventListener("resize", resizeRenderer);
}
resizeRenderer();
document.querySelector("#loading").style.display = "none";
function animate(time) {
requestAnimationFrame(animate);
if (selectionOutline) {
const pulse = 1 + Math.sin(time * 0.004) * 0.045;
selectionOutline.scale.setScalar(pulse);
}
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```