Prompt specification
Build or customize the Three.js 3D scene "Moving the Bottleneck" 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: Moving the Bottleneck
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/moving-the-bottleneck-x3184
Scene Description Prompt:
Upgrade voxel production stations individually and let their actual processing times determine the next bottleneck. Build one HTML scene with Three.js from cdnjs.
Working Three.js Starter (moving-the-bottleneck-x3184):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Flow — Production Optimizer</title>
<style>
:root {
--bg: #07111d;
--panel: rgba(9, 20, 33, 0.86);
--panel-solid: #0b1928;
--line: rgba(139, 190, 215, 0.16);
--text: #eaf7ff;
--muted: #8299ab;
--cyan: #55e6c1;
--blue: #66a8ff;
--orange: #ffb454;
--purple: #c68cff;
--pink: #ff6f91;
}
* {
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;
}
body {
user-select: none;
}
#viewport {
position: fixed;
inset: 0;
}
#viewport canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.topbar {
position: absolute;
top: 18px;
left: 18px;
right: 18px;
height: 64px;
display: flex;
align-items: center;
gap: 14px;
padding: 0 16px;
border: 1px solid var(--line);
border-radius: 14px;
background: rgba(8, 18, 30, 0.88);
backdrop-filter: blur(18px);
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
pointer-events: auto;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
min-width: 245px;
}
.brand-mark {
position: relative;
width: 35px;
height: 35px;
transform: rotate(45deg);
border: 2px solid var(--cyan);
box-shadow:
inset 0 0 14px rgba(85, 230, 193, 0.2),
0 0 18px rgba(85, 230, 193, 0.12);
}
.brand-mark::after {
content: "";
position: absolute;
inset: 8px;
background: var(--cyan);
}
.brand h1 {
margin: 0;
font-size: 17px;
line-height: 1;
letter-spacing: 0.13em;
}
.brand p {
margin: 5px 0 0;
color: var(--muted);
font-size: 10px;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.top-spacer {
flex: 1;
}
.metric {
min-width: 105px;
padding: 0 15px;
border-left: 1px solid var(--line);
}
.metric-label {
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.metric-value {
margin-top: 4px;
font-size: 17px;
font-weight: 750;
font-variant-numeric: tabular-nums;
}
.credits-value {
color: var(--orange);
}
.control-button {
height: 38px;
min-width: 72px;
padding: 0 13px;
border: 1px solid var(--line);
border-radius: 9px;
color: var(--text);
background: rgba(255, 255, 255, 0.045);
font: inherit;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.08em;
cursor: pointer;
transition:
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
.control-button:hover {
border-color: rgba(85, 230, 193, 0.5);
background: rgba(85, 230, 193, 0.08);
}
.control-button:active {
transform: translateY(1px);
}
.live-dot {
display: inline-block;
width: 7px;
height: 7px;
margin-right: 8px;
border-radius: 50%;
background: var(--cyan);
box-shadow: 0 0 10px var(--cyan);
animation: pulse 1.8s infinite;
}
@keyframes pulse {
50% {
opacity: 0.45;
}
}
.panel {
position: absolute;
top: 96px;
width: 302px;
max-height: calc(100vh - 130px);
overflow: hidden auto;
border: 1px solid var(--line);
border-radius: 14px;
background: var(--panel);
backdrop-filter: blur(18px);
box-shadow: 0 18px 45px rgba(0, 0, 0, 0.24);
pointer-events: auto;
scrollbar-width: thin;
scrollbar-color: #294255 transparent;
}
.left-panel {
left: 18px;
}
.right-panel {
right: 18px;
}
.panel-header {
padding: 17px 17px 14px;
border-bottom: 1px solid var(--line);
}
.eyebrow {
color: var(--cyan);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.panel-header h2 {
margin: 5px 0 0;
font-size: 17px;
letter-spacing: -0.02em;
}
.panel-header p {
margin: 7px 0 0;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
.station-list {
padding: 9px;
}
.station-card {
position: relative;
margin-bottom: 7px;
padding: 12px;
overflow: hidden;
border: 1px solid transparent;
border-radius: 10px;
background: rgba(255, 255, 255, 0.028);
cursor: pointer;
transition:
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
.station-card:hover {
background: rgba(255, 255, 255, 0.052);
transform: translateX(2px);
}
.station-card.selected {
border-color: rgba(85, 230, 193, 0.46);
background: rgba(85, 230, 193, 0.06);
}
.station-card::before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 3px;
background: var(--station-color);
box-shadow: 0 0 15px var(--station-color);
}
.station-top {
display: flex;
align-items: center;
gap: 10px;
}
.station-code {
display: grid;
width: 34px;
height: 34px;
flex: 0 0 auto;
place-items: center;
border: 1px solid color-mix(in srgb, var(--station-color) 45%, transparent);
border-radius: 8px;
color: var(--station-color);
background: color-mix(in srgb, var(--station-color) 9%, transparent);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.05em;
}
.station-name {
flex: 1;
min-width: 0;
}
.station-name strong {
display: block;
overflow: hidden;
font-size: 12px;
text-overflow: ellipsis;
white-space: nowrap;
}
.station-name span {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 9px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.station-time {
text-align: right;
font-size: 15px;
font-weight: 750;
font-variant-numeric: tabular-nums;
}
.station-time small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 8px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.station-bottom {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-top: 10px;
}
.level-dots {
display: flex;
align-items: center;
gap: 3px;
}
.level-dot {
width: 6px;
height: 6px;
border-radius: 2px;
background: rgba(255, 255, 255, 0.12);
}
.level-dot.on {
background: var(--station-color);
box-shadow: 0 0 7px color-mix(in srgb, var(--station-color) 65%, transparent);
}
.queue-label {
margin-left: 7px;
color: var(--muted);
font-size: 9px;
font-variant-numeric: tabular-nums;
}
.upgrade-mini {
min-width: 76px;
padding: 7px 9px;
border: 1px solid rgba(255, 180, 84, 0.28);
border-radius: 7px;
color: var(--orange);
background: rgba(255, 180, 84, 0.08);
font: inherit;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.04em;
cursor: pointer;
}
.upgrade-mini:hover:not(:disabled) {
background: rgba(255, 180, 84, 0.15);
}
button:disabled {
cursor: not-allowed;
filter: saturate(0.45);
opacity: 0.42;
}
.bottleneck-card {
margin: 12px;
padding: 14px;
border: 1px solid rgba(255, 180, 84, 0.24);
border-radius: 10px;
background:
linear-gradient(135deg, rgba(255, 180, 84, 0.11), transparent),
rgba(255, 255, 255, 0.025);
}
.bottleneck-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
.bottleneck-top strong {
font-size: 14px;
}
.bottleneck-time {
color: var(--orange);
font-size: 19px;
font-weight: 800;
font-variant-numeric: tabular-nums;
}
.bottleneck-card p {
margin: 7px 0 0;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.ranking {
padding: 0 12px 12px;
}
.ranking-row {
display: grid;
grid-template-columns: 24px 1fr 46px;
align-items: center;
gap: 7px;
margin: 8px 0;
color: var(--muted);
font-size: 9px;
}
.ranking-track {
height: 5px;
overflow: hidden;
border-radius: 5px;
background: rgba(255, 255, 255, 0.07);
}
.ranking-fill {
height: 100%;
border-radius: inherit;
box-shadow: 0 0 8px currentColor;
}
.ranking-time {
color: var(--text);
text-align: right;
font-variant-numeric: tabular-nums;
}
.inspector {
padding: 15px;
}
.selected-heading {
display: flex;
align-items: center;
gap: 11px;
}
.selected-icon {
display: grid;
width: 42px;
height: 42px;
flex: 0 0 auto;
place-items: center;
border-radius: 10px;
color: var(--selected-color);
background: color-mix(in srgb, var(--selected-color) 12%, transparent);
font-size: 11px;
font-weight: 900;
}
.selected-heading h3 {
margin: 0;
font-size: 16px;
}
.selected-heading p {
margin: 4px 0 0;
color: var(--muted);
font-size: 10px;
}
.inspector-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin: 14px 0;
}
.inspector-stat {
padding: 10px;
border: 1px solid var(--line);
border-radius: 8px;
background: rgba(255, 255, 255, 0.025);
}
.inspector-stat span {
display: block;
color: var(--muted);
font-size: 8px;
font-weight: 750;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.inspector-stat strong {
display: block;
margin-top: 5px;
font-size: 16px;
font-variant-numeric: tabular-nums;
}
.main-upgrade {
width: 100%;
min-height: 43px;
border: 1px solid rgba(255, 180, 84, 0.4);
border-radius: 9px;
color: #ffe0ad;
background: linear-gradient(135deg, rgba(255, 180, 84, 0.2), rgba(255, 180, 84, 0.08));
font: inherit;
font-size: 11px;
font-weight: 850;
letter-spacing: 0.05em;
cursor: pointer;
}
.main-upgrade:hover:not(:disabled) {
background: linear-gradient(135deg, rgba(255, 180, 84, 0.3), rgba(255, 180, 84, 0.13));
}
.upgrade-detail {
margin: 8px 0 0;
color: var(--muted);
font-size: 9px;
line-height: 1.45;
text-align: center;
}
.divider {
height: 1px;
margin: 15px 0;
background: var(--line);
}
.help {
padding: 0 15px 16px;
color: var(--muted);
font-size: 10px;
line-height: 1.55;
}
.help strong {
color: #c6d8e5;
}
.bottom-hint {
position: absolute;
bottom: 18px;
left: 50%;
display: flex;
align-items: center;
gap: 12px;
padding: 9px 13px;
transform: translateX(-50%);
border: 1px solid var(--line);
border-radius: 9px;
color: var(--muted);
background: rgba(7, 17, 29, 0.78);
backdrop-filter: blur(12px);
font-size: 9px;
letter-spacing: 0.04em;
white-space: nowrap;
}
.key {
padding: 3px 6px;
border: 1px solid rgba(255, 255, 255, 0.14);
border-radius: 4px;
color: #c9d9e5;
background: rgba(255, 255, 255, 0.05);
font-size: 8px;
font-weight: 800;
}
.toast {
position: absolute;
top: 92px;
left: 50%;
max-width: 360px;
padding: 12px 17px;
transform: translate(-50%, -12px);
border: 1px solid rgba(85, 230, 193, 0.35);
border-radius: 9px;
color: #dffff6;
background: rgba(13, 43, 43, 0.92);
box-shadow: 0 12px 35px rgba(0, 0, 0, 0.3);
font-size: 11px;
opacity: 0;
transition:
opacity 180ms ease,
transform 180ms ease;
pointer-events: none;
}
.toast.show {
transform: translate(-50%, 0);
opacity: 1;
}
.loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
color: var(--cyan);
background: var(--bg);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 400ms ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 1050px) {
.panel {
width: 260px;
}
.brand {
min-width: 210px;
}
.metric {
min-width: 85px;
padding: 0 10px;
}
}
@media (max-width: 780px) {
.topbar {
height: 58px;
}
.brand p,
.rate-metric,
.bottom-hint {
display: none;
}
.brand {
min-width: 0;
}
.brand h1 {
font-size: 13px;
}
.metric {
min-width: 70px;
padding: 0 8px;
}
.metric-value {
font-size: 14px;
}
.panel {
top: 87px;
max-height: calc(100vh - 105px);
}
.left-panel {
left: 10px;
width: 235px;
}
.right-panel {
right: 10px;
width: 225px;
}
.panel-header p,
.help {
display: none;
}
.control-button {
min-width: 56px;
padding: 0 8px;
font-size: 9px;
}
}
@media (max-width: 560px) {
.right-panel {
display: none;
}
.left-panel {
right: 10px;
width: auto;
}
.brand-mark {
display: none;
}
.credits-metric {
display: none;
}
}
</style>
</head>
<body>
<div id="viewport"></div>
<div class="hud">
<header class="topbar">
<div class="brand">
<div class="brand-mark"></div>
<div>
<h1>VOXEL FLOW</h1>
<p>Production intelligence</p>
</div>
</div>
<div class="metric credits-metric">
<div class="metric-label">Credits</div>
<div class="metric-value credits-value" id="creditsValue">600</div>
</div>
<div class="metric rate-metric">
<div class="metric-label">Output / min</div>
<div class="metric-value" id="rateValue">0</div>
</div>
<div class="top-spacer"></div>
<button class="control-button" id="pauseBtn" type="button">
<span class="live-dot"></span>PAUSE
</button>
<button class="control-button" id="speedBtn" type="button">1× SPEED</button>
</header>
<aside class="panel left-panel">
<div class="panel-header">
<div class="eyebrow">Production chain</div>
<h2>Stations</h2>
<p>Select a machine, then improve its individual processing cycle.</p>
</div>
<div class="station-list" id="stationList"></div>
</aside>
<aside class="panel right-panel">
<div class="panel-header">
<div class="eyebrow">Live analysis</div>
<h2>Line intelligence</h2>
<p>The bottleneck is recalculated from current machine cycle times.</p>
</div>
<div class="bottleneck-card">
<div class="bottleneck-top">
<strong id="bottleneckName">Loading…</strong>
<div class="bottleneck-time" id="bottleneckTime">—</div>
</div>
<p id="bottleneckNote">Waiting for station data.</p>
</div>
<div class="ranking" id="ranking"></div>
<div class="divider"></div>
<div class="inspector">
<div class="selected-heading" id="selectedHeading">
<div class="selected-icon" id="selectedCode">—</div>
<div>
<h3 id="selectedName">Select a station</h3>
<p id="selectedRole">Click a machine in the factory</p>
</div>
</div>
<div class="inspector-grid">
<div class="inspector-stat">
<span>Level</span>
<strong id="selectedLevel">—</strong>
</div>
<div class="inspector-stat">
<span>Cycle time</span>
<strong id="selectedTime">—</strong>
</div>
<div class="inspector-stat">
<span>Waiting queue</span>
<strong id="selectedQueue">—</strong>
</div>
<div class="inspector-stat">
<span>Projected max</span>
<strong id="selectedProjected">—</strong>
</div>
</div>
<button class="main-upgrade" id="selectedUpgrade" type="button">
SELECT A STATION
</button>
<p class="upgrade-detail" id="upgradeDetail">
Each upgrade reduces that station's processing time by 18%.
</p>
</div>
<div class="help">
<strong>Controls:</strong> drag to orbit, right-drag or Shift-drag to pan,
scroll to zoom, and click a machine to inspect it.
</div>
</aside>
<div class="bottom-hint">
<span class="key">DRAG</span> ORBIT
<span class="key">SHIFT + DRAG</span> PAN
<span class="key">SCROLL</span> ZOOM
<span class="key">CLICK</span> SELECT
</div>
<div class="toast" id="toast"></div>
</div>
<div class="loading" id="loading">Booting voxel factory</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Application state
// -------------------------------------------------------------------------
const stationDefinitions = [
{
code: "EX",
name: "Ore Extractor",
role: "Raw voxel extraction",
baseMs: 1250,
color: 0x55e6c1,
x: -10
},
{
code: "RF",
name: "Voxel Refinery",
role: "Material purification",
baseMs: 1600,
color: 0xffb454,
x: -5
},
{
code: "MF",
name: "Micro Fabricator",
role: "Precision shaping",
baseMs: 1100,
color: 0x66a8ff,
x: 0
},
{
code: "CA",
name: "Core Assembler",
role: "Component assembly",
baseMs: 1850,
color: 0xc68cff,
x: 5
},
{
code: "PK",
name: "Cargo Packer",
role: "Final shipment packing",
baseMs: 1300,
color: 0xff6f91,
x: 10
}
];
const state = {
credits: 600,
elapsed: 0,
paused: false,
speed: 1,
selected: 3,
shipments: [],
transits: [],
toastTimer: null
};
const stations = stationDefinitions.map((definition, index) => ({
...definition,
index,
level: 1,
timeMs: definition.baseMs,
activeDuration: definition.baseMs,
remaining: 0,
processing: false,
queue: 0,
flash: 0,
measuredMs: 0
}));
const MAX_LEVEL = 8;
const PROCESSING_REDUCTION = 0.82;
const SHIPMENT_VALUE = 30;
const viewport = document.getElementById("viewport");
const loading = document.getElementById("loading");
const creditsValue = document.getElementById("creditsValue");
const rateValue = document.getElementById("rateValue");
const pauseBtn = document.getElementById("pauseBtn");
const speedBtn = document.getElementById("speedBtn");
const stationList = document.getElementById("stationList");
const bottleneckName = document.getElementById("bottleneckName");
const bottleneckTime = document.getElementById("bottleneckTime");
const bottleneckNote = document.getElementById("bottleneckNote");
const ranking = document.getElementById("ranking");
const selectedHeading = document.getElementById("selectedHeading");
const selectedCode = document.getElementById("selectedCode");
const selectedName = document.getElementById("selectedName");
const selectedRole = document.getElementById("selectedRole");
const selectedLevel = document.getElementById("selectedLevel");
const selectedTime = document.getElementById("selectedTime");
const selectedQueue = document.getElementById("selectedQueue");
const selectedProjected = document.getElementById("selectedProjected");
const selectedUpgrade = document.getElementById("selectedUpgrade");
const upgradeDetail = document.getElementById("upgradeDetail");
const toast = document.getElementById("toast");
// -------------------------------------------------------------------------
// Three.js scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07111d);
scene.fog = new THREE.Fog(0x07111d, 25, 62);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
120
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel production factory"
);
viewport.appendChild(renderer.domElement);
const ambient = new THREE.HemisphereLight(0xb9e8ff, 0x0b1522, 2.1);
scene.add(ambient);
const sun = new THREE.DirectionalLight(0xffffff, 3.2);
sun.position.set(8, 20, 13);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -24;
sun.shadow.camera.right = 24;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.bias = -0.0002;
scene.add(sun);
const cyanLight = new THREE.PointLight(0x55e6c1, 24, 28, 2);
cyanLight.position.set(-11, 6, 5);
scene.add(cyanLight);
const purpleLight = new THREE.PointLight(0xc68cff, 22, 26, 2);
purpleLight.position.set(10, 5, -4);
scene.add(purpleLight);
const floorMaterial = new THREE.MeshStandardMaterial({
color: 0x0a1723,
roughness: 0.92,
metalness: 0.12
});
const floor = new THREE.Mesh(
new THREE.BoxGeometry(62, 0.5, 42),
floorMaterial
);
floor.position.y = -0.38;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(60, 60, 0x24495a, 0x112d3b);
grid.position.y = -0.115;
grid.material.transparent = true;
grid.material.opacity = 0.48;
scene.add(grid);
const platform = new THREE.Mesh(
new THREE.BoxGeometry(30, 0.22, 7.6),
new THREE.MeshStandardMaterial({
color: 0x101f2d,
roughness: 0.68,
metalness: 0.5
})
);
platform.position.set(0, 0.02, 0);
platform.receiveShadow = true;
scene.add(platform);
const beltMaterial = new THREE.MeshStandardMaterial({
color: 0x0d1720,
roughness: 0.6,
metalness: 0.72
});
const railMaterial = new THREE.MeshStandardMaterial({
color: 0x395263,
roughness: 0.35,
metalness: 0.82
});
const rollerMaterial = new THREE.MeshStandardMaterial({
color: 0x172a38,
roughness: 0.42,
metalness: 0.78
});
const warningMaterial = new THREE.MeshStandardMaterial({
color: 0xd6a843,
emissive: 0x503a08,
emissiveIntensity: 0.25,
roughness: 0.65
});
function makeBox(width, height, depth, material, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function createBelt(startX, endX) {
const length = endX - startX;
const centerX = (startX + endX) * 0.5;
makeBox(length, 0.25, 2.15, beltMaterial, centerX, 0.48, 0);
makeBox(length, 0.14, 0.13, railMaterial, centerX, 0.68, -1.05);
makeBox(length, 0.14, 0.13, railMaterial, centerX, 0.68, 1.05);
const rollerCount = Math.max(2, Math.floor(length / 0.42));
for (let i = 0; i < rollerCount; i++) {
const x = startX + ((i + 0.5) / rollerCount) * length;
makeBox(0.12, 0.16, 1.8, rollerMaterial, x, 0.63, 0);
}
}
function createLabelTexture(title, code, color) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const context = canvas.getContext("2d");
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(4.35, 1.09, 1);
sprite.renderOrder = 20;
return { canvas, context, texture, sprite, title, code, color };
}
function drawStationLabel(station) {
const label = station.label;
const ctx = label.context;
const cssColor = `#${station.color.toString(16).padStart(6, "0")}`;
ctx.clearRect(0, 0, label.canvas.width, label.canvas.height);
ctx.fillStyle = "rgba(7, 17, 29, 0.90)";
ctx.fillRect(0, 0, 512, 128);
ctx.fillStyle = cssColor;
ctx.fillRect(0, 0, 8, 128);
ctx.strokeStyle = "rgba(145, 195, 220, 0.35)";
ctx.lineWidth = 3;
ctx.strokeRect(2, 2, 508, 124);
ctx.font = "800 24px system-ui, sans-serif";
ctx.fillStyle = "#edf8ff";
ctx.fillText(label.title.toUpperCase(), 27, 43);
ctx.font = "700 18px system-ui, sans-serif";
ctx.fillStyle = cssColor;
ctx.fillText(label.code, 27, 78);
ctx.font = "600 17px system-ui, sans-serif";
ctx.fillStyle = "#9db1c1";
ctx.textAlign = "right";
ctx.fillText(formatMs(effectiveTime(station)), 482, 43);
ctx.font = "600 15px system-ui, sans-serif";
ctx.fillText(`LV ${station.level} • Q ${station.queue}`, 482, 78);
ctx.textAlign = "left";
label.texture.needsUpdate = true;
}
const pickables = [];
function createStation(station) {
const group = new THREE.Group();
group.position.x = station.x;
scene.add(group);
station.group = group;
const baseMaterial = new THREE.MeshStandardMaterial({
color: 0x101d29,
roughness: 0.55,
metalness: 0.65
});
const bodyMaterial = new THREE.MeshStandardMaterial({
color: 0x172a39,
roughness: 0.47,
metalness: 0.58,
emissive: station.color,
emissiveIntensity: 0
});
const accentMaterial = new THREE.MeshStandardMaterial({
color: station.color,
emissive: station.color,
emissiveIntensity: 0.2,
roughness: 0.35,
metalness: 0.48
});
const darkMaterial = new THREE.MeshStandardMaterial({
color: 0x071018,
roughness: 0.42,
metalness: 0.75
});
station.bodyMaterial = bodyMaterial;
station.accentMaterial = accentMaterial;
makeBox(3.25, 0.38, 3.3, baseMaterial, 0, 0.2, 0, group);
makeBox(2.65, 1.45, 2.35, bodyMaterial, 0, 1.12, 0, group);
makeBox(2.9, 0.22, 2.6, accentMaterial, 0, 1.93, 0, group);
makeBox(0.25, 1.2, 0.28, accentMaterial, -1.25, 2.3, -0.92, group);
makeBox(0.25, 1.2, 0.28, accentMaterial, 1.25, 2.3, -0.92, group);
makeBox(0.25, 0.8, 0.28, accentMaterial, -1.25, 2.05, 0.92, group);
makeBox(0.25, 0.8, 0.28, accentMaterial, 1.25, 2.05, 0.92, group);
makeBox(2.15, 0.75, 0.08, darkMaterial, 0, 1.3, 1.21, group);
makeBox(1.62, 0.28, 0.1, accentMaterial, 0, 1.48, 1.28, group);
makeBox(0.42, 0.44, 0.25, darkMaterial, -1.55, 1.2, 0, group);
makeBox(0.42, 0.44, 0.25, darkMaterial, 1.55, 1.2, 0, group);
const progressBackground = makeBox(
2.12,
0.13,
0.1,
darkMaterial,
0,
0.94,
1.28,
group
);
progressBackground.castShadow = false;
const progressFill = makeBox(
2.06,
0.15,
0.12,
accentMaterial,
0,
0.94,
1.35,
group
);
progressFill.castShadow = false;
station.progressFill = progressFill;
const workMaterial = new THREE.MeshStandardMaterial({
color: station.color,
emissive: station.color,
emissiveIntensity: 0.65,
roughness: 0.25,
metalness: 0.4
});
const workMesh = makeBox(
0.62,
0.62,
0.62,
workMaterial,
0,
2.53,
0,
group
);
workMesh.visible = false;
station.workMesh = workMesh;
const rotor = new THREE.Group();
rotor.position.set(0, 2.36, -0.42);
group.add(rotor);
for (let i = 0; i < 4; i++) {
const angle = (i / 4) * Math.PI * 2;
const part = makeBox(
0.34,
0.22,
0.34,
accentMaterial,
Math.cos(angle) * 0.55,
0,
Math.sin(angle) * 0.55,
rotor
);
part.rotation.y = angle;
}
station.rotor = rotor;
const queueGroup = new THREE.Group();
group.add(queueGroup);
station.queueMeshes = [];
const queueMaterial = new THREE.MeshStandardMaterial({
color: 0xd9edf5,
emissive: 0x294654,
emissiveIntensity: 0.18,
roughness: 0.48,
metalness: 0.25
});
for (let i = 0; i < 10; i++) {
const row = Math.floor(i / 2);
const column = i % 2;
const cube = makeBox(
0.38,
0.32,
0.38,
queueMaterial,
-1.17 + column * 0.43,
0.62 + row * 0.34,
0.83,
queueGroup
);
cube.visible = false;
station.queueMeshes.push(cube);
}
const selectionMaterial = new THREE.MeshBasicMaterial({
color: station.color,
transparent: true,
opacity: 0.8,
depthWrite: false
});
const selection = new THREE.Group();
const half = 1.8;
const strip = 0.07;
const length = 1.15;
makeBox(length, 0.04, strip, selectionMaterial, -half + length / 2, 0.03, -half, selection);
makeBox(length, 0.04, strip, selectionMaterial, half - length / 2, 0.03, -half, selection);
makeBox(length, 0.04, strip, selectionMaterial, -half + length / 2, 0.03, half, selection);
makeBox(length, 0.04, strip, selectionMaterial, half - length / 2, 0.04, half, selection);
selection.visible = false;
group.add(selection);
station.selection = selection;
const label = createLabelTexture(
station.name,
station.code,
station.color
);
label.sprite.position.set(0, 4.15, 0);
group.add(label.sprite);
station.label = label;
group.traverse((object) => {
if (object.isMesh) {
object.userData.stationIndex = station.index;
pickables.push(object);
}
});
}
stations.forEach(createStation);
for (let i = 0; i < stations.length - 1; i++) {
createBelt(
stations[i].x + 1.67,
stations[i + 1].x - 1.67
);
}
createBelt(stations.at(-1).x + 1.67, 13.45);
// Shipping dock.
const dock = new THREE.Group();
dock.position.x = 14.25;
scene.add(dock);
const dockMaterial = new THREE.MeshStandardMaterial({
color: 0x172b39,
roughness: 0.45,
metalness: 0.68
});
const dockAccent = new THREE.MeshStandardMaterial({
color: 0x55e6c1,
emissive: 0x55e6c1,
emissiveIntensity: 0.25,
roughness: 0.35,
metalness: 0.5
});
makeBox(2.4, 0.38, 3.3, dockMaterial, 0, 0.2, 0, dock);
makeBox(0.22, 3.25, 0.22, dockAccent, -1.02, 1.65, -1.35, dock);
makeBox(0.22, 3.25, 0.22, dockAccent, 1.02, 1.65, -1.35, dock);
makeBox(2.25, 0.22, 0.22, dockAccent, 0, 3.2, -1.35, dock);
makeBox(1.7, 0.7, 1.5, dockMaterial, 0, 0.75, 0, dock);
const dockLabel = createLabelTexture("Shipment Dock", "OUT", 0x55e6c1);
dockLabel.sprite.position.set(0, 4, 0);
dockLabel.sprite.scale.set(3.8, 0.95, 1);
dock.add(dockLabel.sprite);
// Background voxel stacks and distant structures.
const backgroundMaterials = [
new THREE.MeshStandardMaterial({ color: 0x102536, roughness: 0.9 }),
new THREE.MeshStandardMaterial({ color: 0x142b3a, roughness: 0.86 }),
new THREE.MeshStandardMaterial({ color: 0x173344, roughness: 0.82 })
];
for (let i = 0; i < 13; i++) {
const x = -21 + i * 3.55;
const stackHeight = 1 + (Math.sin(i * 4.13) + 1) * 1.3;
const z = -9.5 - (i % 3) * 1.3;
const width = 1.4 + (i % 2) * 0.5;
makeBox(
width,
stackHeight,
1.7,
backgroundMaterials[i % backgroundMaterials.length],
x,
stackHeight * 0.5 - 0.12,
z
);
if (i % 3 === 0) {
makeBox(
0.24,
3.4,
0.24,
dockAccent,
x - width * 0.25,
1.6,
z + 0.9
);
}
}
// Safety markings along the factory platform.
for (let i = 0; i < 28; i++) {
const stripe = makeBox(
0.42,
0.035,
0.16,
warningMaterial,
-13.2 + i * 0.98,
0.16,
3.52
);
stripe.rotation.y = -0.35;
stripe.castShadow = false;
}
// -------------------------------------------------------------------------
// Custom camera controls — no external controls addon
// -------------------------------------------------------------------------
const cameraRig = {
target: new THREE.Vector3(0, 1.1, 0),
radius: 27,
theta: 0.68,
phi: 0.76,
minRadius: 12,
maxRadius: 42,
pointers: new Map(),
lastPinchDistance: 0,
update() {
this.phi = THREE.MathUtils.clamp(this.phi, 0.32, 1.38);
this.radius = THREE.MathUtils.clamp(
this.radius,
this.minRadius,
this.maxRadius
);
const sinPhi = Math.sin(this.phi);
camera.position.set(
this.target.x + this.radius * sinPhi * Math.sin(this.theta),
this.target.y + this.radius * Math.cos(this.phi),
this.target.z + this.radius * sinPhi * Math.cos(this.theta)
);
camera.lookAt(this.target);
},
pan(dx, dy) {
const right = new THREE.Vector3().setFromMatrixColumn(
camera.matrix,
0
);
const up = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 1);
const scale = this.radius * 0.00145;
this.target.addScaledVector(right, -dx * scale);
this.target.addScaledVector(up, dy * scale);
this.target.x = THREE.MathUtils.clamp(this.target.x, -9, 9);
this.target.y = THREE.MathUtils.clamp(this.target.y, 0, 4);
this.target.z = THREE.MathUtils.clamp(this.target.z, -5, 5);
}
};
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function pickStation(event) {
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(pickables, false);
if (hits.length) {
const index = hits[0].object.userData.stationIndex;
if (Number.isInteger(index)) {
selectStation(index);
}
}
}
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
cameraRig.pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY,
startX: event.clientX,
startY: event.clientY,
button: event.button
});
});
renderer.domElement.addEventListener("pointermove", (event) => {
const current = cameraRig.pointers.get(event.pointerId);
if (!current) return;
if (cameraRig.pointers.size === 1) {
const dx = event.clientX - current.x;
const dy = event.clientY - current.y;
if (current.button === 2 || event.shiftKey) {
cameraRig.pan(dx, dy);
} else {
cameraRig.theta -= dx * 0.006;
cameraRig.phi += dy * 0.005;
}
current.x = event.clientX;
current.y = event.clientY;
} else if (cameraRig.pointers.size === 2) {
current.x = event.clientX;
current.y = event.clientY;
const points = [...cameraRig.pointers.values()];
const distance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
if (cameraRig.lastPinchDistance > 0) {
cameraRig.radius *=
cameraRig.lastPinchDistance / Math.max(1, distance);
}
cameraRig.lastPinchDistance = distance;
}
});
renderer.domElement.addEventListener("pointerup", (event) => {
const current = cameraRig.pointers.get(event.pointerId);
const wasSinglePointer = cameraRig.pointers.size === 1;
cameraRig.pointers.delete(event.pointerId);
if (cameraRig.pointers.size < 2) {
cameraRig.lastPinchDistance = 0;
}
if (
current &&
wasSinglePointer &&
event.button === 0 &&
Math.hypot(
event.clientX - current.startX,
event.clientY - current.startY
) < 6
) {
pickStation(event);
}
});
renderer.domElement.addEventListener("pointercancel", (event) => {
cameraRig.pointers.delete(event.pointerId);
cameraRig.lastPinchDistance = 0;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraRig.radius *= Math.exp(event.deltaY * 0.001);
},
{ passive: false }
);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
// -------------------------------------------------------------------------
// Simulation
// -------------------------------------------------------------------------
function cycleTimeForLevel(station, level) {
return Math.max(
450,
Math.round(station.baseMs * Math.pow(PROCESSING_REDUCTION, level - 1))
);
}
function upgradeCost(station) {
if (station.level >= MAX_LEVEL) return Infinity;
const raw =
station.baseMs * 0.12 * Math.pow(1.55, station.level - 1);
return Math.max(75, Math.round(raw / 5) * 5);
}
function effectiveTime(station) {
return station.processing
? station.activeDuration
: station.timeMs;
}
function formatMs(ms) {
if (ms >= 1000) {
return `${(ms / 1000).toFixed(2)}s`;
}
return `${Math.round(ms)}ms`;
}
function currentBottleneck() {
let result = stations[0];
let longest = effectiveTime(result);
for (const station of stations) {
const time = effectiveTime(station);
if (time > longest) {
longest = time;
result = station;
}
}
return { station: result, time: longest };
}
function spawnTransit(fromIndex) {
const from = stations[fromIndex];
const isShipping = fromIndex === stations.length - 1;
const startX = from.x + 1.6;
const endX = isShipping ? 13.45 : stations[fromIndex + 1].x - 1.6;
const material = new THREE.MeshStandardMaterial({
color: from.color,
emissive: from.color,
emissiveIntensity: 0.32,
roughness: 0.32,
metalness: 0.42
});
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(0.56, 0.56, 0.56),
material
);
mesh.castShadow = true;
mesh.position.set(startX, 1.03, 0);
scene.add(mesh);
state.transits.push({
fromIndex,
isShipping,
mesh,
startX,
endX,
progress: 0,
duration: 1300
});
}
function completeStation(station) {
station.processing = false;
station.remaining = 0;
station.measuredMs = station.activeDuration;
spawnTransit(station.index);
}
function updateStations(dt) {
const dtMs = dt * 1000;
for (const station of stations) {
if (station.processing) {
station.remaining -= dtMs;
if (station.remaining <= 0) {
completeStation(station);
}
} else if (station.index === 0 || station.queue > 0) {
if (station.index !== 0) {
station.queue -= 1;
}
station.processing = true;
station.activeDuration = station.timeMs;
station.remaining = station.timeMs;
}
}
}
function updateTransits(dt) {
for (let i = state.transits.length - 1; i >= 0; i--) {
const transit = state.transits[i];
transit.progress += (dt * 1000) / transit.duration;
const t = Math.min(1, transit.progress);
const eased = t * t * (3 - 2 * t);
transit.mesh.position.x = THREE.MathUtils.lerp(
transit.startX,
transit.endX,
eased
);
transit.mesh.position.y =
1.03 + Math.sin(t * Math.PI) * 0.22;
transit.mesh.rotation.x += dt * 2.2;
transit.mesh.rotation.y += dt * 2.8;
if (t >= 1) {
scene.remove(transit.mesh);
transit.mesh.geometry.dispose();
transit.mesh.material.dispose();
if (transit.isShipping) {
state.credits += SHIPMENT_VALUE;
state.shipments.push(state.elapsed);
} else {
stations[transit.fromIndex + 1].queue += 1;
}
state.transits.splice(i, 1);
}
}
}
function upgradeStation(index) {
const station = stations[index];
const cost = upgradeCost(station);
if (!Number.isFinite(cost)) {
showToast(`${station.name} is already at maximum level.`);
return;
}
if (state.credits < cost) {
showToast(`Not enough credits. ${station.name} needs ${cost} CR.`);
return;
}
state.credits -= cost;
const oldTime = station.timeMs;
station.level += 1;
station.timeMs = cycleTimeForLevel(station, station.level);
if (station.processing) {
const ratio = station.timeMs / oldTime;
station.remaining *= ratio;
station.activeDuration *= ratio;
}
station.flash = 1;
selectStation(index);
showToast(
`${station.name} upgraded to Lv ${station.level} • ${formatMs(
station.timeMs
)} cycle`
);
updateUI();
}
function selectStation(index) {
state.selected = index;
for (const station of stations) {
station.selection.visible = station.index === index;
}
updateUI();
}
// -------------------------------------------------------------------------
// Interface
// -------------------------------------------------------------------------
const cardElements = new Map();
for (const station of stations) {
const card = document.createElement("article");
card.className = "station-card";
card.style.setProperty("--station-color", `#${station.color
.toString(16)
.padStart(6, "0")}`);
card.innerHTML = `
<div class="station-top">
<div class="station-code">${station.code}</div>
<div class="station-name">
<strong>${station.name}</strong>
<span>${station.role}</span>
</div>
<div class="station-time">
<span class="card-time">${formatMs(station.timeMs)}</span>
<small>cycle</small>
</div>
</div>
<div class="station-bottom">
<div style="display:flex;align-items:center;">
<div class="level-dots">
${Array.from({ length: MAX_LEVEL }, () => "<i class='level-dot'></i>").join("")}
</div>
<span class="queue-label">Q <b class="card-queue">0</b></span>
</div>
<button class="upgrade-mini" type="button">UPGRADE</button>
</div>
`;
card.addEventListener("click", () => selectStation(station.index));
const button = card.querySelector(".upgrade-mini");
button.addEventListener("click", (event) => {
event.stopPropagation();
selectStation(station.index);
upgradeStation(station.index);
});
stationList.appendChild(card);
cardElements.set(station.index, {
card,
button,
time: card.querySelector(".card-time"),
queue: card.querySelector(".card-queue"),
dots: [...card.querySelectorAll(".level-dot")]
});
}
selectedUpgrade.addEventListener("click", () => {
upgradeStation(state.selected);
});
pauseBtn.addEventListener("click", () => {
state.paused = !state.paused;
pauseBtn.innerHTML = state.paused
? "▶ RESUME"
: '<span class="live-dot"></span>PAUSE';
});
speedBtn.addEventListener("click", () => {
state.speed = state.speed === 1 ? 2 : state.speed === 2 ? 4 : 1;
speedBtn.textContent = `${state.speed}× SPEED`;
});
function showToast(message) {
toast.textContent = message;
toast.classList.add("show");
clearTimeout(state.toastTimer);
state.toastTimer = setTimeout(() => {
toast.classList.remove("show");
}, 2600);
}
function updateUI() {
creditsValue.textContent = Math.floor(state.credits).toLocaleString();
const recentWindow = Math.min(30, Math.max(5, state.elapsed));
const recentShipments = state.shipments.filter(
(time) => time >= state.elapsed - 30
).length;
const measuredRate =
state.elapsed > 0
? Math.round((recentShipments / recentWindow) * 60)
: 0;
rateValue.textContent = measuredRate;
const bottleneck = currentBottleneck();
bottleneckName.textContent = bottleneck.station.name;
bottleneckTime.textContent = formatMs(bottleneck.time);
bottleneckNote.textContent =
`This station currently has the longest processing cycle, so it sets the line's maximum sustainable pace.`;
const sorted = [...stations].sort(
(a, b) => effectiveTime(b) - effectiveTime(a)
);
const maximum = Math.max(...stations.map(effectiveTime));
ranking.innerHTML = sorted
.map((station) => {
const time = effectiveTime(station);
const width = Math.max(7, (time / maximum) * 100);
const color = `#${station.color.toString(16).padStart(6, "0")}`;
return `
<div class="ranking-row">
<span>${station.code}</span>
<div class="ranking-track">
<div
class="ranking-fill"
style="width:${width}%;background:${color};color:${color}"
></div>
</div>
<span class="ranking-time">${formatMs(time)}</span>
</div>
`;
})
.join("");
for (const station of stations) {
const elements = cardElements.get(station.index);
const cost = upgradeCost(station);
elements.time.textContent = formatMs(effectiveTime(station));
elements.queue.textContent = station.queue;
elements.card.classList.toggle("selected", station.index === state.selected);
elements.button.disabled =
!Number.isFinite(cost) || state.credits < cost;
elements.button.textContent = Number.isFinite(cost)
? `+ ${cost} CR`
: "MAX";
elements.dots.forEach((dot, index) => {
dot.classList.toggle("on", index < station.level);
});
}
const selected = stations[state.selected];
const selectedCost = upgradeCost(selected);
const nextTime = cycleTimeForLevel(selected, selected.level + 1);
const projected = Math.round(60000 / bottleneck.time);
const selectedColor = `#${selected.color.toString(16).padStart(6, "0")}`;
selectedHeading.style.setProperty("--selected-color", selectedColor);
selectedCode.textContent = selected.code;
selectedCode.style.color = selectedColor;
selectedName.textContent = selected.name;
selectedRole.textContent = selected.role;
selectedLevel.textContent = `${selected.level} / ${MAX_LEVEL}`;
selectedTime.textContent = formatMs(effectiveTime(selected));
selectedQueue.textContent = selected.queue;
selectedProjected.textContent = `${projected}/min`;
if (Number.isFinite(selectedCost)) {
selectedUpgrade.disabled = state.credits < selectedCost;
selectedUpgrade.textContent = `UPGRADE STATION • ${selectedCost} CR`;
upgradeDetail.textContent =
`Next cycle: ${formatMs(selected.timeMs)} → ${formatMs(nextTime)} ` +
`(${Math.round((1 - nextTime / selected.timeMs) * 100)}% faster).`;
} else {
selectedUpgrade.disabled = true;
selectedUpgrade.textContent = "MAXIMUM LEVEL REACHED";
upgradeDetail.textContent =
"This station is running at its fastest supported processing cycle.";
}
}
// -------------------------------------------------------------------------
// Animation loop
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
let lastUIUpdate = 0;
let firstFrame = true;
function animate(now) {
requestAnimationFrame(animate);
const realDt = Math.min(clock.getDelta(), 0.05);
const dt = state.paused ? 0 : realDt * state.speed;
if (!state.paused) {
state.elapsed += dt;
updateStations(dt);
updateTransits(dt);
}
for (const station of stations) {
if (station.processing) {
station.workMesh.visible = true;
station.workMesh.rotation.y += dt * 2.6;
station.workMesh.position.y =
2.53 + Math.sin(now * 0.006 + station.index) * 0.09;
const progress = THREE.MathUtils.clamp(
1 - station.remaining / station.activeDuration,
0,
1
);
station.progressFill.scale.x = Math.max(0.001, progress);
station.progressFill.position.x =
-1.03 + 1.03 * progress;
} else {
station.workMesh.visible = false;
station.progressFill.scale.x = 0.001;
}
station.rotor.rotation.y +=
dt * (station.processing ? 1.8 : 0.22);
station.flash = Math.max(0, station.flash - realDt * 2.2);
station.accentMaterial.emissiveIntensity =
0.2 + station.flash * 1.6;
station.bodyMaterial.emissiveIntensity =
station.flash * 0.22;
if (station.selection.visible) {
const pulse = 1 + Math.sin(now * 0.004) * 0.035;
station.selection.scale.set(pulse, 1, pulse);
station.selection.children.forEach((part) => {
part.material.opacity = 0.58 + Math.sin(now * 0.004) * 0.18;
});
}
const visibleQueue = Math.min(station.queue, station.queueMeshes.length);
station.queueMeshes.forEach((mesh, index) => {
mesh.visible = index < visibleQueue;
});
}
cameraRig.update();
if (now - lastUIUpdate > 120) {
updateUI();
lastUIUpdate = now;
}
if (now - (animate.lastLabelUpdate || 0) > 220) {
stations.forEach(drawStationLabel);
animate.lastLabelUpdate = now;
}
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 450);
}
}
selectStation(3);
updateUI();
requestAnimationFrame(animate);
</script>
</body>
</html>
```