Prompt specification
Build or customize the Three.js 3D scene "Event-contingency scheduling game" 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: Event-contingency scheduling game
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/event-contingency-scheduling-game-x3860
Scene Description Prompt:
Please use Three.js from cdnjs for a low-poly scene based on this idea: event-contingency scheduling game. Create a fictional festival with changing weather and limited indoor space; users prioritize and relocate activities while tracking capacity, required equipment, and setup dependencies explicitly. Return one self-contained HTML file.
Working Three.js Starter (event-contingency-scheduling-game-x3860):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fieldwork — Festival Contingency Planner</title>
<style>
:root {
--ink: #f3f6ef;
--muted: #a8b4b0;
--panel: rgba(17, 27, 32, 0.91);
--panel-soft: rgba(30, 43, 48, 0.72);
--line: rgba(224, 240, 232, 0.13);
--accent: #c9f269;
--cyan: #68d7d1;
--orange: #ffb35c;
--red: #ff7474;
--purple: #c5a4ff;
}
* { box-sizing: border-box; }
html, body {
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #9bcbd4;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button { font: inherit; }
button:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
}
.glass {
background: var(--panel);
border: 1px solid var(--line);
box-shadow: 0 18px 60px rgba(4, 12, 16, 0.25);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
}
#topbar {
position: fixed;
z-index: 20;
top: 14px;
left: 14px;
right: 14px;
height: 66px;
border-radius: 16px;
display: flex;
align-items: center;
gap: 18px;
padding: 10px 14px;
}
.brand {
display: flex;
align-items: center;
gap: 11px;
min-width: 215px;
}
.brand-mark {
width: 37px;
height: 37px;
border-radius: 11px;
display: grid;
place-items: center;
color: #142026;
background: var(--accent);
font-weight: 950;
transform: rotate(-4deg);
box-shadow: 4px 4px 0 rgba(104, 215, 209, 0.35);
}
.brand strong {
display: block;
font-size: 15px;
letter-spacing: 0.12em;
}
.brand small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 10px;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.top-stat {
min-width: 92px;
padding-left: 16px;
border-left: 1px solid var(--line);
}
.top-stat span {
display: block;
color: var(--muted);
font-size: 9px;
text-transform: uppercase;
letter-spacing: 0.12em;
}
.top-stat strong {
display: block;
margin-top: 3px;
font-size: 16px;
font-variant-numeric: tabular-nums;
}
.top-stat.weather strong { color: var(--accent); }
#top-actions {
margin-left: auto;
display: flex;
align-items: center;
gap: 7px;
}
.icon-btn, .small-btn {
color: var(--ink);
background: rgba(255,255,255,0.055);
border: 1px solid var(--line);
border-radius: 9px;
padding: 8px 10px;
cursor: pointer;
transition: background .15s, transform .15s, border-color .15s;
}
.icon-btn:hover, .small-btn:hover {
background: rgba(255,255,255,0.12);
border-color: rgba(255,255,255,0.25);
}
.icon-btn:active, .small-btn:active { transform: translateY(1px); }
.panel {
position: fixed;
z-index: 15;
top: 92px;
bottom: 14px;
border-radius: 18px;
overflow: hidden;
display: flex;
flex-direction: column;
}
#left-panel {
left: 14px;
width: 330px;
}
#right-panel {
right: 14px;
width: 360px;
}
.panel-head {
padding: 17px 18px 12px;
border-bottom: 1px solid var(--line);
flex: 0 0 auto;
}
.eyebrow {
color: var(--muted);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.panel-title {
display: flex;
justify-content: space-between;
align-items: center;
gap: 10px;
margin-top: 4px;
}
.panel-title h2 {
margin: 0;
font-size: 20px;
letter-spacing: -0.02em;
}
.pill {
padding: 4px 7px;
border-radius: 999px;
background: rgba(201, 242, 105, 0.12);
color: var(--accent);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.scroll {
overflow-y: auto;
padding: 13px;
scrollbar-width: thin;
scrollbar-color: rgba(255,255,255,.18) transparent;
}
.scroll::-webkit-scrollbar { width: 6px; }
.scroll::-webkit-scrollbar-thumb {
background: rgba(255,255,255,.18);
border-radius: 8px;
}
.weather-card {
padding: 14px;
border-radius: 14px;
background: linear-gradient(135deg, rgba(201,242,105,.11), rgba(104,215,209,.055));
border: 1px solid rgba(201,242,105,.17);
margin-bottom: 13px;
}
.weather-current {
display: flex;
align-items: center;
gap: 12px;
}
.weather-icon {
width: 43px;
height: 43px;
display: grid;
place-items: center;
border-radius: 12px;
background: rgba(255,255,255,.08);
font-size: 23px;
color: var(--accent);
}
.weather-current strong {
display: block;
font-size: 16px;
}
.weather-current small {
display: block;
color: var(--muted);
margin-top: 2px;
font-size: 11px;
}
.forecast {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 5px;
margin-top: 13px;
}
.forecast div {
min-width: 0;
padding: 7px 4px;
border-radius: 9px;
text-align: center;
background: rgba(0,0,0,.13);
}
.forecast b {
display: block;
font-size: 15px;
color: var(--cyan);
}
.forecast span {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.event-card {
position: relative;
margin-bottom: 9px;
padding: 12px;
border-radius: 14px;
border: 1px solid var(--line);
background: rgba(255,255,255,.035);
cursor: pointer;
overflow: hidden;
transition: border-color .15s, background .15s, transform .15s;
}
.event-card:hover {
background: rgba(255,255,255,.065);
transform: translateX(2px);
}
.event-card.selected {
border-color: color-mix(in srgb, var(--accent) 65%, transparent);
background: rgba(201,242,105,.065);
}
.event-card.selected::before {
content: "";
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 3px;
background: var(--accent);
}
.event-top {
display: flex;
align-items: flex-start;
gap: 10px;
}
.priority-box {
width: 31px;
height: 36px;
flex: 0 0 auto;
border-radius: 9px;
display: grid;
place-items: center;
color: #152025;
background: var(--accent);
font-weight: 950;
font-size: 15px;
}
.event-info { min-width: 0; flex: 1; }
.event-name-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.event-name {
font-weight: 800;
font-size: 13px;
}
.status {
flex: 0 0 auto;
border-radius: 999px;
padding: 4px 7px;
font-size: 8px;
font-weight: 900;
letter-spacing: .08em;
text-transform: uppercase;
}
.status.live { color: var(--accent); background: rgba(201,242,105,.12); }
.status.setup { color: var(--orange); background: rgba(255,179,92,.13); }
.status.hold { color: var(--red); background: rgba(255,116,116,.14); }
.event-location {
margin-top: 4px;
color: var(--muted);
font-size: 10px;
}
.mini-bar {
height: 4px;
overflow: hidden;
border-radius: 5px;
background: rgba(255,255,255,.09);
margin-top: 10px;
}
.mini-bar > span {
display: block;
height: 100%;
border-radius: inherit;
background: var(--cyan);
transition: width .4s ease;
}
.event-footer {
margin-top: 6px;
display: flex;
justify-content: space-between;
gap: 8px;
color: var(--muted);
font-size: 9px;
}
.issue-chip {
display: inline-block;
margin-top: 8px;
padding: 4px 6px;
border-radius: 6px;
color: var(--orange);
background: rgba(255,179,92,.1);
font-size: 9px;
}
.priority-actions {
display: flex;
gap: 3px;
}
.priority-actions button {
width: 22px;
height: 22px;
padding: 0;
border-radius: 6px;
border: 1px solid var(--line);
background: rgba(255,255,255,.04);
color: var(--ink);
cursor: pointer;
line-height: 1;
}
.priority-actions button:hover { background: rgba(255,255,255,.12); }
.howto {
margin-top: 4px;
padding: 11px 12px;
border-radius: 12px;
color: var(--muted);
background: rgba(255,255,255,.03);
border: 1px solid var(--line);
font-size: 10px;
line-height: 1.55;
}
.howto strong { color: var(--ink); }
.inspector-scroll { padding: 0 15px 15px; }
.activity-hero {
padding: 17px 0 14px;
border-bottom: 1px solid var(--line);
}
.activity-hero h3 {
margin: 5px 0 4px;
font-size: 24px;
letter-spacing: -.035em;
}
.activity-hero p {
margin: 0;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
.inspector-section {
padding: 14px 0;
border-bottom: 1px solid var(--line);
}
.section-title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
font-size: 10px;
font-weight: 850;
letter-spacing: .12em;
text-transform: uppercase;
}
.section-title span {
color: var(--muted);
font-weight: 600;
letter-spacing: .03em;
text-transform: none;
}
.priority-control {
display: flex;
align-items: center;
gap: 8px;
}
.priority-control button {
border: 1px solid var(--line);
background: rgba(255,255,255,.05);
color: var(--ink);
border-radius: 8px;
width: 34px;
height: 30px;
cursor: pointer;
}
.priority-control button:hover { background: rgba(255,255,255,.13); }
.priority-control .rank {
flex: 1;
text-align: center;
font-weight: 800;
font-size: 12px;
}
.capacity-card {
padding: 12px;
border-radius: 12px;
background: rgba(255,255,255,.035);
border: 1px solid var(--line);
}
.capacity-line {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 10px;
}
.capacity-line strong {
font-size: 19px;
font-variant-numeric: tabular-nums;
}
.capacity-line span {
color: var(--muted);
font-size: 10px;
}
.capacity-track {
height: 8px;
background: rgba(255,255,255,.08);
border-radius: 8px;
overflow: hidden;
margin-top: 9px;
}
.capacity-track > span {
display: block;
height: 100%;
width: 0;
border-radius: inherit;
background: var(--cyan);
transition: width .35s;
}
.capacity-note {
display: flex;
justify-content: space-between;
margin-top: 7px;
color: var(--muted);
font-size: 9px;
}
.gear-row {
display: grid;
grid-template-columns: 1fr auto;
gap: 7px 12px;
padding: 8px 0;
border-bottom: 1px dashed rgba(255,255,255,.08);
}
.gear-row:last-child { border-bottom: 0; }
.gear-name {
font-size: 11px;
font-weight: 700;
}
.gear-qty {
color: var(--muted);
font-size: 10px;
text-align: right;
}
.gear-qty.ok { color: var(--accent); }
.gear-qty.short { color: var(--red); }
.dependency-list {
display: grid;
gap: 7px;
}
.dependency {
display: flex;
align-items: center;
gap: 9px;
font-size: 10px;
color: var(--muted);
}
.dependency i {
width: 17px;
height: 17px;
display: grid;
place-items: center;
flex: 0 0 auto;
border-radius: 50%;
border: 1px solid var(--line);
font-style: normal;
font-size: 9px;
}
.dependency.ok { color: var(--ink); }
.dependency.ok i { color: #152025; background: var(--accent); border-color: var(--accent); }
.dependency.bad i { color: var(--red); border-color: rgba(255,116,116,.45); }
.setup-chain {
position: relative;
display: grid;
gap: 0;
margin-top: 5px;
}
.setup-step {
position: relative;
min-height: 38px;
padding-left: 35px;
}
.setup-step:not(:last-child)::before {
content: "";
position: absolute;
left: 12px;
top: 24px;
bottom: -3px;
width: 1px;
background: var(--line);
}
.setup-step b {
position: absolute;
left: 0;
top: 0;
width: 25px;
height: 25px;
display: grid;
place-items: center;
border-radius: 50%;
border: 1px solid var(--line);
color: var(--muted);
background: #1a282d;
font-size: 10px;
}
.setup-step strong {
display: block;
font-size: 10px;
line-height: 1.25;
}
.setup-step small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 9px;
}
.setup-step.done b {
color: #152025;
background: var(--accent);
border-color: var(--accent);
}
.setup-step.current b {
color: var(--orange);
border-color: var(--orange);
box-shadow: 0 0 0 4px rgba(255,179,92,.08);
}
.setup-step.current strong { color: var(--orange); }
.action-stack {
display: grid;
gap: 8px;
padding-top: 14px;
}
.primary-btn, .secondary-btn, .warning-btn {
border-radius: 10px;
padding: 11px 12px;
cursor: pointer;
border: 1px solid transparent;
font-weight: 850;
font-size: 11px;
transition: transform .15s, filter .15s, opacity .15s;
}
.primary-btn {
color: #142026;
background: var(--accent);
}
.secondary-btn {
color: var(--ink);
background: rgba(255,255,255,.065);
border-color: var(--line);
}
.warning-btn {
color: var(--ink);
background: rgba(255,179,92,.13);
border-color: rgba(255,179,92,.35);
}
.primary-btn:hover, .secondary-btn:hover, .warning-btn:hover {
filter: brightness(1.08);
transform: translateY(-1px);
}
button:disabled {
opacity: .42;
cursor: not-allowed;
transform: none !important;
filter: none !important;
}
.fine-print {
color: var(--muted);
font-size: 9px;
line-height: 1.5;
}
#map-labels {
position: fixed;
inset: 0;
z-index: 8;
pointer-events: none;
}
.map-label {
position: absolute;
left: 0;
top: 0;
pointer-events: auto;
min-width: 118px;
max-width: 155px;
padding: 8px 10px;
border-radius: 11px;
border: 1px solid rgba(255,255,255,.25);
color: #f8fbf5;
background: rgba(19,31,36,.84);
box-shadow: 0 9px 24px rgba(3,9,12,.22);
backdrop-filter: blur(8px);
cursor: pointer;
text-align: left;
transition: opacity .2s, border-color .2s, background .2s;
}
.map-label:hover { background: rgba(19,31,36,.96); }
.map-label.valid { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201,242,105,.12); }
.map-label.invalid { opacity: .34; }
.map-label strong {
display: block;
font-size: 10px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.map-label small {
display: block;
margin-top: 3px;
color: #b5c1bd;
font-size: 8px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.map-label .label-dot {
display: inline-block;
width: 7px;
height: 7px;
border-radius: 50%;
margin-right: 5px;
background: #83918e;
}
#relocate-banner {
position: fixed;
z-index: 30;
top: 92px;
left: 50%;
transform: translateX(-50%);
display: none;
align-items: center;
gap: 12px;
padding: 9px 10px 9px 14px;
border-radius: 12px;
color: #162126;
background: var(--accent);
box-shadow: 0 12px 35px rgba(10,20,20,.25);
font-size: 11px;
font-weight: 750;
}
#relocate-banner button {
border: 0;
border-radius: 7px;
padding: 5px 8px;
color: #162126;
background: rgba(22,33,38,.13);
cursor: pointer;
}
#toasts {
position: fixed;
z-index: 50;
left: 50%;
bottom: 23px;
transform: translateX(-50%);
width: min(440px, calc(100vw - 30px));
display: grid;
gap: 8px;
pointer-events: none;
}
.toast {
padding: 11px 14px;
border-radius: 11px;
color: var(--ink);
background: rgba(17,27,32,.94);
border: 1px solid var(--line);
box-shadow: 0 14px 35px rgba(0,0,0,.25);
font-size: 11px;
animation: toast-in .25s ease both;
}
.toast.warn { border-color: rgba(255,179,92,.42); }
.toast.good { border-color: rgba(201,242,105,.4); }
@keyframes toast-in {
from { opacity: 0; transform: translateY(8px); }
to { opacity: 1; transform: translateY(0); }
}
#map-hint {
position: fixed;
z-index: 7;
left: 50%;
bottom: 18px;
transform: translateX(-50%);
padding: 7px 11px;
border-radius: 999px;
color: rgba(245,249,242,.85);
background: rgba(17,27,32,.66);
border: 1px solid rgba(255,255,255,.15);
font-size: 9px;
letter-spacing: .04em;
pointer-events: none;
}
@media (max-width: 1120px) {
#left-panel { width: 292px; }
#right-panel { width: 326px; }
.brand { min-width: 175px; }
.brand small { display: none; }
.top-stat { min-width: 76px; padding-left: 10px; }
#mood-stat { display: none; }
}
@media (max-width: 850px) {
#topbar { gap: 8px; }
.top-stat { display: none; }
.brand { min-width: auto; }
#left-panel { width: 255px; }
#right-panel { width: 285px; }
.event-name { font-size: 11px; }
.forecast { grid-template-columns: repeat(2, 1fr); }
.map-label { min-width: 100px; max-width: 125px; }
}
@media (max-width: 680px) {
#topbar { top: 7px; left: 7px; right: 7px; height: 58px; }
.brand strong { font-size: 12px; }
.brand-mark { width: 32px; height: 32px; }
#top-actions .small-btn { padding: 7px 8px; font-size: 10px; }
#reset-btn { display: none; }
.panel { top: 73px; bottom: 7px; }
#left-panel { left: 7px; width: 48%; }
#right-panel { right: 7px; width: 48%; }
.panel-head { padding: 12px; }
.panel-title h2 { font-size: 15px; }
.weather-card { padding: 10px; }
.event-card { padding: 9px; }
.event-location, .event-footer, .issue-chip { display: none; }
.inspector-scroll { padding: 0 10px 10px; }
.activity-hero h3 { font-size: 18px; }
.activity-hero p { display: none; }
.map-label { display: none !important; }
#map-hint { display: none; }
#relocate-banner { top: 72px; width: calc(100vw - 20px); justify-content: center; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive three-dimensional festival site"></canvas>
<header id="topbar" class="glass">
<div class="brand">
<div class="brand-mark">F</div>
<div>
<strong>FIELDWORK</strong>
<small>Contingency festival planner</small>
</div>
</div>
<div class="top-stat">
<span>Festival time</span>
<strong id="clock">11:00</strong>
</div>
<div class="top-stat weather">
<span>Conditions</span>
<strong id="weather-top">☀ Sunlit</strong>
</div>
<div class="top-stat">
<span>Attendance</span>
<strong id="attendance-stat">0 / 540</strong>
</div>
<div class="top-stat">
<span>Live setups</span>
<strong id="setup-stat">0 / 4</strong>
</div>
<div class="top-stat" id="mood-stat">
<span>Guest mood</span>
<strong id="mood-value">—</strong>
</div>
<div id="top-actions">
<button id="pause-btn" class="small-btn" title="Pause festival time">Pause</button>
<button id="speed-btn" class="small-btn" title="Change simulation speed">1×</button>
<button id="ff-btn" class="small-btn" title="Fast-forward 30 festival minutes">+30m</button>
<button id="reset-btn" class="small-btn" title="Reset the festival">Reset</button>
</div>
</header>
<section id="left-panel" class="panel glass">
<div class="panel-head">
<div class="eyebrow">Live operations</div>
<div class="panel-title">
<h2>Festival runboard</h2>
<span class="pill" id="budget-pill">$1,800</span>
</div>
</div>
<div class="scroll">
<div id="weather-card" class="weather-card"></div>
<div id="activity-list"></div>
<div class="howto">
<strong>How to keep the festival moving:</strong><br>
Set priorities, verify equipment, complete setup dependencies, and relocate activities before severe weather arrives. Moving an activity resets its site setup.
</div>
</div>
</section>
<section id="right-panel" class="panel glass">
<div class="panel-head">
<div class="eyebrow">Selected activity</div>
<div class="panel-title">
<h2>Contingency inspector</h2>
<span class="pill" id="selected-pill">Live plan</span>
</div>
</div>
<div id="inspector" class="scroll inspector-scroll"></div>
</section>
<div id="map-labels"></div>
<div id="relocate-banner">
<span id="relocate-text"></span>
<button id="cancel-relocate">Cancel</button>
</div>
<div id="toasts" aria-live="polite"></div>
<div id="map-hint">Drag to orbit · Wheel to zoom · Right-drag to pan · Click a venue to inspect</div>
<script type="module">
import * as THREE from 'https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js';
const $ = (selector) => document.querySelector(selector);
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
const lerp = (a, b, t) => a + (b - a) * t;
const sites = [
{
id: 'meadow', name: 'Lantern Meadow', type: 'outdoor', capacity: 150,
position: [-25, -15], color: 0x8fbf78,
features: ['Power', 'Open sky']
},
{
id: 'yard', name: 'Workshop Yard', type: 'semi', capacity: 90,
position: [18, -19], color: 0xe6a86d,
features: ['Power', 'Shade bays']
},
{
id: 'atrium', name: 'Glass Atrium', type: 'indoor', capacity: 70,
position: [-22, 18], color: 0x77b9b4,
features: ['Power', 'Network', 'Blackout']
},
{
id: 'signal', name: 'Signal Hall', type: 'indoor', capacity: 110,
position: [3, 26], color: 0x9f8ec6,
features: ['Power', 'Network', 'Blackout']
},
{
id: 'river', name: 'Riverside Deck', type: 'outdoor', capacity: 120,
position: [29, 5], color: 0xe2c46c,
features: ['Power', 'Open sky']
}
];
const activityTemplates = [
{
id: 'aurora',
name: 'Aurora Sessions',
short: 'Aurora',
description: 'A sunset live set with synchronized lighting and a compact PA system.',
color: 0xc5a4ff,
priority: 1,
location: 'meadow',
baseGuests: 95,
placement: 'any',
crew: 2,
crewRole: 'Audio Pair',
features: ['Power'],
gear: { 'PA rack': 1, 'Stage deck': 1 },
steps: ['Power drop inspected', 'PA and stage assembled', 'Doors opened']
},
{
id: 'pixel',
name: 'Pixel Picnic',
short: 'Pixel',
description: 'Portable arcade cabinets, cooperative games, and shaded maker benches.',
color: 0x68d7d1,
priority: 2,
location: 'yard',
baseGuests: 72,
placement: 'any',
crew: 2,
crewRole: 'Game Masters',
features: ['Power'],
gear: { 'Work table': 6, 'Handheld console': 4 },
steps: ['Power drop inspected', 'Tables and consoles dressed', 'Doors opened']
},
{
id: 'moon',
name: 'Moonlight Cinema',
short: 'Cinema',
description: 'Short-form film screenings that require blackout, projection, and reliable power.',
color: 0xffd36f,
priority: 3,
location: 'atrium',
baseGuests: 60,
placement: 'indoor',
crew: 1,
crewRole: 'Projection Tech',
features: ['Power', 'Network', 'Blackout'],
gear: { 'Projector': 2, 'Screen': 1 },
steps: ['Screen mounted and blackout checked', 'Projectors focused and networked', 'Doors opened']
},
{
id: 'bazaar',
name: 'Makers’ Bazaar',
short: 'Bazaar',
description: 'Local food and craft stalls with canopy, lighting, and a reliable power feed.',
color: 0xff9b67,
priority: 4,
location: 'river',
baseGuests: 82,
placement: 'outdoor',
crew: 3,
crewRole: 'Market Crew',
features: ['Power'],
gear: { 'Market stall': 6, 'Canopy': 2 },
steps: ['Power drop inspected', 'Stalls and lighting assembled', 'Doors opened']
}
];
const activities = activityTemplates.map(activity => ({
...activity,
gear: { ...activity.gear },
steps: [...activity.steps],
setupIndex: 0,
attendance: 0
}));
const weatherSchedule = [
{ minute: 660, key: 'sunny', label: 'Sunlit', icon: '☀' },
{ minute: 720, key: 'hot', label: 'Heat haze', icon: '♨' },
{ minute: 840, key: 'cloud', label: 'Cloud cover', icon: '☁' },
{ minute: 900, key: 'storm', label: 'Storm front', icon: 'ϟ' },
{ minute: 990, key: 'rain', label: 'Steady rain', icon: '☂' },
{ minute: 1080, key: 'clear', label: 'Clear skies', icon: '☀' },
{ minute: 1200, key: 'dusk', label: 'Blue dusk', icon: '☾' },
{ minute: 1290, key: 'clear', label: 'Clear skies', icon: '☀' }
];
const weatherEffects = {
sunny: { outdoor: 1.05, indoor: 1.00, sky: 0x91cfe6, sun: 2.3, ambient: 1.15, cloud: 0.22 },
hot: { outdoor: 0.90, indoor: 1.00, sky: 0xefc895, sun: 2.7, ambient: 1.05, cloud: 0.18 },
cloud: { outdoor: 0.94, indoor: 1.00, sky: 0x9aaeb8, sun: 1.15, ambient: 1.25, cloud: 0.76 },
storm: { outdoor: 0.50, indoor: 0.95, sky: 0x455568, sun: 0.55, ambient: 0.85, cloud: 1.00 },
rain: { outdoor: 0.72, indoor: 0.98, sky: 0x708899, sun: 0.70, ambient: 1.05, cloud: 0.92 },
clear: { outdoor: 1.00, indoor: 1.00, sky: 0x9bd8e7, sun: 2.25, ambient: 1.10, cloud: 0.30 },
dusk: { outdoor: 0.90, indoor: 1.00, sky: 0x55577f, sun: 0.95, ambient: 0.95, cloud: 0.42 }
};
const gearCosts = {
'PA rack': 240,
'Stage deck': 180,
'Work table': 35,
'Handheld console': 55,
'Projector': 320,
'Screen': 260,
'Market stall': 70,
'Canopy': 95
};
let inventory = {
'PA rack': 2,
'Stage deck': 2,
'Work table': 8,
'Handheld console': 5,
'Projector': 1,
'Screen': 1,
'Market stall': 8,
'Canopy': 3
};
let festivalMinutes = 660;
let paused = false;
let speed = 1;
let budget = 1800;
let selectedId = 'aurora';
let relocating = false;
let currentWeather = 'sunny';
let ended = false;
const CREW_TOTAL = 8;
const canvas = $('#scene');
const renderer = new THREE.WebGLRenderer({ canvas, antialias: true });
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();
const camera = new THREE.PerspectiveCamera(43, window.innerWidth / window.innerHeight, 0.1, 260);
const targetSky = new THREE.Color(0x91cfe6);
scene.background = targetSky.clone();
scene.fog = new THREE.Fog(targetSky.clone(), 65, 155);
const ambientLight = new THREE.HemisphereLight(0xe9fbff, 0x667a52, 1.15);
scene.add(ambientLight);
const sunLight = new THREE.DirectionalLight(0xfff0d0, 2.3);
sunLight.position.set(-35, 55, 25);
sunLight.castShadow = true;
sunLight.shadow.mapSize.set(2048, 2048);
sunLight.shadow.camera.left = -65;
sunLight.shadow.camera.right = 65;
sunLight.shadow.camera.top = 65;
sunLight.shadow.camera.bottom = -65;
sunLight.shadow.camera.near = 1;
sunLight.shadow.camera.far = 140;
scene.add(sunLight);
const rimLight = new THREE.DirectionalLight(0x7ed9ff, 0.55);
rimLight.position.set(40, 20, -35);
scene.add(rimLight);
const flatMaterial = (color, options = {}) => new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.85,
metalness: options.metalness ?? 0,
flatShading: options.flatShading ?? true,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1,
side: options.side ?? THREE.FrontSide
});
const shadowify = (object) => {
object.traverse(child => {
if (child.isMesh) {
child.castShadow = true;
child.receiveShadow = true;
}
});
return object;
};
function makeBox(parent, size, position, color, options = {}) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
flatMaterial(color, options)
);
mesh.position.set(position[0], position[1], position[2]);
if (options.rotationY) mesh.rotation.y = options.rotationY;
parent.add(mesh);
return mesh;
}
function makeCylinder(parent, radiusTop, radiusBottom, height, sides, position, color, options = {}) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radiusTop, radiusBottom, height, sides),
flatMaterial(color, options)
);
mesh.position.set(position[0], position[1], position[2]);
parent.add(mesh);
return mesh;
}
function makeCone(parent, radius, height, sides, position, color, options = {}) {
const mesh = new THREE.Mesh(
new THREE.ConeGeometry(radius, height, sides),
flatMaterial(color, options)
);
mesh.position.set(position[0], position[1], position[2]);
parent.add(mesh);
return mesh;
}
// Festival terrain.
const ground = new THREE.Mesh(
new THREE.CylinderGeometry(66, 69, 2.2, 18),
flatMaterial(0x829b68)
);
ground.position.y = -1.1;
ground.receiveShadow = true;
scene.add(ground);
const grassPatch = new THREE.Mesh(
new THREE.CircleGeometry(48, 16),
flatMaterial(0x8ca66f)
);
grassPatch.rotation.x = -Math.PI / 2;
grassPatch.position.y = 0.015;
grassPatch.receiveShadow = true;
scene.add(grassPatch);
const river = new THREE.Mesh(
new THREE.CircleGeometry(16, 12),
flatMaterial(0x5eafba, { roughness: 0.35, metalness: 0.05 })
);
river.rotation.x = -Math.PI / 2;
river.scale.set(1.5, 0.48, 1);
river.position.set(47, 0.035, -2);
scene.add(river);
const pathMaterial = flatMaterial(0xc5b995);
function addPath(a, b) {
const dx = b[0] - a[0];
const dz = b[1] - a[1];
const length = Math.hypot(dx, dz);
const path = new THREE.Mesh(new THREE.BoxGeometry(length, 0.12, 2.1), pathMaterial);
path.position.set((a[0] + b[0]) / 2, 0.08, (a[1] + b[1]) / 2);
path.rotation.y = -Math.atan2(dz, dx);
path.receiveShadow = true;
scene.add(path);
}
addPath([-25, -15], [18, -19]);
addPath([-25, -15], [-22, 18]);
addPath([-22, 18], [3, 26]);
addPath([3, 26], [29, 5]);
addPath([18, -19], [29, 5]);
// Deterministic low-poly trees around the perimeter.
let randomSeed = 8127;
function random() {
randomSeed = (randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
function addTree(x, z, scale = 1) {
const tree = new THREE.Group();
tree.position.set(x, 0, z);
tree.scale.setScalar(scale);
makeCylinder(tree, 0.35, 0.48, 3.2, 6, [0, 1.6, 0], 0x76543a);
makeCone(tree, 2.2, 4.8, 7, [0, 4.6, 0], 0x4d7956);
makeCone(tree, 1.65, 3.6, 7, [0, 6.3, 0], 0x628f62);
scene.add(shadowify(tree));
}
let treeCount = 0;
while (treeCount < 28) {
const x = (random() - 0.5) * 112;
const z = (random() - 0.5) * 100;
const nearSite = sites.some(site => Math.hypot(x - site.position[0], z - site.position[1]) < 14);
if (!nearSite && Math.hypot(x, z) > 35) {
addTree(x, z, 0.75 + random() * 0.65);
treeCount++;
}
}
for (let i = 0; i < 14; i++) {
const angle = (i / 14) * Math.PI * 2;
const radius = 51 + random() * 7;
const rock = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.6 + random() * 0.9, 0),
flatMaterial(i % 2 ? 0x8f9b8e : 0xa8aa94)
);
rock.position.set(Math.cos(angle) * radius, 0.3, Math.sin(angle) * radius);
rock.scale.y = 0.6 + random() * 0.5;
scene.add(shadowify(rock));
}
const pickables = [];
const siteLabels = new Map();
function buildVenue(site) {
const group = new THREE.Group();
group.position.set(site.position[0], 0, site.position[1]);
const pad = makeCylinder(group, 10.4, 10.8, 0.55, 10, [0, 0.22, 0], site.color);
pad.receiveShadow = true;
const ring = new THREE.Mesh(
new THREE.TorusGeometry(9.8, 0.12, 4, 32),
flatMaterial(0xf2e6bf)
);
ring.rotation.x = Math.PI / 2;
ring.position.y = 0.53;
group.add(ring);
if (site.id === 'meadow') {
for (const angle of [-2.45, -0.7, 0.7, 2.45]) {
const x = Math.cos(angle) * 8.5;
const z = Math.sin(angle) * 8.5;
makeCylinder(group, 0.09, 0.09, 4.6, 6, [x, 2.7, z], 0x725741);
makeCone(group, 0.85, 1.8, 5, [x, 5.2, z], 0xf4b55f);
}
}
if (site.id === 'yard') {
for (const [x, z, color] of [[-6,-4,0xf2c96d],[-6,5,0x7fc8c2],[6,-4,0xe89472]]) {
makeCylinder(group, 0.12, 0.12, 4.4, 6, [x, 2.5, z], 0x715643);
makeCone(group, 2.7, 1.65, 4, [x, 4.7, z], color, { side: THREE.DoubleSide });
}
}
if (site.type === 'indoor') {
const floor = makeBox(group, [14, 0.35, 12], [0, 0.7, 0], 0xd6c9a8);
floor.receiveShadow = true;
for (const x of [-6.4, 6.4]) {
for (const z of [-5.2, 5.2]) {
makeCylinder(group, 0.25, 0.25, 6.3, 6, [x, 3.7, z], 0x63777a);
}
}
const roof = makeBox(
group,
[14.8, 0.35, 12.8],
[0, 7.05, 0],
site.id === 'signal' ? 0x8f86b1 : 0x87aaa6,
{ transparent: true, opacity: 0.58 }
);
roof.castShadow = false;
makeBox(group, [14.8, 0.55, 0.35], [0, 6.9, 6.25], 0x53686a);
makeBox(group, [0.35, 0.55, 12.8], [-6.85, 6.9, 0], 0x53686a);
}
if (site.id === 'river') {
for (let i = -3; i <= 3; i++) {
makeBox(group, [12, 0.18, 1.55], [0, 0.68, i * 1.45], 0xa87c52);
}
}
// Small entry marker for every venue.
makeCylinder(group, 0.11, 0.11, 3.5, 6, [-8.4, 2.1, 8], 0x725741);
const sign = makeBox(group, [2.4, 1.15, 0.18], [-8.4, 3.8, 8], 0xf1d991);
sign.rotation.y = -0.15;
scene.add(shadowify(group));
const picker = new THREE.Mesh(
new THREE.CircleGeometry(10.8, 16),
new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false,
side: THREE.DoubleSide
})
);
picker.rotation.x = -Math.PI / 2;
picker.position.set(site.position[0], 0.57, site.position[1]);
picker.userData.siteId = site.id;
scene.add(picker);
pickables.push(picker);
}
sites.forEach(buildVenue);
// Entrance arch.
const entrance = new THREE.Group();
entrance.position.set(0, 0, 42);
makeCylinder(entrance, 0.32, 0.32, 8.5, 6, [-8, 4.25, 0], 0xe97659);
makeCylinder(entrance, 0.32, 0.32, 8.5, 6, [8, 4.25, 0], 0xe97659);
makeBox(entrance, [17, 1.6, 0.5], [0, 8, 0], 0xf0d86e);
const entranceText = makeBox(entrance, [8.5, 0.45, 0.58], [0, 8.05, 0], 0x26383b);
scene.add(shadowify(entrance));
// Cloud bank.
const cloudMaterial = flatMaterial(0xf2f4ef, { transparent: true, opacity: 0.22 });
const cloudGroups = [];
for (let i = 0; i < 7; i++) {
const cloud = new THREE.Group();
cloud.position.set(-58 + i * 18, 27 + random() * 8, -42 + random() * 75);
for (let j = 0; j < 4; j++) {
const puff = new THREE.Mesh(new THREE.DodecahedronGeometry(3 + random() * 2, 0), cloudMaterial);
puff.position.set(j * 3.2 - 4.5, random() * 1.8, random() * 2);
puff.scale.y = 0.6;
cloud.add(puff);
}
scene.add(cloud);
cloudGroups.push(cloud);
}
// Rain line segments.
const rainCount = 420;
const rainPositions = new Float32Array(rainCount * 6);
for (let i = 0; i < rainCount; i++) {
const offset = i * 6;
const x = (random() - 0.5) * 125;
const y = random() * 38;
const z = (random() - 0.5) * 110;
rainPositions[offset] = x;
rainPositions[offset + 1] = y;
rainPositions[offset + 2] = z;
rainPositions[offset + 3] = x + 0.12;
rainPositions[offset + 4] = y - 1.25;
rainPositions[offset + 5] = z;
}
const rainGeometry = new THREE.BufferGeometry();
rainGeometry.setAttribute('position', new THREE.BufferAttribute(rainPositions, 3));
const rain = new THREE.LineSegments(
rainGeometry,
new THREE.LineBasicMaterial({ color: 0xd6f1ff, transparent: true, opacity: 0.65 })
);
rain.frustumCulled = false;
scene.add(rain);
// Activity models and crowds.
const activityGroups = {};
function makePerson(color) {
const person = new THREE.Group();
const body = makeCylinder(person, 0.22, 0.28, 0.75, 5, [0, 0.5, 0], color);
const head = new THREE.Mesh(new THREE.DodecahedronGeometry(0.25, 0), flatMaterial(0xe8c6a4));
head.position.y = 1.02;
person.add(head);
body.castShadow = true;
head.castShadow = true;
return person;
}
function buildActivityVisual(activity) {
const group = new THREE.Group();
const color = activity.color;
if (activity.id === 'aurora') {
makeBox(group, [6.5, 0.8, 4.2], [0, 0.65, 0], 0x5b4d72);
makeBox(group, [6.8, 4.2, 0.28], [0, 2.6, -2], 0x775da8);
for (const x of [-3.3, 3.3]) {
makeBox(group, [1.0, 2.4, 0.9], [x, 1.8, 0], 0x252a35);
makeCone(group, 0.65, 0.9, 6, [x, 3.3, 0], color);
}
makeBox(group, [7.3, 0.18, 0.18], [0, 4.65, -1.8], 0xb8b7bb);
}
if (activity.id === 'pixel') {
for (const x of [-4, 0, 4]) {
for (const z of [-2.4, 2.4]) {
makeBox(group, [2.8, 0.18, 1.35], [x, 1.35, z], 0xe9dfc5);
makeCylinder(group, 0.12, 0.12, 1.2, 5, [x, 0.65, z], 0x68787a);
makeBox(group, [1.05, 1.6, 0.8], [x, 1.85, z + 0.1], color);
makeBox(group, [0.75, 0.55, 0.08], [x, 2.05, z + 0.54], 0x26343c);
}
}
}
if (activity.id === 'moon') {
makeBox(group, [7.4, 3.9, 0.22], [0, 3, -3.8], 0xe7d8ac);
makeBox(group, [6.8, 3.3, 0.08], [0, 3, -3.65], color);
for (const x of [-4.5, 4.5]) {
makeBox(group, [0.75, 1.15, 0.75], [x, 1.1, 1.3], 0x30343a);
makeCylinder(group, 0.23, 0.23, 0.45, 8, [x, 0.9, 1.7], 0x242a31, { metalness: 0.2 });
}
for (let row = 0; row < 3; row++) {
for (let seat = 0; seat < 6; seat++) {
makeBox(group, [0.75, 0.18, 0.75], [-3.3 + seat * 1.3, 0.55, -1.2 + row * 1.6], 0x6b596d);
makeBox(group, [0.75, 0.8, 0.16], [-3.3 + seat * 1.3, 0.95, -1.48 + row * 1.6], 0x6b596d);
}
}
}
if (activity.id === 'bazaar') {
for (let i = 0; i < 6; i++) {
const x = -6 + (i % 3) * 6;
const z = i < 3 ? -3.6 : 3.6;
makeBox(group, [4.3, 1.25, 2.1], [x, 1.1, z], i % 2 ? 0xc87959 : 0x6c9b7e);
makeCone(group, 2.65, 1.4, 4, [x, 3.25, z], i % 2 ? color : 0xf0d47a, { side: THREE.DoubleSide });
makeBox(group, [3.4, 0.14, 1.3], [x, 1.82, z], 0xe6cda1);
}
}
const people = [];
for (let i = 0; i < 22; i++) {
const person = makePerson(i % 3 === 0 ? 0xf0b075 : i % 3 === 1 ? 0x69b6bb : 0xd990b0);
const angle = random() * Math.PI * 2;
const radius = 4.2 + random() * 5.3;
person.position.set(Math.cos(angle) * radius, 0.45, Math.sin(angle) * radius);
person.rotation.y = random() * Math.PI * 2;
group.add(person);
people.push(person);
}
group.userData.people = people;
group.position.set(siteById(activity.location).position[0], 0.42, siteById(activity.location).position[1]);
scene.add(shadowify(group));
return group;
}
function syncActivityVisuals() {
for (const activity of activities) {
if (activityGroups[activity.id]) {
scene.remove(activityGroups[activity.id]);
}
activityGroups[activity.id] = buildActivityVisual(activity);
}
}
syncActivityVisuals();
// DOM map labels.
for (const site of sites) {
const label = document.createElement('button');
label.className = 'map-label';
label.addEventListener('click', event => {
event.stopPropagation();
handleSiteClick(site.id);
});
$('#map-labels').appendChild(label);
siteLabels.set(site.id, label);
}
// Custom camera controls: no addons.
const orbit = {
theta: 0.72,
phi: 0.88,
radius: 92,
target: new THREE.Vector3(0, 0, 1)
};
function updateCamera() {
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
orbit.target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
orbit.target.y + orbit.radius * Math.cos(orbit.phi),
orbit.target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(orbit.target);
}
let dragState = null;
canvas.addEventListener('contextmenu', event => event.preventDefault());
canvas.addEventListener('pointerdown', event => {
dragState = {
x: event.clientX,
y: event.clientY,
lastX: event.clientX,
lastY: event.clientY,
distance: 0,
button: event.button
};
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener('pointermove', event => {
if (!dragState) return;
const dx = event.clientX - dragState.lastX;
const dy = event.clientY - dragState.lastY;
dragState.distance += Math.abs(dx) + Math.abs(dy);
dragState.lastX = event.clientX;
dragState.lastY = event.clientY;
if (dragState.button === 2 || event.shiftKey) {
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();
orbit.target.addScaledVector(right, -dx * 0.045);
orbit.target.addScaledVector(forward, dy * 0.045);
} else {
orbit.theta -= dx * 0.006;
orbit.phi = clamp(orbit.phi - dy * 0.005, 0.32, 1.34);
}
});
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
canvas.addEventListener('pointerup', event => {
if (!dragState) return;
const wasClick = dragState.distance < 7 && dragState.button === 0;
dragState = null;
if (canvas.hasPointerCapture(event.pointerId)) canvas.releasePointerCapture(event.pointerId);
if (wasClick) {
const rect = canvas.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 hit = raycaster.intersectObjects(pickables, false)[0];
if (hit) handleSiteClick(hit.object.userData.siteId);
}
});
canvas.addEventListener('pointercancel', () => { dragState = null; });
canvas.addEventListener('wheel', event => {
event.preventDefault();
orbit.radius = clamp(orbit.radius + event.deltaY * 0.055, 42, 135);
}, { passive: false });
function siteById(id) {
return sites.find(site => site.id === id);
}
function activityById(id) {
return activities.find(activity => activity.id === id);
}
function activityAtSite(siteId) {
return activities.find(activity => activity.location === siteId);
}
function formatTime(minutes) {
const total = Math.floor(minutes);
const hour = Math.floor(total / 60) % 24;
const minute = total % 60;
return `${String(hour).padStart(2, '0')}:${String(minute).padStart(2, '0')}`;
}
function getWeatherAt(minutes) {
let result = weatherSchedule[0];
for (const weather of weatherSchedule) {
if (minutes >= weather.minute) result = weather;
}
return result;
}
function isWeatherHold(activity) {
const site = siteById(activity.location);
return currentWeather === 'storm' && site.type !== 'indoor';
}
function priorityFactor(activity) {
return 1 + (4 - activity.priority) * 0.07;
}
function expectedAttendance(activity) {
const effect = weatherEffects[currentWeather];
const site = siteById(activity.location);
const weatherFactor = site.type === 'indoor' ? effect.indoor : effect.outdoor;
return Math.round(activity.baseGuests * priorityFactor(activity) * weatherFactor);
}
function getShortage(activity) {
const shortages = [];
for (const [name, needed] of Object.entries(activity.gear)) {
const usedByOthers = activities
.filter(other => other.id !== activity.id)
.reduce((sum, other) => sum + (other.gear[name] || 0), 0);
const free = Math.max(0, (inventory[name] || 0) - usedByOthers);
if (needed > free) shortages.push({ name, amount: needed - free });
}
return shortages;
}
function getCrewShortage(activity) {
const usedByOthers = activities
.filter(other => other.id !== activity.id)
.reduce((sum, other) => sum + other.crew, 0);
return Math.max(0, activity.crew - (CREW_TOTAL - usedByOthers));
}
function placementProblem(activity, site) {
if (activity.placement === 'indoor' && site.type !== 'indoor') {
return 'This activity requires an indoor venue.';
}
if (activity.placement === 'outdoor' && site.type === 'indoor') {
return 'This activity must remain outdoors.';
}
const missing = activity.features.filter(feature => !site.features.includes(feature));
if (missing.length) return `Missing site feature: ${missing.join(', ')}.`;
return null;
}
function canSwap(activity, targetSite) {
if (!targetSite) return false;
const other = activityAtSite(targetSite.id);
if (!other) return false;
return !placementProblem(activity, targetSite) && !placementProblem(other, siteById(activity.location));
}
function setupBlockReason(activity) {
if (isWeatherHold(activity)) return 'Outdoor safety hold during the storm.';
const shortage = getShortage(activity);
if (shortage.length) {
return shortage.map(item => `${item.name} ×${item.amount} short`).join(', ');
}
const site = siteById(activity.location);
const missing = activity.features.filter(feature => !site.features.includes(feature));
if (missing.length) return `Missing site feature: ${missing.join(', ')}.`;
const crewShortage = getCrewShortage(activity);
if (crewShortage) return `Crew short by ${crewShortage}.`;
return null;
}
function statusFor(activity) {
if (activity.setupIndex < activity.steps.length) {
return { label: `Setup ${activity.setupIndex + 1}/${activity.steps.length}`, className: 'setup' };
}
if (isWeatherHold(activity)) return { label: 'Weather hold', className: 'hold' };
return { label: 'Live', className: 'live' };
}
function issuesFor(activity) {
const issues = [];
if (isWeatherHold(activity)) issues.push('Storm safety hold');
const shortage = getShortage(activity);
if (shortage.length) issues.push(shortage.map(item => `${item.name} ×${item.amount}`).join(', '));
const site = siteById(activity.location);
if (expectedAttendance(activity) > site.capacity) issues.push(`Forecast over ${site.name} capacity`);
return issues;
}
function toast(message, type = '') {
const element = document.createElement('div');
element.className = `toast ${type}`;
element.textContent = message;
$('#toasts').appendChild(element);
setTimeout(() => {
element.style.opacity = '0';
element.style.transform = 'translateY(6px)';
element.style.transition = 'opacity .25s, transform .25s';
setTimeout(() => element.remove(), 260);
}, 3300);
}
function movePriority(activityId, direction) {
const sorted = [...activities].sort((a, b) => a.priority - b.priority);
const index = sorted.findIndex(activity => activity.id === activityId);
const targetIndex = direction === 'up' ? index - 1 : index + 1;
if (targetIndex < 0 || targetIndex >= sorted.length) return;
const current = sorted[index];
const target = sorted[targetIndex];
const priority = current.priority;
current.priority = target.priority;
target.priority = priority;
toast(`${current.name} moved to priority ${current.priority}.`, 'good');
renderUI();
}
function advanceSetup() {
const activity = activityById(selectedId);
if (!activity || activity.setupIndex >= activity.steps.length) return;
const blocked = setupBlockReason(activity);
if (blocked) {
toast(blocked, 'warn');
return;
}
activity.setupIndex++;
if (activity.setupIndex === activity.steps.length) {
toast(`${activity.name} is open. Attendance is building.`, 'good');
} else {
toast(`${activity.name}: ${activity.steps[activity.setupIndex - 1]} complete.`);
}
renderUI();
}
function acquireGear() {
const activity = activityById(selectedId);
const shortage = getShortage(activity);
if (!shortage.length) return;
const cost = shortage.reduce((sum, item) => sum + (gearCosts[item.name] || 100) * item.amount, 0);
if (cost > budget) {
toast(`Not enough budget. This order costs $${cost}.`, 'warn');
return;
}
budget -= cost;
for (const item of shortage) inventory[item.name] += item.amount;
toast(`Acquired ${shortage.map(item => `${item.name} ×${item.amount}`).join(', ')} for $${cost}.`, 'good');
renderUI();
}
function cancelRelocation() {
relocating = false;
$('#relocate-banner').style.display = 'none';
renderUI();
}
function toggleRelocation() {
relocating = !relocating;
if (relocating) {
const activity = activityById(selectedId);
$('#relocate-text').textContent = `Relocate ${activity.name}: choose a highlighted venue.`;
$('#relocate-banner').style.display = 'flex';
} else {
$('#relocate-banner').style.display = 'none';
}
renderUI();
}
function resetSetup(activity) {
activity.setupIndex = 0;
activity.attendance = 0;
}
function handleSiteClick(siteId) {
const site = siteById(siteId);
if (!relocating) {
const activity = activityAtSite(siteId);
if (activity) {
selectedId = activity.id;
renderUI();
} else {
toast(`${site.name} is open: ${site.capacity} guest capacity, ${site.features.join(', ')}.`);
}
return;
}
const activity = activityById(selectedId);
if (activity.location === siteId) {
toast('That is the activity’s current venue.');
return;
}
const occupied = activityAtSite(siteId);
const problem = placementProblem(activity, site);
if (occupied) {
if (!problem && canSwap(activity, site)) {
const sourceSite = siteById(activity.location);
activity.location = siteId;
occupied.location = sourceSite.id;
resetSetup(activity);
resetSetup(occupied);
cancelRelocation();
syncActivityVisuals();
toast(`Swapped ${activity.name} with ${occupied.name}. Both site setups must be reverified.`, 'good');
renderUI();
} else {
toast(problem || `A compatible swap is not possible with ${occupied.name}.`, 'warn');
}
return;
}
if (problem) {
toast(problem, 'warn');
return;
}
activity.location = siteId;
resetSetup(activity);
cancelRelocation();
syncActivityVisuals();
const capacityWarning = expectedAttendance(activity) > site.capacity;
toast(
`${activity.name} moved to ${site.name}. Site setup has been reset.${capacityWarning ? ' Forecast attendance exceeds venue capacity.' : ''}`,
capacityWarning ? 'warn' : 'good'
);
renderUI();
}
function applyWeather(key) {
currentWeather = key;
const effect = weatherEffects[key];
targetSky.setHex(effect.sky);
sunLight.targetIntensity = effect.sun;
ambientLight.targetIntensity = effect.ambient;
rain.visible = key === 'rain' || key === 'storm';
cloudMaterial.opacity = effect.cloud;
}
function renderWeatherCard() {
const weather = getWeatherAt(festivalMinutes);
const upcoming = weatherSchedule
.filter(item => item.minute > festivalMinutes)
.slice(0, 4);
const forecastMarkup = upcoming.length
? upcoming.map(item => `
<div>
<b>${item.icon}</b>
<span>${formatTime(item.minute)} ${item.label}</span>
</div>`).join('')
: '<div><b>—</b><span>Festival complete</span></div>';
$('#weather-card').innerHTML = `
<div class="weather-current">
<div class="weather-icon">${weather.icon}</div>
<div>
<strong>${weather.label}</strong>
<small>${weather.key === 'storm' ? 'Outdoor activities suspended' : 'Forecast adjusts outdoor attendance'}</small>
</div>
</div>
<div class="forecast">${forecastMarkup}</div>
`;
}
function renderActivityList() {
const sorted = [...activities].sort((a, b) => a.priority - b.priority);
$('#activity-list').innerHTML = sorted.map(activity => {
const site = siteById(activity.location);
const status = statusFor(activity);
const issues = issuesFor(activity);
const barWidth = clamp((activity.attendance / site.capacity) * 100, 0, 100);
const color = `#${activity.color.toString(16).padStart(6, '0')}`;
return `
<article class="event-card ${activity.id === selectedId ? 'selected' : ''}" data-select="${activity.id}">
<div class="event-top">
<div class="priority-box">${activity.priority}</div>
<div class="event-info">
<div class="event-name-row">
<span class="event-name">${activity.name}</span>
<span class="status ${status.className}">${status.label}</span>
</div>
<div class="event-location">${site.name} · cap ${site.capacity}</div>
<div class="mini-bar"><span style="width:${barWidth}%; background:${color}"></span></div>
<div class="event-footer">
<span>${Math.round(activity.attendance)} here · ${expectedAttendance(activity)} forecast</span>
<span>${Math.round(barWidth)}%</span>
</div>
${issues.length ? `<div class="issue-chip">! ${issues[0]}</div>` : ''}
</div>
<div class="priority-actions">
<button data-priority="up" data-id="${activity.id}" title="Raise priority">↑</button>
<button data-priority="down" data-id="${activity.id}" title="Lower priority">↓</button>
</div>
</div>
</article>
`;
}).join('');
}
function renderInspector() {
const activity = activityById(selectedId);
const site = siteById(activity.location);
const status = statusFor(activity);
const shortage = getShortage(activity);
const shortageCost = shortage.reduce((sum, item) => sum + gearCosts[item.name] * item.amount, 0);
const block = setupBlockReason(activity);
const color = `#${activity.color.toString(16).padStart(6, '0')}`;
const usedByOthers = name => activities
.filter(other => other.id !== activity.id)
.reduce((sum, other) => sum + (other.gear[name] || 0), 0);
const gearRows = Object.entries(activity.gear).map(([name, needed]) => {
const free = Math.max(0, inventory[name] - usedByOthers(name));
const enough = needed <= free;
return `
<div class="gear-row">
<span class="gear-name">${name}</span>
<span class="gear-qty ${enough ? 'ok' : 'short'}">
${enough ? '✓' : '!'} need ${needed} · ${free} free
</span>
</div>
`;
}).join('');
const crewUsedByOthers = activities
.filter(other => other.id !== activity.id)
.reduce((sum, other) => sum + other.crew, 0);
const crewFree = CREW_TOTAL - crewUsedByOthers;
const crewOkay = activity.crew <= crewFree;
const featureRows = activity.features.map(feature => {
const available = site.features.includes(feature);
return `
<div class="dependency ${available ? 'ok' : 'bad'}">
<i>${available ? '✓' : '!'}</i>
<span>${feature} at ${site.name}</span>
</div>
`;
}).join('');
const steps = activity.steps.map((step, index) => {
const state = index < activity.setupIndex ? 'done' : index === activity.setupIndex ? 'current' : '';
const label = index < activity.setupIndex ? 'Complete' : index === activity.setupIndex ? 'Next dependency' : 'Waiting';
return `
<div class="setup-step ${state}">
<b>${index < activity.setupIndex ? '✓' : index + 1}</b>
<strong>${step}</strong>
<small>${label}</small>
</div>
`;
}).join('');
const placementLabel = activity.placement === 'indoor'
? 'Indoor venue required'
: activity.placement === 'outdoor'
? 'Outdoor venue required'
: 'Indoor or outdoor venue';
const currentStep = activity.setupIndex < activity.steps.length
? activity.steps[activity.setupIndex]
: null;
$('#inspector').innerHTML = `
<div class="activity-hero">
<div class="eyebrow">Priority ${activity.priority} · ${status.label}</div>
<h3 style="color:${color}">${activity.name}</h3>
<p>${activity.description}</p>
</div>
<section class="inspector-section">
<div class="section-title">Priority <span>Higher priority increases forecast demand</span></div>
<div class="priority-control">
<button data-action="priority-up" title="Raise priority">↑</button>
<div class="rank">Priority ${activity.priority} of 4</div>
<button data-action="priority-down" title="Lower priority">↓</button>
</div>
</section>
<section class="inspector-section">
<div class="section-title">Venue capacity <span>${site.name} · ${site.type}</span></div>
<div class="capacity-card">
<div class="capacity-line">
<strong>${Math.round(activity.attendance)}</strong>
<span>of ${site.capacity} guests</span>
</div>
<div class="capacity-track">
<span style="width:${clamp(activity.attendance / site.capacity * 100, 0, 100)}%; background:${color}"></span>
</div>
<div class="capacity-note">
<span>Forecast ${expectedAttendance(activity)}</span>
<span>${expectedAttendance(activity) > site.capacity ? 'Capacity warning' : 'Within capacity'}</span>
</div>
</div>
</section>
<section class="inspector-section">
<div class="section-title">Required equipment <span>Reserved against festival stock</span></div>
${gearRows}
${shortage.length ? `
<button class="warning-btn" data-action="acquire" style="width:100%;margin-top:9px">
Acquire missing gear · $${shortageCost}
</button>
` : ''}
</section>
<section class="inspector-section">
<div class="section-title">Placement dependencies</div>
<div class="dependency-list">
<div class="dependency ${placementProblem(activity, site) ? 'bad' : 'ok'}">
<i>${placementProblem(activity, site) ? '!' : '✓'}</i>
<span>${placementLabel}</span>
</div>
${featureRows}
<div class="dependency ${crewOkay ? 'ok' : 'bad'}">
<i>${crewOkay ? '✓' : '!'}</i>
<span>${activity.crewRole}: ${activity.crew} of ${crewFree} unassigned crew available</span>
</div>
</div>
</section>
<section class="inspector-section">
<div class="section-title">Setup dependency chain <span>Must be completed in order</span></div>
<div class="setup-chain">${steps}</div>
</section>
<div class="action-stack">
<button class="primary-btn" data-action="advance" ${!currentStep || block ? 'disabled' : ''}>
${currentStep ? `Complete: ${currentStep}` : 'Doors are open'}
</button>
${block && currentStep ? `<div class="fine-print" style="color:var(--orange)">Blocked: ${block}</div>` : ''}
<button class="secondary-btn" data-action="relocate">
${relocating ? 'Cancel relocation' : 'Relocate activity'}
</button>
<div class="fine-print">Relocation resets all completed setup steps and attendance for the moved activity. Some occupied venues permit a compatible swap.</div>
</div>
`;
$('#selected-pill').textContent = relocating ? 'Choose a venue' : status.label;
}
function renderTop() {
const weather = getWeatherAt(festivalMinutes);
const attendance = Math.round(activities.reduce((sum, activity) => sum + activity.attendance, 0));
const totalCapacity = sites.reduce((sum, site) => sum + site.capacity, 0);
const live = activities.filter(activity => activity.setupIndex >= activity.steps.length).length;
let gearReady = 0;
let gearTotal = 0;
for (const activity of activities) {
for (const [name, needed] of Object.entries(activity.gear)) {
gearTotal++;
const usedByOthers = activities
.filter(other => other.id !== activity.id)
.reduce((sum, other) => sum + (other.gear[name] || 0), 0);
if ((inventory[name] || 0) - usedByOthers >= needed) gearReady++;
}
}
const mood = activities.reduce((sum, activity) => {
const setup = activity.setupIndex / activity.steps.length * 55;
const capacity = expectedAttendance(activity) <= siteById(activity.location).capacity ? 25 : 8;
const weather = isWeatherHold(activity) ? 0 : 20;
return sum + setup + capacity + weather;
}, 0) / activities.length;
$('#clock').textContent = formatTime(festivalMinutes);
$('#weather-top').textContent = `${weather.icon} ${weather.label}`;
$('#attendance-stat').textContent = `${attendance} / ${totalCapacity}`;
$('#setup-stat').textContent = `${live} / ${activities.length}`;
$('#mood-value').textContent = `${Math.round(mood)}%`;
$('#budget-pill').textContent = `$${budget.toLocaleString()}`;
$('#pause-btn').textContent = paused ? 'Resume' : 'Pause';
$('#speed-btn').textContent = `${speed}×`;
}
function updateLabelContent() {
for (const site of sites) {
const label = siteLabels.get(site.id);
const activity = activityAtSite(site.id);
const color = activity ? `#${activity.color.toString(16).padStart(6, '0')}` : '#83918e';
const status = activity ? statusFor(activity).label : 'Open venue';
label.innerHTML = `
<strong><span class="label-dot" style="background:${color}"></span>${activity ? activity.name : site.name}</strong>
<small>${activity ? `${site.name} · ${status}` : `${site.name} · cap ${site.capacity}`}</small>
`;
label.classList.remove('valid', 'invalid');
if (relocating) {
const activityToMove = activityById(selectedId);
const occupied = activityAtSite(site.id);
let valid = false;
if (activityToMove.location !== site.id) {
if (occupied) {
valid = canSwap(activityToMove, site);
} else {
valid = !placementProblem(activityToMove, site);
}
}
label.classList.add(valid ? 'valid' : 'invalid');
}
}
}
function renderUI() {
renderTop();
renderWeatherCard();
renderActivityList();
renderInspector();
updateLabelContent();
}
$('#activity-list').addEventListener('click', event => {
const priorityButton = event.target.closest('[data-priority]');
if (priorityButton) {
event.stopPropagation();
movePriority(priorityButton.dataset.id, priorityButton.dataset.priority);
return;
}
const card = event.target.closest('[data-select]');
if (card) {
selectedId = card.dataset.select;
renderUI();
}
});
$('#inspector').addEventListener('click', event => {
const button = event.target.closest('[data-action]');
if (!button) return;
const action = button.dataset.action;
if (action === 'advance') advanceSetup();
if (action === 'acquire') acquireGear();
if (action === 'relocate') toggleRelocation();
if (action === 'priority-up') movePriority(selectedId, 'up');
if (action === 'priority-down') movePriority(selectedId, 'down');
});
$('#pause-btn').addEventListener('click', () => {
paused = !paused;
renderUI();
});
$('#speed-btn').addEventListener('click', () => {
speed = speed === 1 ? 2 : 1;
renderUI();
});
$('#ff-btn').addEventListener('click', () => {
festivalMinutes = Math.min(1380, festivalMinutes + 30);
const weather = getWeatherAt(festivalMinutes);
if (weather.key !== currentWeather) applyWeather(weather.key);
toast(`Festival advanced to ${formatTime(festivalMinutes)}.`, 'good');
renderUI();
});
$('#cancel-relocate').addEventListener('click', cancelRelocation);
function resetGame() {
festivalMinutes = 660;
paused = false;
speed = 1;
budget = 1800;
selectedId = 'aurora';
relocating = false;
ended = false;
currentWeather = 'sunny';
inventory = {
'PA rack': 2,
'Stage deck': 2,
'Work table': 8,
'Handheld console': 5,
'Projector': 1,
'Screen': 1,
'Market stall': 8,
'Canopy': 3
};
activityTemplates.forEach((template, index) => {
const activity = activities[index];
activity.priority = template.priority;
activity.location = template.location;
activity.setupIndex = index === 0 || index === 3 ? 3 : index === 1 ? 2 : 1;
activity.attendance = 0;
});
$('#relocate-banner').style.display = 'none';
applyWeather('sunny');
syncActivityVisuals();
renderUI();
toast('Festival reset. The first storm is forecast for 15:00.', 'good');
}
$('#reset-btn').addEventListener('click', resetGame);
// Update attendance and scene.
function updateAttendance(dt) {
for (const activity of activities) {
const open = activity.setupIndex >= activity.steps.length;
const target = open && !isWeatherHold(activity) ? expectedAttendance(activity) : 0;
const ease = 1 - Math.exp(-dt * 0.62);
activity.attendance = lerp(activity.attendance, target, ease);
}
}
function updateCrowds() {
for (const activity of activities) {
const group = activityGroups[activity.id];
if (!group) continue;
const visiblePeople = clamp(Math.round(activity.attendance / 6), 0, 22);
group.userData.people.forEach((person, index) => {
person.visible = index < visiblePeople;
});
}
}
function updateRain(dt) {
if (!rain.visible) return;
const positions = rainGeometry.attributes.position.array;
for (let i = 0; i < rainCount; i++) {
const offset = i * 6;
positions[offset + 1] -= dt * 26;
positions[offset + 4] -= dt * 26;
if (positions[offset + 1] < 0) {
const y = 34 + Math.random() * 5;
positions[offset + 1] = y;
positions[offset + 4] = y - 1.25;
}
}
rainGeometry.attributes.position.needsUpdate = true;
}
let lightningTimer = 0;
let lightningFlash = 0;
function updateAtmosphere(dt) {
scene.background.lerp(targetSky, 1 - Math.exp(-dt * 1.4));
scene.fog.color.copy(scene.background);
sunLight.intensity = lerp(sunLight.intensity, sunLight.targetIntensity, 1 - Math.exp(-dt * 1.6));
ambientLight.intensity = lerp(ambientLight.intensity, ambientLight.targetIntensity, 1 - Math.exp(-dt * 1.6));
cloudGroups.forEach((cloud, index) => {
cloud.position.x += dt * (0.18 + index * 0.015);
if (cloud.position.x > 72) cloud.position.x = -72;
});
updateRain(dt);
if (currentWeather === 'storm') {
lightningTimer -= dt;
lightningFlash = Math.max(0, lightningFlash - dt * 3.4);
if (lightningTimer <= 0) {
lightningTimer = 4 + Math.random() * 8;
lightningFlash = 1;
}
sunLight.intensity += lightningFlash * 4.5;
} else {
lightningFlash = 0;
}
}
const projected = new THREE.Vector3();
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const site of sites) {
const label = siteLabels.get(site.id);
projected.set(site.position[0], 11.7, site.position[1]).project(camera);
const visible = projected.z > -1 && projected.z < 1;
label.style.display = visible ? 'block' : 'none';
if (!visible) continue;
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
label.style.transform = `translate(${x}px, ${y}px) translate(-50%, -100%)`;
}
}
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
const clock = new THREE.Clock();
let uiTimer = 0;
let previousWeather = 'sunny';
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
if (!paused && !ended) {
festivalMinutes += dt * speed;
if (festivalMinutes >= 1380) {
festivalMinutes = 1380;
ended = true;
paused = true;
toast('23:00 — the festival is complete. Review the final run of show.', 'good');
}
}
const weather = getWeatherAt(festivalMinutes);
if (weather.key !== currentWeather) {
applyWeather(weather.key);
if (weather.key === 'storm') {
toast('Storm front arrived. Outdoor activities are on safety hold.', 'warn');
} else {
toast(`Weather changed: ${weather.label}.`, 'good');
}
}
updateAttendance(dt);
updateCrowds();
updateAtmosphere(dt);
updateCamera();
updateLabels();
uiTimer += dt;
if (uiTimer > 0.25) {
uiTimer = 0;
renderUI();
}
renderer.render(scene, camera);
}
resetGame();
animate();
</script>
</body>
</html>
```