Prompt specification
Build or customize the Three.js 3D scene "Circular Neighborhood Learning Diorama" 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: Circular Neighborhood Learning Diorama
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/circular-neighborhood-learning-diorama-x3947
Scene Description Prompt:
Trace selected material flows through a voxel neighborhood linking garden, kitchen, repair shop, and collection point. Three.js from cdnjs, standalone HTML.
Working Three.js Starter (circular-neighborhood-learning-diorama-x3947):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Circular Block — Material Flow Atlas</title>
<style>
:root {
--accent: #f2b65d;
--accent-rgb: 242, 182, 93;
--ink: #edf5f5;
--muted: #91a5ad;
--panel: rgba(9, 22, 30, 0.82);
--line: rgba(173, 211, 220, 0.16);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #071018;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
outline: none;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
z-index: 1;
pointer-events: none;
background:
radial-gradient(
circle at 52% 47%,
transparent 35%,
rgba(2, 8, 12, 0.28) 75%,
rgba(2, 8, 12, 0.68) 100%
);
}
.masthead {
position: fixed;
top: 27px;
left: 30px;
z-index: 5;
max-width: 470px;
pointer-events: none;
text-shadow: 0 2px 20px rgba(0, 0, 0, 0.45);
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.22em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 24px;
height: 2px;
background: var(--accent);
box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.8);
}
h1 {
margin: 9px 0 7px;
max-width: 430px;
font-size: clamp(27px, 3vw, 42px);
font-weight: 650;
line-height: 1.02;
letter-spacing: -0.045em;
}
.masthead p {
margin: 0;
color: #a9bbc1;
font-size: 12px;
line-height: 1.55;
}
.panel {
position: fixed;
z-index: 5;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
box-shadow:
0 22px 60px rgba(0, 0, 0, 0.28),
inset 0 1px 0 rgba(255, 255, 255, 0.035);
backdrop-filter: blur(18px) saturate(120%);
-webkit-backdrop-filter: blur(18px) saturate(120%);
}
#materialPanel {
top: 185px;
left: 30px;
width: 322px;
padding: 17px;
}
.panel-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 13px;
}
.panel-heading h2 {
margin: 0;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.live-tag {
display: inline-flex;
align-items: center;
gap: 6px;
color: #9bb0b7;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.live-tag::before {
content: "";
width: 6px;
height: 6px;
border-radius: 50%;
background: #68d998;
box-shadow: 0 0 10px #68d998;
animation: breathe 1.8s ease-in-out infinite;
}
@keyframes breathe {
50% {
opacity: 0.45;
transform: scale(0.8);
}
}
#materialList {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.material-button {
position: relative;
min-height: 78px;
padding: 12px;
overflow: hidden;
border: 1px solid rgba(164, 199, 210, 0.12);
border-radius: 11px;
background: rgba(255, 255, 255, 0.025);
color: var(--ink);
text-align: left;
cursor: pointer;
transition:
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
.material-button:hover {
transform: translateY(-1px);
border-color: rgba(var(--accent-rgb), 0.45);
background: rgba(var(--accent-rgb), 0.055);
}
.material-button.active {
border-color: rgba(var(--accent-rgb), 0.75);
background:
linear-gradient(
135deg,
rgba(var(--accent-rgb), 0.15),
rgba(var(--accent-rgb), 0.035)
);
box-shadow:
inset 0 0 0 1px rgba(var(--accent-rgb), 0.08),
0 0 24px rgba(var(--accent-rgb), 0.08);
}
.material-button::after {
content: "";
position: absolute;
top: 10px;
right: 10px;
width: 5px;
height: 5px;
border-radius: 50%;
background: var(--swatch);
box-shadow: 0 0 12px var(--swatch);
}
.material-button strong {
display: block;
margin-top: 12px;
font-size: 12px;
font-weight: 700;
}
.material-button small {
display: block;
margin-top: 4px;
color: #7f969e;
font-size: 9px;
line-height: 1.35;
}
.panel-note {
margin: 13px 2px 0;
color: #82979f;
font-size: 10px;
line-height: 1.5;
}
#routeCard {
top: 84px;
right: 30px;
width: 302px;
padding: 19px;
}
.route-code {
color: var(--accent);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
#routeTitle {
margin: 8px 0 6px;
font-size: 24px;
font-weight: 650;
line-height: 1.1;
letter-spacing: -0.035em;
}
#routeDescription {
min-height: 48px;
margin: 0;
color: #92a7ae;
font-size: 10px;
line-height: 1.55;
}
.route-sequence {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 4px;
margin: 18px 0;
}
.route-step {
position: relative;
display: flex;
flex: 1;
flex-direction: column;
align-items: center;
min-width: 0;
text-align: center;
}
.route-step:not(:last-child)::after {
content: "";
position: absolute;
top: 10px;
left: calc(50% + 12px);
width: calc(100% - 24px);
height: 1px;
background: linear-gradient(
90deg,
rgba(var(--accent-rgb), 0.85),
rgba(var(--accent-rgb), 0.25)
);
}
.step-dot {
position: relative;
z-index: 1;
width: 21px;
height: 21px;
border: 1px solid rgba(var(--accent-rgb), 0.85);
border-radius: 50%;
background: #0c1b23;
box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.17);
}
.step-dot::after {
content: "";
position: absolute;
inset: 5px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.8);
}
.route-step span {
display: block;
width: 100%;
margin-top: 7px;
overflow: hidden;
color: #b8c8cd;
font-size: 8px;
font-weight: 700;
text-overflow: ellipsis;
text-transform: uppercase;
white-space: nowrap;
}
.metric-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 16px;
}
.metric {
padding: 11px;
border: 1px solid rgba(166, 203, 214, 0.1);
border-radius: 9px;
background: rgba(255, 255, 255, 0.025);
}
.metric small {
display: block;
margin-bottom: 4px;
color: #708991;
font-size: 8px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.metric strong {
display: block;
color: #e9f3f4;
font-size: 15px;
font-weight: 650;
}
#focusLine {
margin-top: 13px;
padding-top: 12px;
border-top: 1px solid rgba(164, 201, 211, 0.11);
color: #829aa2;
font-size: 9px;
line-height: 1.45;
}
#viewTools {
position: fixed;
top: 28px;
right: 30px;
z-index: 6;
display: flex;
gap: 7px;
}
.tool-button {
min-height: 34px;
padding: 0 12px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(9, 22, 30, 0.78);
color: #b8c8cd;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(12px);
transition: 150ms ease;
}
.tool-button:hover {
border-color: rgba(var(--accent-rgb), 0.55);
color: var(--ink);
background: rgba(var(--accent-rgb), 0.08);
}
#stationLabels {
position: fixed;
inset: 0;
z-index: 3;
pointer-events: none;
}
.station-label {
position: absolute;
display: flex;
align-items: center;
gap: 8px;
min-width: 122px;
padding: 8px 10px;
border: 1px solid rgba(172, 206, 216, 0.14);
border-radius: 9px;
background: rgba(7, 18, 25, 0.84);
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.24);
transform: translate(-50%, -100%);
pointer-events: auto;
cursor: pointer;
backdrop-filter: blur(10px);
transition:
opacity 160ms ease,
border-color 160ms ease,
background 160ms ease;
}
.station-label:hover,
.station-label.on-route {
border-color: rgba(var(--accent-rgb), 0.48);
background: rgba(10, 25, 33, 0.92);
}
.station-label.focused {
border-color: rgba(var(--accent-rgb), 0.9);
box-shadow: 0 0 28px rgba(var(--accent-rgb), 0.13);
}
.station-pin {
width: 9px;
height: 9px;
flex: 0 0 auto;
border: 2px solid var(--site-color);
border-radius: 50%;
box-shadow: 0 0 11px var(--site-color);
}
.station-label small {
display: block;
margin-bottom: 2px;
color: #6e858d;
font-size: 7px;
font-weight: 800;
letter-spacing: 0.12em;
}
.station-label strong {
display: block;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.station-label em {
display: block;
margin-top: 2px;
color: #728a92;
font-size: 7px;
font-style: normal;
white-space: nowrap;
}
.station-label.on-route em {
color: var(--accent);
}
.legend {
position: fixed;
bottom: 26px;
left: 50%;
z-index: 5;
display: flex;
align-items: center;
gap: 18px;
padding: 10px 15px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(7, 18, 25, 0.78);
color: #8ea3aa;
font-size: 9px;
transform: translateX(-50%);
backdrop-filter: blur(12px);
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 7px;
white-space: nowrap;
}
.legend-line {
width: 19px;
height: 3px;
border-radius: 3px;
background: var(--accent);
box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.6);
}
.legend-line.idle {
background: #36515e;
box-shadow: none;
}
.legend-cube {
width: 7px;
height: 7px;
border-radius: 1px;
background: var(--accent);
box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.7);
}
.north {
position: fixed;
right: 34px;
bottom: 30px;
z-index: 5;
display: flex;
flex-direction: column;
align-items: center;
gap: 5px;
color: #799098;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.16em;
pointer-events: none;
}
.north-arrow {
width: 0;
height: 0;
border-right: 6px solid transparent;
border-bottom: 18px solid #8ca3aa;
border-left: 6px solid transparent;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #071018;
color: #8da4ac;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 900px) {
.masthead {
left: 18px;
top: 20px;
}
.masthead p {
display: none;
}
#materialPanel {
top: 124px;
left: 18px;
width: 286px;
}
#routeCard {
top: 78px;
right: 18px;
width: 270px;
}
#viewTools {
top: 20px;
right: 18px;
}
.legend {
bottom: 18px;
}
}
@media (max-width: 700px) {
h1 {
max-width: 300px;
font-size: 27px;
}
#routeCard {
display: none;
}
#materialPanel {
top: auto;
right: 12px;
bottom: 62px;
left: 12px;
width: auto;
padding: 12px;
}
#materialList {
grid-template-columns: repeat(4, 1fr);
}
.material-button {
min-height: 65px;
padding: 9px;
}
.material-button strong {
margin-top: 9px;
font-size: 10px;
}
.material-button small,
.panel-note {
display: none;
}
.legend {
right: 12px;
bottom: 14px;
left: 12px;
justify-content: center;
transform: none;
}
.legend-item:nth-child(3) {
display: none;
}
.north {
display: none;
}
.station-label {
min-width: 100px;
}
.station-label em {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" tabindex="0" aria-label="Interactive voxel neighborhood material flow map"></canvas>
<div class="vignette"></div>
<header class="masthead">
<div class="eyebrow">Circular block / flow atlas</div>
<h1>Follow the stuff that moves.</h1>
<p>
A living neighborhood map of reusable materials moving between the
garden, kitchen, repair shop, and collection point.
</p>
</header>
<aside class="panel" id="materialPanel">
<div class="panel-heading">
<h2>Select material</h2>
<span class="live-tag">Live trace</span>
</div>
<div id="materialList"></div>
<p class="panel-note">
Select a material to reveal its active route. Click a site marker to
inspect that part of the neighborhood.
</p>
</aside>
<aside class="panel" id="routeCard">
<div class="route-code" id="routeCode">TRACE / WD-02</div>
<h2 id="routeTitle">Timber offcuts</h2>
<p id="routeDescription"></p>
<div class="route-sequence" id="routeSequence"></div>
<div class="metric-grid">
<div class="metric">
<small>Current batch</small>
<strong id="routeQuantity">2.8 m³</strong>
</div>
<div class="metric">
<small>Recovery rate</small>
<strong id="routeRecovery">86% reused</strong>
</div>
</div>
<div id="focusLine">4 neighborhood sites connected by 5 transfer links.</div>
</aside>
<div id="viewTools">
<button class="tool-button" id="resetView" type="button">Reset</button>
<button class="tool-button" id="topView" type="button">Top</button>
<button class="tool-button" id="pauseFlow" type="button">Pause</button>
</div>
<div id="stationLabels"></div>
<div class="legend">
<div class="legend-item">
<span class="legend-line"></span>
Selected route
</div>
<div class="legend-item">
<span class="legend-line idle"></span>
Other network links
</div>
<div class="legend-item">
<span class="legend-cube"></span>
Material batch
</div>
<div class="legend-item">Drag to orbit · Shift-drag to pan · Scroll to zoom</div>
</div>
<div class="north">
<span>N</span>
<span class="north-arrow"></span>
</div>
<div id="loading">Building neighborhood…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Data
// ------------------------------------------------------------
const stations = {
garden: {
index: "01",
name: "Garden",
role: "Source / organics",
x: -13,
z: -4.5,
labelY: 3.7,
color: "#7bd99a",
colorValue: 0x7bd99a
},
kitchen: {
index: "02",
name: "Kitchen",
role: "Sorting / transfer",
x: -4,
z: -7.5,
labelY: 4.2,
color: "#f2a865",
colorValue: 0xf2a865
},
repair: {
index: "03",
name: "Repair shop",
role: "Process / reuse",
x: 6,
z: -1,
labelY: 4.2,
color: "#63c8e8",
colorValue: 0x63c8e8
},
collection: {
index: "04",
name: "Collection",
role: "Destination / depot",
x: 14,
z: 7,
labelY: 4.7,
color: "#cf9cf4",
colorValue: 0xcf9cf4
}
};
const materials = {
timber: {
name: "Timber",
subtitle: "Garden offcuts",
title: "Timber offcuts",
code: "WD-02",
color: 0xf2b65d,
css: "#f2b65d",
rgb: "242, 182, 93",
quantity: "2.8 m³",
recovery: "86% reused",
path: ["garden", "repair", "collection"],
description:
"Arbor and planter offcuts move to the repair shop for sizing, then leave the block as reusable construction stock."
},
organic: {
name: "Organics",
subtitle: "Market greens",
title: "Market greens",
code: "OR-11",
color: 0x76dc91,
css: "#76dc91",
rgb: "118, 220, 145",
quantity: "640 kg",
recovery: "92% composted",
path: ["garden", "kitchen", "collection"],
description:
"Surplus produce is harvested in the garden, prepared at the kitchen, and collected for neighborhood composting."
},
metal: {
name: "Aluminium",
subtitle: "Scrap metal",
title: "Scrap aluminium",
code: "MT-04",
color: 0x63c8e8,
css: "#63c8e8",
rgb: "99, 200, 232",
quantity: "185 kg",
recovery: "98% remelted",
path: ["kitchen", "repair", "collection"],
description:
"Kitchen trays and workshop offcuts are sorted, repaired, and transferred to the collection point for remelting."
},
glass: {
name: "Glass",
subtitle: "Container glass",
title: "Container glass",
code: "GL-08",
color: 0xcf9cf4,
css: "#cf9cf4",
rgb: "207, 156, 244",
quantity: "420 kg",
recovery: "95% recycled",
path: ["kitchen", "collection"],
description:
"Color-sorted containers bypass the repair workshop and travel directly to the collection point for glass recycling."
}
};
const edgeDefinitions = {
"garden-kitchen": {
from: "garden",
to: "kitchen",
points: [
[-13, -4.5],
[-11, -2.3],
[-9, -4.2],
[-7, -6.8],
[-4, -7.5]
]
},
"garden-repair": {
from: "garden",
to: "repair",
points: [
[-13, -4.5],
[-11, 0.5],
[-7, 2.5],
[-2, 3.2],
[2, 1.2],
[6, -1]
]
},
"kitchen-repair": {
from: "kitchen",
to: "repair",
points: [
[-4, -7.5],
[-1, -6],
[1, -7],
[4, -4.5],
[6, -1]
]
},
"repair-collection": {
from: "repair",
to: "collection",
points: [
[6, -1],
[9, 0.4],
[10, 3.8],
[12, 5.8],
[14, 7]
]
},
"kitchen-collection": {
from: "kitchen",
to: "collection",
points: [
[-4, -7.5],
[0, -4],
[4, -1],
[8, 2],
[11, 5.5],
[14, 7]
]
}
};
// ------------------------------------------------------------
// Renderer and scene
// ------------------------------------------------------------
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x071018);
scene.fog = new THREE.Fog(0x071018, 31, 73);
const camera = new THREE.PerspectiveCamera(
44,
window.innerWidth / window.innerHeight,
0.1,
120
);
const hemisphere = new THREE.HemisphereLight(0xb9e6ff, 0x17231f, 1.7);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff0d0, 3.0);
sun.position.set(-16, 26, 18);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -29;
sun.shadow.camera.right = 29;
sun.shadow.camera.top = 25;
sun.shadow.camera.bottom = -25;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 70;
sun.shadow.bias = -0.0003;
scene.add(sun);
const rimLight = new THREE.DirectionalLight(0x4e9cff, 1.2);
rimLight.position.set(22, 12, -18);
scene.add(rimLight);
// ------------------------------------------------------------
// Ground and road network
// ------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.BoxGeometry(48, 0.5, 38),
new THREE.MeshStandardMaterial({
color: 0x0a1720,
roughness: 0.92,
metalness: 0.08
})
);
ground.position.y = -0.27;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(48, 48, 0x29414d, 0x1b303b);
grid.position.y = 0.005;
grid.material.transparent = true;
grid.material.opacity = 0.44;
scene.add(grid);
const edgeCurves = {};
const roadGroup = new THREE.Group();
scene.add(roadGroup);
for (const [key, edge] of Object.entries(edgeDefinitions)) {
const roadPoints = edge.points.map(
([x, z]) => new THREE.Vector3(x, 0.08, z)
);
const roadCurve = new THREE.CatmullRomCurve3(
roadPoints,
false,
"centripetal"
);
edgeCurves[key] = roadCurve;
const road = new THREE.Mesh(
new THREE.TubeGeometry(roadCurve, 72, 0.43, 8, false),
new THREE.MeshStandardMaterial({
color: 0x132630,
roughness: 0.88,
metalness: 0.12
})
);
road.receiveShadow = true;
roadGroup.add(road);
const centerLine = new THREE.Mesh(
new THREE.TubeGeometry(roadCurve, 72, 0.025, 4, false),
new THREE.MeshBasicMaterial({
color: 0x43606c,
transparent: true,
opacity: 0.22
})
);
roadGroup.add(centerLine);
}
// ------------------------------------------------------------
// Voxel neighborhood
// ------------------------------------------------------------
let randomSeed = 874321;
function random() {
randomSeed |= 0;
randomSeed = (randomSeed + 0x6d2b79f5) | 0;
let t = Math.imul(randomSeed ^ (randomSeed >>> 15), 1 | randomSeed);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
}
const buildingColors = [
0x172c38,
0x1b303b,
0x203541,
0x172732,
0x253a43
];
const roofColors = [
0x29424e,
0x233946,
0x2b414b
];
const windowMaterial = new THREE.MeshBasicMaterial({
color: 0xffd18a
});
const coolWindowMaterial = new THREE.MeshBasicMaterial({
color: 0x86d7e8
});
const buildingGroup = new THREE.Group();
scene.add(buildingGroup);
const routeSamples = [];
for (const curve of Object.values(edgeCurves)) {
for (let i = 0; i <= 40; i++) {
const point = curve.getPoint(i / 40);
routeSamples.push(new THREE.Vector2(point.x, point.z));
}
}
function nearRoute(x, z, radius) {
const r2 = radius * radius;
return routeSamples.some((p) => {
const dx = p.x - x;
const dz = p.y - z;
return dx * dx + dz * dz < r2;
});
}
function nearStation(x, z, radius) {
return Object.values(stations).some(
(station) =>
(station.x - x) ** 2 + (station.z - z) ** 2 < radius * radius
);
}
function addWindow(parent, x, y, z, material, side = "front") {
const dimensions =
side === "front"
? [0.28, 0.34, 0.055]
: [0.055, 0.34, 0.28];
const windowMesh = new THREE.Mesh(
new THREE.BoxGeometry(...dimensions),
material
);
windowMesh.position.set(x, y, z);
parent.add(windowMesh);
}
for (let gx = -5; gx <= 5; gx++) {
for (let gz = -4; gz <= 4; gz++) {
const x = gx * 4 + (random() - 0.5) * 1.25;
const z = gz * 3.8 + (random() - 0.5) * 1.15;
if (nearStation(x, z, 4.7) || nearRoute(x, z, 1.75)) {
continue;
}
const width = 1.8 + random() * 1.15;
const depth = 1.7 + random() * 1.05;
const height = 0.8 + Math.pow(random(), 1.7) * 4.7;
const building = new THREE.Group();
building.position.set(x, 0, z);
const body = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
new THREE.MeshStandardMaterial({
color: buildingColors[Math.floor(random() * buildingColors.length)],
roughness: 0.82,
metalness: 0.12
})
);
body.position.y = height / 2;
body.castShadow = true;
body.receiveShadow = true;
building.add(body);
const roof = new THREE.Mesh(
new THREE.BoxGeometry(width + 0.16, 0.16, depth + 0.16),
new THREE.MeshStandardMaterial({
color: roofColors[Math.floor(random() * roofColors.length)],
roughness: 0.8
})
);
roof.position.y = height + 0.08;
roof.castShadow = true;
building.add(roof);
if (random() > 0.38) {
const unit = new THREE.Mesh(
new THREE.BoxGeometry(
0.35 + random() * 0.45,
0.25 + random() * 0.4,
0.35 + random() * 0.45
),
new THREE.MeshStandardMaterial({
color: 0x334a54,
roughness: 0.75
})
);
unit.position.set(
(random() - 0.5) * width * 0.4,
height + 0.3,
(random() - 0.5) * depth * 0.4
);
unit.castShadow = true;
building.add(unit);
}
const rows = Math.max(1, Math.floor((height - 0.45) / 0.9));
const columns = Math.max(1, Math.floor(width / 0.65));
for (let row = 0; row < rows; row++) {
for (let col = 0; col < columns; col++) {
if (random() < 0.25) continue;
const wx =
-width / 2 +
((col + 0.5) * width) / columns;
const wy = 0.55 + row * 0.85;
addWindow(
building,
wx,
wy,
depth / 2 + 0.032,
random() > 0.2 ? windowMaterial : coolWindowMaterial
);
if (random() > 0.4) {
addWindow(
building,
width / 2 + 0.032,
wy,
-depth / 2 + ((col + 0.5) * depth) / columns,
random() > 0.5 ? windowMaterial : coolWindowMaterial,
"side"
);
}
}
}
buildingGroup.add(building);
}
}
// Small trees and shrubs.
const trunkMaterial = new THREE.MeshStandardMaterial({
color: 0x4a3a2c,
roughness: 1
});
const leafMaterials = [
new THREE.MeshStandardMaterial({ color: 0x315d49, roughness: 0.95 }),
new THREE.MeshStandardMaterial({ color: 0x3e7355, roughness: 0.95 }),
new THREE.MeshStandardMaterial({ color: 0x2a5042, roughness: 0.95 })
];
function addTree(x, z, scale = 1) {
const tree = new THREE.Group();
tree.position.set(x, 0, z);
tree.scale.setScalar(scale);
const trunk = new THREE.Mesh(
new THREE.BoxGeometry(0.32, 1.25, 0.32),
trunkMaterial
);
trunk.position.y = 0.625;
trunk.castShadow = true;
tree.add(trunk);
const leafA = new THREE.Mesh(
new THREE.BoxGeometry(1.25, 0.85, 1.15),
leafMaterials[Math.floor(random() * leafMaterials.length)]
);
leafA.position.y = 1.55;
leafA.castShadow = true;
tree.add(leafA);
const leafB = new THREE.Mesh(
new THREE.BoxGeometry(0.9, 0.85, 0.9),
leafMaterials[Math.floor(random() * leafMaterials.length)]
);
leafB.position.set(0.16, 2.1, -0.1);
leafB.castShadow = true;
tree.add(leafB);
scene.add(tree);
}
[
[-18, -9], [-17, 0], [-17, 7], [-12, 7], [-8, 10],
[-1, 11], [4, 10], [11, 11], [18, 2], [19, -7],
[12, -11], [5, -12], [-1, -13], [-10, -13], [20, 10]
].forEach(([x, z], index) => addTree(x, z, 0.8 + random() * 0.35 + index * 0.01));
// Light dust above the city.
const dustPositions = [];
for (let i = 0; i < 180; i++) {
dustPositions.push(
(random() - 0.5) * 47,
1.5 + random() * 7,
(random() - 0.5) * 36
);
}
const dustGeometry = new THREE.BufferGeometry();
dustGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(dustPositions, 3)
);
scene.add(
new THREE.Points(
dustGeometry,
new THREE.PointsMaterial({
color: 0x87b8c6,
size: 0.035,
transparent: true,
opacity: 0.32,
depthWrite: false
})
)
);
// ------------------------------------------------------------
// Station models
// ------------------------------------------------------------
const stationGroups = {};
const stationPickMeshes = [];
const stationRings = {};
function makeBox(
width,
height,
depth,
material,
x,
y,
z,
parent
) {
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 createStationBase(id) {
const station = stations[id];
const group = new THREE.Group();
group.position.set(station.x, 0, station.z);
const platform = makeBox(
4.35,
0.28,
4.0,
new THREE.MeshStandardMaterial({
color: 0x142933,
roughness: 0.78,
metalness: 0.18
}),
0,
0.14,
0,
group
);
const edge = makeBox(
4.45,
0.055,
4.1,
new THREE.MeshBasicMaterial({
color: station.colorValue,
transparent: true,
opacity: 0.22
}),
0,
0.305,
0,
group
);
edge.castShadow = false;
const ringMaterial = new THREE.MeshBasicMaterial({
color: station.colorValue,
transparent: true,
opacity: 0.15,
depthWrite: false
});
const ring = new THREE.Mesh(
new THREE.TorusGeometry(1.42, 0.045, 6, 48),
ringMaterial
);
ring.rotation.x = Math.PI / 2;
ring.position.y = 0.38;
group.add(ring);
stationRings[id] = ring;
scene.add(group);
stationGroups[id] = group;
group.traverse((child) => {
if (child.isMesh) {
child.userData.stationId = id;
stationPickMeshes.push(child);
}
});
return group;
}
// Garden.
{
const group = createStationBase("garden");
const soilMaterial = new THREE.MeshStandardMaterial({
color: 0x3b2b21,
roughness: 1
});
const planterMaterial = new THREE.MeshStandardMaterial({
color: 0x75503a,
roughness: 0.92
});
const plantMaterials = [
new THREE.MeshStandardMaterial({ color: 0x4e9d63, roughness: 0.95 }),
new THREE.MeshStandardMaterial({ color: 0x75b866, roughness: 0.95 }),
new THREE.MeshStandardMaterial({ color: 0x2f7654, roughness: 0.95 })
];
const planterPositions = [
[-1.05, -0.85],
[0, -0.85],
[-1.05, 0.05],
[0, 0.05]
];
for (const [x, z] of planterPositions) {
makeBox(0.86, 0.3, 0.72, planterMaterial, x, 0.48, z, group);
makeBox(0.68, 0.08, 0.54, soilMaterial, x, 0.66, z, group);
for (let i = 0; i < 3; i++) {
const plant = makeBox(
0.2,
0.28 + random() * 0.2,
0.2,
plantMaterials[i % plantMaterials.length],
x + (random() - 0.5) * 0.35,
0.82,
z + (random() - 0.5) * 0.28,
group
);
plant.rotation.y = random() * Math.PI;
}
}
makeBox(
0.12,
2.15,
0.12,
planterMaterial,
-1.65,
1.35,
-1.45,
group
);
makeBox(
0.12,
2.15,
0.12,
planterMaterial,
1.65,
1.35,
-1.45,
group
);
makeBox(
3.35,
0.1,
0.1,
planterMaterial,
0,
2.25,
-1.45,
group
);
}
// Kitchen.
{
const group = createStationBase("kitchen");
const wallMaterial = new THREE.MeshStandardMaterial({
color: 0x283f48,
roughness: 0.82
});
const roofMaterial = new THREE.MeshStandardMaterial({
color: 0xd48350,
roughness: 0.74
});
makeBox(3.35, 2.45, 2.55, wallMaterial, 0, 1.51, -0.2, group);
makeBox(3.58, 0.18, 2.78, roofMaterial, 0, 2.81, -0.2, group);
makeBox(
3.55,
0.18,
0.8,
roofMaterial,
0,
2.03,
1.27,
group
);
makeBox(
0.48,
0.95,
0.48,
new THREE.MeshStandardMaterial({
color: 0x46555a,
roughness: 0.85
}),
-1.05,
3.28,
-0.75,
group
);
makeBox(
1.15,
0.85,
0.07,
new THREE.MeshBasicMaterial({ color: 0xffce83 }),
-0.55,
1.63,
1.095,
group
);
makeBox(
0.08,
1.05,
0.08,
new THREE.MeshStandardMaterial({ color: 0x131d22 }),
0.63,
0.84,
1.15,
group
);
makeBox(
0.52,
0.58,
0.08,
new THREE.MeshBasicMaterial({ color: 0x80d9e6 }),
0.62,
1.55,
1.09,
group
);
}
// Repair shop.
{
const group = createStationBase("repair");
const wallMaterial = new THREE.MeshStandardMaterial({
color: 0x223e4b,
roughness: 0.8
});
const roofMaterial = new THREE.MeshStandardMaterial({
color: 0x4a9db7,
roughness: 0.68
});
makeBox(3.45, 2.5, 2.75, wallMaterial, 0, 1.54, -0.1, group);
makeBox(3.7, 0.2, 3.0, roofMaterial, 0, 2.86, -0.1, group);
makeBox(
1.55,
1.35,
0.08,
new THREE.MeshBasicMaterial({ color: 0x7bdbea }),
-0.35,
1.42,
1.31,
group
);
makeBox(
1.75,
0.16,
0.85,
new THREE.MeshStandardMaterial({
color: 0x936044,
roughness: 0.9
}),
0,
0.63,
1.72,
group
);
makeBox(
0.15,
0.55,
0.15,
new THREE.MeshStandardMaterial({ color: 0x32444b }),
-0.62,
0.34,
1.72,
group
);
makeBox(
0.15,
0.55,
0.15,
new THREE.MeshStandardMaterial({ color: 0x32444b }),
0.62,
0.34,
1.72,
group
);
const toolMaterial = new THREE.MeshStandardMaterial({
color: 0xe0b45f,
roughness: 0.52,
metalness: 0.4
});
const toolA = makeBox(
0.12,
1.0,
0.12,
toolMaterial,
1.5,
1.55,
1.0,
group
);
toolA.rotation.z = 0.55;
const toolB = makeBox(
0.12,
1.0,
0.12,
toolMaterial,
1.5,
1.55,
1.0,
group
);
toolB.rotation.z = -0.55;
}
// Collection point.
{
const group = createStationBase("collection");
const binColors = [0xb477db, 0x62c9df, 0xe1aa59];
binColors.forEach((color, index) => {
const x = -1.0 + index * 1.0;
makeBox(
0.78,
1.0,
0.78,
new THREE.MeshStandardMaterial({
color,
roughness: 0.68,
metalness: 0.15
}),
x,
0.83,
-0.65,
group
);
makeBox(
0.86,
0.1,
0.86,
new THREE.MeshStandardMaterial({
color: 0x233740,
roughness: 0.75
}),
x,
1.38,
-0.65,
group
);
});
makeBox(
0.32,
3.25,
0.32,
new THREE.MeshStandardMaterial({
color: 0x44525b,
roughness: 0.65,
metalness: 0.35
}),
1.35,
1.92,
1.05,
group
);
const beaconMaterial = new THREE.MeshBasicMaterial({
color: 0xd49cf5,
transparent: true,
opacity: 0.86
});
const beacon = new THREE.Mesh(
new THREE.OctahedronGeometry(0.42),
beaconMaterial
);
beacon.position.set(1.35, 3.72, 1.05);
group.add(beacon);
}
// ------------------------------------------------------------
// UI construction
// ------------------------------------------------------------
const materialList = document.querySelector("#materialList");
const stationLabelsContainer = document.querySelector("#stationLabels");
const labelElements = {};
Object.entries(materials).forEach(([id, material]) => {
const button = document.createElement("button");
button.type = "button";
button.className = "material-button";
button.dataset.material = id;
button.style.setProperty("--swatch", material.css);
button.setAttribute("aria-pressed", "false");
button.innerHTML = `
<strong>${material.name}</strong>
<small>${material.subtitle}</small>
`;
button.addEventListener("click", () => selectMaterial(id));
materialList.appendChild(button);
});
Object.entries(stations).forEach(([id, station]) => {
const label = document.createElement("div");
label.className = "station-label";
label.tabIndex = 0;
label.dataset.station = id;
label.style.setProperty("--site-color", station.color);
label.innerHTML = `
<span class="station-pin"></span>
<div>
<small>${station.index} / SITE</small>
<strong>${station.name}</strong>
<em>${station.role}</em>
</div>
`;
label.addEventListener("click", () => focusStation(id));
label.addEventListener("keydown", (event) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
focusStation(id);
}
});
stationLabelsContainer.appendChild(label);
labelElements[id] = label;
});
// ------------------------------------------------------------
// Active route and material packets
// ------------------------------------------------------------
const activeRouteGroup = new THREE.Group();
scene.add(activeRouteGroup);
let packets = [];
let selectedMaterialId = null;
let flowPaused = false;
let pausedTime = 0;
function edgeKey(from, to) {
return `${from}-${to}`;
}
function disposeObject(object) {
object.traverse((child) => {
if (child.geometry) child.geometry.dispose();
if (child.material) {
const list = Array.isArray(child.material)
? child.material
: [child.material];
list.forEach((material) => material.dispose());
}
});
}
function clearActiveRoute() {
while (activeRouteGroup.children.length) {
const child = activeRouteGroup.children.pop();
activeRouteGroup.remove(child);
disposeObject(child);
}
packets = [];
}
function buildActiveRoute(materialId) {
clearActiveRoute();
const material = materials[materialId];
const color = new THREE.Color(material.color);
material.path.forEach((stationId, edgeIndex) => {
if (edgeIndex === material.path.length - 1) return;
const from = material.path[edgeIndex];
const to = material.path[edgeIndex + 1];
const key = edgeKey(from, to);
const roadCurve = edgeCurves[key];
const elevatedPoints = roadCurve.points.map(
(point) => new THREE.Vector3(point.x, 0.51, point.z)
);
const activeCurve = new THREE.CatmullRomCurve3(
elevatedPoints,
false,
"centripetal"
);
const halo = new THREE.Mesh(
new THREE.TubeGeometry(activeCurve, 80, 0.24, 8, false),
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.12,
depthWrite: false
})
);
activeRouteGroup.add(halo);
const core = new THREE.Mesh(
new THREE.TubeGeometry(activeCurve, 80, 0.075, 8, false),
new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 1.15,
roughness: 0.38,
metalness: 0.12,
transparent: true,
opacity: 0.96,
depthWrite: false
})
);
activeRouteGroup.add(core);
const packetCount = 5;
for (let i = 0; i < packetCount; i++) {
const packet = new THREE.Mesh(
new THREE.BoxGeometry(0.32, 0.2, 0.2),
new THREE.MeshBasicMaterial({ color: material.color })
);
const glow = new THREE.Mesh(
new THREE.BoxGeometry(0.52, 0.32, 0.32),
new THREE.MeshBasicMaterial({
color: material.color,
transparent: true,
opacity: 0.1,
depthWrite: false
})
);
packet.add(glow);
activeRouteGroup.add(packet);
packets.push({
mesh: packet,
curve: activeCurve,
offset: i / packetCount + edgeIndex * 0.13,
glow
});
}
});
material.path.forEach((stationId) => {
const station = stations[stationId];
const node = new THREE.Mesh(
new THREE.CylinderGeometry(0.25, 0.25, 0.08, 16),
new THREE.MeshBasicMaterial({ color: material.color })
);
node.position.set(station.x, 0.57, station.z);
activeRouteGroup.add(node);
});
}
function selectMaterial(materialId) {
selectedMaterialId = materialId;
const material = materials[materialId];
document.documentElement.style.setProperty("--accent", material.css);
document.documentElement.style.setProperty(
"--accent-rgb",
material.rgb
);
document.querySelectorAll(".material-button").forEach((button) => {
const active = button.dataset.material === materialId;
button.classList.toggle("active", active);
button.setAttribute("aria-pressed", String(active));
});
document.querySelector("#routeCode").textContent =
`TRACE / ${material.code}`;
document.querySelector("#routeTitle").textContent = material.title;
document.querySelector("#routeDescription").textContent =
material.description;
document.querySelector("#routeQuantity").textContent = material.quantity;
document.querySelector("#routeRecovery").textContent = material.recovery;
document.querySelector("#routeSequence").innerHTML =
material.path
.map(
(stationId) => `
<div class="route-step">
<span class="step-dot"></span>
<span>${stations[stationId].name}</span>
</div>
`
)
.join("");
Object.entries(labelElements).forEach(([id, label]) => {
const onRoute = material.path.includes(id);
label.classList.toggle("on-route", onRoute);
label.querySelector("em").textContent = onRoute
? "On selected route"
: stations[id].role;
});
buildActiveRoute(materialId);
document.querySelector("#focusLine").textContent =
`${material.path.length} sites · ${
material.path.length - 1
} transfer legs · ${packets.length} batch markers in motion`;
}
// ------------------------------------------------------------
// Custom camera controls
// ------------------------------------------------------------
const controls = {
target: new THREE.Vector3(0, 0, 0),
desiredTarget: new THREE.Vector3(0, 0, 0),
yaw: 0.52,
pitch: 0.76,
distance: 39
};
function updateCamera(delta) {
const smoothing = 1 - Math.exp(-delta * 5.2);
controls.target.lerp(controls.desiredTarget, smoothing);
const horizontal =
controls.distance * Math.cos(controls.pitch);
camera.position.set(
controls.target.x + horizontal * Math.sin(controls.yaw),
controls.target.y + controls.distance * Math.sin(controls.pitch),
controls.target.z + horizontal * Math.cos(controls.yaw)
);
camera.lookAt(controls.target);
}
function resetView() {
controls.yaw = 0.52;
controls.pitch = 0.76;
controls.distance = 39;
controls.desiredTarget.set(0, 0, 0);
}
function focusStation(id) {
const station = stations[id];
controls.desiredTarget.set(station.x, 0, station.z);
controls.distance = 23;
Object.entries(labelElements).forEach(([stationId, label]) => {
label.classList.toggle("focused", stationId === id);
});
document.querySelector("#focusLine").textContent =
`Focused: ${station.name} · ${station.role}`;
}
let pointerDown = false;
let pointerMode = "orbit";
let lastPointerX = 0;
let lastPointerY = 0;
let pointerTravel = 0;
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
canvas.addEventListener("pointerdown", (event) => {
pointerDown = true;
pointerMode = event.button === 2 || event.shiftKey ? "pan" : "orbit";
lastPointerX = event.clientX;
lastPointerY = event.clientY;
pointerTravel = 0;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!pointerDown) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
pointerTravel += Math.abs(dx) + Math.abs(dy);
if (pointerMode === "orbit") {
controls.yaw -= dx * 0.006;
controls.pitch = THREE.MathUtils.clamp(
controls.pitch + dy * 0.005,
0.28,
1.42
);
} else {
const scale = controls.distance * 0.0015;
const right = new THREE.Vector3(
Math.cos(controls.yaw),
0,
-Math.sin(controls.yaw)
);
const forward = new THREE.Vector3(
-Math.sin(controls.yaw),
0,
-Math.cos(controls.yaw)
);
controls.target.addScaledVector(right, -dx * scale);
controls.target.addScaledVector(forward, dy * scale);
controls.target.x = THREE.MathUtils.clamp(
controls.target.x,
-19,
19
);
controls.target.z = THREE.MathUtils.clamp(
controls.target.z,
-14,
14
);
controls.desiredTarget.copy(controls.target);
}
});
canvas.addEventListener("pointerup", (event) => {
pointerDown = false;
if (pointerTravel < 6 && event.button === 0) {
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 hits = raycaster.intersectObjects(stationPickMeshes, false);
if (hits.length) {
focusStation(hits[0].object.userData.stationId);
}
}
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
});
canvas.addEventListener("pointercancel", () => {
pointerDown = false;
});
canvas.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.distance = THREE.MathUtils.clamp(
controls.distance * Math.exp(event.deltaY * 0.001),
13,
64
);
},
{ passive: false }
);
canvas.addEventListener("keydown", (event) => {
const key = event.key;
if (key === "ArrowLeft") controls.yaw -= 0.08;
else if (key === "ArrowRight") controls.yaw += 0.08;
else if (key === "ArrowUp") {
controls.pitch = Math.min(1.42, controls.pitch + 0.06);
} else if (key === "ArrowDown") {
controls.pitch = Math.max(0.28, controls.pitch - 0.06);
} else if (key === "+" || key === "=") {
controls.distance = Math.max(13, controls.distance - 2);
} else if (key === "-" || key === "_") {
controls.distance = Math.min(64, controls.distance + 2);
} else if (key === "0") {
resetView();
} else {
return;
}
event.preventDefault();
});
document.querySelector("#resetView").addEventListener("click", resetView);
document.querySelector("#topView").addEventListener("click", () => {
controls.yaw = 0;
controls.pitch = 1.42;
controls.distance = 43;
controls.desiredTarget.set(0, 0, 0);
});
document.querySelector("#pauseFlow").addEventListener("click", (event) => {
flowPaused = !flowPaused;
event.currentTarget.textContent = flowPaused ? "Resume" : "Pause";
});
// ------------------------------------------------------------
// Label projection and animation
// ------------------------------------------------------------
const projected = new THREE.Vector3();
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const [id, station] of Object.entries(stations)) {
projected.set(station.x, station.labelY, station.z);
projected.project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.2 &&
projected.x < 1.2 &&
projected.y > -1.2 &&
projected.y < 1.2;
const label = labelElements[id];
label.style.opacity = visible ? "1" : "0";
label.style.pointerEvents = visible ? "auto" : "none";
if (visible) {
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
label.style.left = `${x}px`;
label.style.top = `${y}px`;
}
}
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
selectMaterial("timber");
const clock = new THREE.Clock();
let animationTime = 0;
renderer.setAnimationLoop(() => {
const delta = Math.min(clock.getDelta(), 0.05);
if (!flowPaused) {
animationTime += delta;
}
updateCamera(delta);
for (const packet of packets) {
const t = (animationTime * 0.085 + packet.offset) % 1;
const point = packet.curve.getPointAt(t);
packet.mesh.position.copy(point);
packet.mesh.rotation.set(
animationTime * 0.8,
animationTime * 1.35 + packet.offset * 8,
animationTime * 0.55
);
const pulse = 0.75 + Math.sin(animationTime * 5 + packet.offset * 9) * 0.25;
packet.glow.material.opacity = 0.065 + pulse * 0.075;
}
Object.entries(stationRings).forEach(([id, ring]) => {
const active =
selectedMaterialId &&
materials[selectedMaterialId].path.includes(id);
const pulse = 1 + Math.sin(animationTime * 2.8) * 0.025;
ring.scale.setScalar(pulse);
ring.material.opacity = active
? 0.63 + Math.sin(animationTime * 3.1) * 0.17
: 0.12;
});
updateLabels();
renderer.render(scene, camera);
});
requestAnimationFrame(() => {
document.querySelector("#loading").classList.add("hidden");
});
</script>
</body>
</html>
```