Prompt specification
Build or customize the Three.js 3D scene "Industrial-town station arrival vignette" 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: Industrial-town station arrival vignette
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/industrial-town-station-arrival-vignette-x2594
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts railway-linked migration to industrial towns. Create a referenced industrial-era station scene with arriving workers, luggage, and local transport. Use fictional individuals and avoid assigning a uniform motive to every traveler. Low-poly.
Working Three.js Starter (industrial-town-station-arrival-vignette-x2594):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Millford Junction — Railway-Linked Arrivals</title>
<style>
:root {
--ink: #253033;
--paper: rgba(244, 236, 214, 0.93);
--line: rgba(54, 61, 57, 0.22);
--accent: #9b553f;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b9c8c7;
color: var(--ink);
font-family: Georgia, "Times New Roman", serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.panel {
position: fixed;
z-index: 5;
pointer-events: none;
}
.title-card {
top: 22px;
left: 22px;
width: min(390px, calc(100vw - 44px));
padding: 18px 20px 16px;
border: 1px solid rgba(52, 58, 54, 0.2);
border-left: 5px solid var(--accent);
background: var(--paper);
box-shadow: 0 14px 35px rgba(28, 35, 33, 0.16);
backdrop-filter: blur(5px);
}
.eyebrow {
margin: 0 0 5px;
color: #845044;
font: 700 11px/1.3 Arial, sans-serif;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 4vw, 37px);
line-height: 1;
font-weight: 700;
letter-spacing: -0.035em;
}
.date {
margin: 7px 0 10px;
color: #59615d;
font: 600 12px/1.3 Arial, sans-serif;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.title-card p:last-child {
margin: 0;
color: #454d49;
font-size: 14px;
line-height: 1.45;
}
.arrivals {
top: 22px;
right: 22px;
width: min(330px, calc(100vw - 44px));
padding: 16px 18px 14px;
border: 1px solid rgba(52, 58, 54, 0.2);
background: var(--paper);
box-shadow: 0 14px 35px rgba(28, 35, 33, 0.14);
backdrop-filter: blur(5px);
}
.arrivals h2 {
margin: 0 0 10px;
font-size: 18px;
letter-spacing: -0.02em;
}
.arrivals ul {
list-style: none;
margin: 0;
padding: 0;
}
.arrivals li {
display: grid;
grid-template-columns: 28px 1fr;
gap: 9px;
align-items: start;
padding: 7px 0;
border-top: 1px solid var(--line);
}
.arrivals li:first-child {
border-top: 0;
padding-top: 0;
}
.badge {
display: grid;
width: 23px;
height: 23px;
place-items: center;
border-radius: 50%;
color: #fff;
font: 700 11px/1 Arial, sans-serif;
box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.person {
font-size: 13px;
line-height: 1.3;
}
.person strong {
font-weight: 700;
}
.reason {
display: block;
margin-top: 2px;
color: #68706b;
font: 12px/1.35 Arial, sans-serif;
}
.fiction-note {
margin: 11px 0 0;
padding-top: 9px;
border-top: 1px solid var(--line);
color: #68706b;
font: italic 11px/1.4 Georgia, serif;
}
.controls {
left: 22px;
bottom: 20px;
display: flex;
align-items: center;
gap: 9px;
padding: 8px 11px;
border: 1px solid rgba(52, 58, 54, 0.18);
border-radius: 2px;
background: rgba(244, 236, 214, 0.88);
color: #4c5550;
font: 11px/1 Arial, sans-serif;
letter-spacing: 0.03em;
pointer-events: auto;
box-shadow: 0 8px 22px rgba(28, 35, 33, 0.1);
}
button {
border: 1px solid rgba(46, 57, 53, 0.35);
border-radius: 2px;
padding: 7px 10px;
background: #efe4c8;
color: #33403c;
font: 700 10px/1 Arial, sans-serif;
letter-spacing: 0.1em;
text-transform: uppercase;
cursor: pointer;
}
button:hover {
background: #fff5db;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #c6d0ca;
color: #4b5551;
font: 700 12px/1 Arial, sans-serif;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 0.5s ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
.title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 13px 15px;
}
.arrivals {
top: auto;
right: 12px;
bottom: 54px;
width: min(315px, calc(100vw - 24px));
max-height: 38vh;
overflow: auto;
}
.controls {
left: 12px;
bottom: 12px;
}
.title-card p:last-child {
display: none;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div id="loading">Building Millford Junction…</div>
<header class="panel title-card">
<p class="eyebrow">A railway-linked arrival</p>
<h1>Millford Junction</h1>
<p class="date">Northern branch line · Autumn, 1896</p>
<p>
Steam rail, factory smoke, luggage, and a local carrier at an industrial
terminus. The railway connects the town, but no two arrivals share
exactly the same reason for coming.
</p>
</header>
<aside class="panel arrivals">
<h2>Six arrivals, six stories</h2>
<ul>
<li>
<span class="badge" style="background:#a86f45">1</span>
<span class="person">
<strong>Elias Venn</strong>
<span class="reason">Beginning a mill apprenticeship</span>
</span>
</li>
<li>
<span class="badge" style="background:#87505b">2</span>
<span class="person">
<strong>Mara Sol</strong>
<span class="reason">Visiting her aunt in the town</span>
</span>
</li>
<li>
<span class="badge" style="background:#536f83">3</span>
<span class="person">
<strong>Ivo Brant</strong>
<span class="reason">Taking a stonework contract</span>
</span>
</li>
<li>
<span class="badge" style="background:#b18b3e">4</span>
<span class="person">
<strong>Ada Bell</strong>
<span class="reason">Attending textile training</span>
</span>
</li>
<li>
<span class="badge" style="background:#477d73">5</span>
<span class="person">
<strong>Lidia Fen</strong>
<span class="reason">Arriving for a nursing course</span>
</span>
</li>
<li>
<span class="badge" style="background:#68784a">6</span>
<span class="person">
<strong>Jonah Pike</strong>
<span class="reason">Making a market delivery</span>
</span>
</li>
</ul>
<p class="fiction-note">
All individuals, destinations, and the station name are fictional.
</p>
</aside>
<div class="panel controls">
<span>Drag to orbit · Wheel to zoom · Arrow keys to pan</span>
<button id="reset-view" type="button">Reset view</button>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, camera, and lighting
// -------------------------------------------------------------------------
const container = document.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
antialias: true,
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.12;
container.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xb9c8c7);
scene.fog = new THREE.Fog(0xb9c8c7, 38, 88);
const camera = new THREE.PerspectiveCamera(
48,
window.innerWidth / window.innerHeight,
0.1,
140
);
const cameraState = {
target: new THREE.Vector3(-1, 1.2, -1.5),
radius: 31,
theta: 0.68,
phi: 1.11
};
function updateCamera() {
const { target, radius, theta, phi } = cameraState;
const sinPhi = Math.sin(phi);
camera.position.set(
target.x + radius * sinPhi * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * sinPhi * Math.cos(theta)
);
camera.lookAt(target);
}
updateCamera();
const hemi = new THREE.HemisphereLight(0xe5f1f2, 0x55483a, 2.0);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffd5a0, 3.0);
sun.position.set(-15, 24, 16);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -32;
sun.shadow.camera.right = 32;
sun.shadow.camera.top = 25;
sun.shadow.camera.bottom = -25;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 70;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xbad6df, 0.85);
fill.position.set(18, 10, -22);
scene.add(fill);
// -------------------------------------------------------------------------
// Palette and reusable geometry helpers
// -------------------------------------------------------------------------
function mat(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0.0,
flatShading: true,
...options
});
}
const M = {
ground: mat(0x737b55),
grass: mat(0x78845b),
ballast: mat(0x575651),
sleeper: mat(0x4b382b),
rail: mat(0x6f7473, { metalness: 0.65, roughness: 0.42 }),
platform: mat(0x9a8b70),
platformEdge: mat(0xc0ae87),
stone: mat(0x706d62),
paleStone: mat(0xb3a88e),
darkIron: mat(0x303a3b, { metalness: 0.48, roughness: 0.52 }),
iron: mat(0x4c5554, { metalness: 0.42, roughness: 0.58 }),
brick: mat(0x874b3d),
brickDark: mat(0x6e3e35),
roof: mat(0x354346),
cream: mat(0xd5c6a0),
brass: mat(0xb48a45, { metalness: 0.58, roughness: 0.4 }),
wood: mat(0x77533b),
woodDark: mat(0x473629),
trainGreen: mat(0x294f49),
trainRed: mat(0x713d38),
trainBlack: mat(0x272d2d),
glass: mat(0x31464d, { metalness: 0.18, roughness: 0.28 }),
lamp: mat(0xffcf72, {
emissive: 0xffa62b,
emissiveIntensity: 1.7,
roughness: 0.5
}),
leaf: mat(0x506746),
leafLight: mat(0x697954),
trunk: mat(0x5f4631),
coal: mat(0x303332)
};
function addMesh(parent, geometry, material, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function box(parent, w, h, d, material, x = 0, y = 0, z = 0) {
return addMesh(
parent,
new THREE.BoxGeometry(w, h, d),
material,
x, y, z
);
}
function cylinder(
parent,
topRadius,
bottomRadius,
height,
segments,
material,
x = 0,
y = 0,
z = 0
) {
return addMesh(
parent,
new THREE.CylinderGeometry(
topRadius,
bottomRadius,
height,
segments
),
material,
x, y, z
);
}
function lowSphere(parent, radius, material, x = 0, y = 0, z = 0) {
return addMesh(
parent,
new THREE.IcosahedronGeometry(radius, 1),
material,
x, y, z
);
}
function gableRoof(parent, width, depth, height, material, x, y, z) {
const positions = new Float32Array([
-width / 2, 0, -depth / 2,
width / 2, 0, -depth / 2,
0, height, -depth / 2,
-width / 2, 0, depth / 2,
width / 2, 0, depth / 2,
0, height, depth / 2
]);
const indices = [
0, 2, 1,
3, 4, 5,
0, 3, 5,
0, 5, 2,
1, 2, 5,
1, 5, 4,
0, 1, 4,
0, 4, 3
];
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
const roofMesh = new THREE.Mesh(geometry, material);
roofMesh.position.set(x, y, z);
roofMesh.castShadow = true;
roofMesh.receiveShadow = true;
parent.add(roofMesh);
return roofMesh;
}
// Deterministic randomness keeps the composition stable between reloads.
let seed = 1917;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
// -------------------------------------------------------------------------
// Procedural station signs
// -------------------------------------------------------------------------
function makeSign(parent, lines, width, height, x, y, z, options = {}) {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 384;
const ctx = canvas.getContext("2d");
ctx.fillStyle = options.background || "#243b39";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = options.border || "#d5bc76";
ctx.lineWidth = 10;
ctx.strokeRect(15, 15, canvas.width - 30, canvas.height - 30);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
lines.forEach((line, index) => {
const isMain = index === 0;
ctx.font = isMain
? "700 58px Georgia"
: "700 29px Arial";
ctx.fillStyle = isMain
? (options.color || "#ead9a8")
: "#d9d3bd";
const yPos = lines.length === 1
? 192
: 112 + index * 88;
ctx.fillText(line, 384, yPos);
});
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
const group = new THREE.Group();
group.position.set(x, y, z);
parent.add(group);
box(group, width + 0.12, height + 0.12, 0.12, M.darkIron);
const face = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({ map: texture })
);
face.position.z = 0.068;
group.add(face);
return group;
}
// -------------------------------------------------------------------------
// Ground, tracks, and platforms
// -------------------------------------------------------------------------
const ground = box(
scene,
120,
0.5,
90,
M.ground,
0,
-0.62,
-10
);
ground.receiveShadow = true;
const grassPatches = [];
for (let i = 0; i < 24; i++) {
const patch = cylinder(
scene,
0.6 + random() * 1.5,
0.8 + random() * 1.8,
0.06,
7,
M.grass,
-27 + random() * 54,
-0.34,
-33 + random() * 22
);
patch.rotation.y = random() * Math.PI;
grassPatches.push(patch);
}
box(scene, 65, 0.24, 3.7, M.ballast, 0, -0.18, -2.4);
for (let x = -31; x <= 31; x += 0.92) {
box(scene, 0.22, 0.12, 2.5, M.sleeper, x, 0.0, -2.4);
}
box(scene, 65, 0.14, 0.11, M.rail, 0, 0.12, -3.02);
box(scene, 65, 0.14, 0.11, M.rail, 0, 0.12, -1.78);
// Near passenger platform.
box(scene, 46, 0.7, 8.0, M.platform, 0, 0, 2.85);
box(scene, 46, 0.12, 0.28, M.platformEdge, 0, 0.39, -1.0);
// Far platform.
box(scene, 46, 0.58, 4.0, M.stone, 0, -0.02, -5.9);
box(scene, 46, 0.1, 0.22, M.platformEdge, 0, 0.31, -4.02);
// Platform edge posts and warning markers.
for (let x = -21; x <= 21; x += 3.5) {
cylinder(scene, 0.055, 0.07, 0.75, 6, M.darkIron, x, 0.73, -0.95);
box(scene, 0.18, 0.18, 0.18, M.cream, x, 1.12, -0.95);
}
// -------------------------------------------------------------------------
// Station building and iron canopy
// -------------------------------------------------------------------------
const station = new THREE.Group();
scene.add(station);
box(station, 10.5, 4.7, 6, M.brick, -7.5, 2.45, -10.2);
box(station, 10.7, 0.22, 6.15, M.paleStone, -7.5, 0.2, -10.2);
box(station, 10.8, 0.28, 6.25, M.paleStone, -7.5, 4.82, -10.2);
gableRoof(station, 11.7, 6.8, 2.35, M.roof, -7.5, 4.95, -10.2);
// Stone corner quoins.
for (const x of [-12.45, -2.55]) {
for (let y = 0.6; y < 4.7; y += 0.65) {
box(station, 0.65, 0.48, 0.18, M.paleStone, x, y, -7.12);
}
}
// Arched entrance.
box(station, 1.75, 2.65, 0.16, M.darkIron, -7.5, 1.7, -7.12);
box(station, 1.35, 2.35, 0.18, M.glass, -7.5, 1.55, -7.01);
const entranceArch = new THREE.Mesh(
new THREE.TorusGeometry(0.72, 0.16, 6, 16, Math.PI),
M.paleStone
);
entranceArch.position.set(-7.5, 3.0, -7.0);
station.add(entranceArch);
// Station windows.
for (const x of [-10.5, -4.5]) {
box(station, 1.35, 1.6, 0.15, M.cream, x, 2.15, -7.11);
box(station, 1.08, 1.35, 0.17, M.glass, x, 2.15, -7.0);
box(station, 0.07, 1.35, 0.19, M.cream, x, 2.15, -6.9);
box(station, 1.08, 0.07, 0.19, M.cream, x, 2.15, -6.9);
}
makeSign(
station,
["MILLFORD NORTHERN", "JUNCTION · EST. 1848"],
6.5,
1.45,
-7.5,
4.1,
-7.0,
{ background: "#263c3a", color: "#e8d39c" }
);
// Clock above the entrance.
const clockGroup = new THREE.Group();
clockGroup.position.set(-7.5, 4.25, -6.94);
station.add(clockGroup);
const clockFace = cylinder(
clockGroup,
0.48,
0.48,
0.12,
16,
M.cream,
0,
0,
0
);
clockFace.rotation.x = Math.PI / 2;
const clockRim = new THREE.Mesh(
new THREE.TorusGeometry(0.49, 0.05, 6, 18),
M.darkIron
);
clockRim.position.z = 0.08;
clockGroup.add(clockRim);
box(clockGroup, 0.05, 0.31, 0.04, M.darkIron, 0, 0.1, 0.1);
box(clockGroup, 0.25, 0.045, 0.04, M.darkIron, 0.09, 0, 0.105);
// Canopy with iron columns and decorative brackets.
const canopy = new THREE.Group();
scene.add(canopy);
const canopyRoof = box(
canopy,
22,
0.16,
5.3,
M.roof,
7.3,
3.65,
-5.55
);
canopyRoof.rotation.x = -0.055;
box(canopy, 22.2, 0.18, 0.18, M.darkIron, 7.3, 3.4, -2.96);
box(canopy, 22.2, 0.18, 0.18, M.darkIron, 7.3, 3.4, -8.05);
for (const x of [-3.2, 2.2, 7.6, 13, 18.1]) {
cylinder(canopy, 0.09, 0.12, 3.3, 8, M.darkIron, x, 1.95, -4.05);
box(canopy, 0.8, 0.09, 0.09, M.darkIron, x, 3.35, -4.05);
const brace = box(
canopy,
0.08,
0.95,
0.08,
M.darkIron,
x + 0.3,
2.95,
-4.05
);
brace.rotation.z = -0.55;
}
// Platform benches.
function makeBench(x, z) {
const bench = new THREE.Group();
bench.position.set(x, 0.35, z);
scene.add(bench);
box(bench, 2.2, 0.12, 0.56, M.wood, 0, 0.62, 0);
box(bench, 2.2, 0.5, 0.1, M.wood, 0, 1.02, -0.25);
for (const xOffset of [-0.82, 0.82]) {
box(bench, 0.11, 0.68, 0.48, M.darkIron, xOffset, 0.34, 0);
box(bench, 0.11, 0.72, 0.11, M.darkIron, xOffset, 0.84, -0.24);
}
}
makeBench(-0.7, -6.0);
makeBench(12.4, -6.0);
// -------------------------------------------------------------------------
// Steam locomotive and passenger coaches
// -------------------------------------------------------------------------
const train = new THREE.Group();
scene.add(train);
function trainWheel(x, radius = 0.52) {
const wheelGroup = new THREE.Group();
wheelGroup.position.set(x, 0.58, -1.61);
train.add(wheelGroup);
const wheel = cylinder(
wheelGroup,
radius,
radius,
0.16,
12,
M.trainBlack,
0,
0,
0
);
wheel.rotation.x = Math.PI / 2;
const hub = cylinder(
wheelGroup,
0.12,
0.12,
0.2,
10,
M.brass,
0,
0,
0.01
);
hub.rotation.x = Math.PI / 2;
box(wheelGroup, radius * 1.5, 0.055, 0.19, M.iron, 0, 0, 0.02);
box(wheelGroup, 0.055, radius * 1.5, 0.19, M.iron, 0, 0, 0.02);
}
// Locomotive boiler.
const boiler = cylinder(
train,
0.73,
0.78,
4.8,
12,
M.trainGreen,
-12.4,
1.48,
-2.4
);
boiler.rotation.z = Math.PI / 2;
for (const x of [-14.15, -12.4, -10.65]) {
const band = new THREE.Mesh(
new THREE.TorusGeometry(0.755, 0.045, 6, 16),
M.brass
);
band.position.set(x, 1.48, -2.4);
band.rotation.y = Math.PI / 2;
train.add(band);
}
const front = cylinder(
train,
0.73,
0.73,
0.12,
12,
M.trainBlack,
-14.83,
1.48,
-2.4
);
front.rotation.z = Math.PI / 2;
box(train, 0.08, 0.08, 1.35, M.brass, -14.92, 1.48, -2.4);
box(train, 1.55, 0.12, 0.12, M.brass, -14.92, 1.48, -2.4);
// Chimney and dome.
cylinder(train, 0.29, 0.36, 1.2, 10, M.trainBlack, -14.1, 2.55, -2.4);
cylinder(train, 0.42, 0.32, 0.23, 10, M.trainBlack, -14.1, 3.2, -2.4);
lowSphere(train, 0.52, M.brass, -11.6, 2.23, -2.4);
// Cab.
box(train, 2.3, 2.25, 2.25, M.trainGreen, -8.95, 1.65, -2.4);
box(train, 2.55, 0.2, 2.5, M.trainBlack, -8.95, 2.88, -2.4);
box(train, 1.15, 0.85, 0.08, M.glass, -8.95, 2.0, -1.24);
box(train, 0.12, 1.05, 1.8, M.trainBlack, -7.72, 1.65, -2.4);
// Cowcatcher.
const catcher = box(train, 1.05, 0.1, 1.85, M.darkIron, -15.25, 0.52, -2.4);
catcher.rotation.x = -0.26;
for (const x of [-13.75, -11.55, -8.85]) {
trainWheel(x, x === -8.85 ? 0.62 : 0.52);
}
// Coupling rods.
box(train, 4.9, 0.09, 0.1, M.brass, -11.3, 0.58, -1.45);
// Passenger coaches.
function makeCoach(centerX, bodyMaterial) {
const coach = new THREE.Group();
coach.position.x = centerX;
train.add(coach);
box(coach, 7.2, 2.25, 2.25, bodyMaterial, 0, 1.62, -2.4);
box(coach, 7.45, 0.22, 2.5, M.trainBlack, 0, 2.83, -2.4);
box(coach, 7.5, 0.16, 2.52, M.brass, 0, 1.05, -2.4);
const windowXs = [-2.55, -1.55, 1.55, 2.55];
for (const x of windowXs) {
box(coach, 0.83, 0.83, 0.09, M.brass, x, 2.03, -1.24);
box(coach, 0.69, 0.68, 0.1, M.glass, x, 2.03, -1.18);
}
// An open doorway and steps.
box(coach, 1.05, 1.8, 0.08, M.trainBlack, 0.35, 1.45, -1.23);
box(coach, 1.25, 0.13, 0.7, M.darkIron, 0.35, 0.42, -0.96);
box(coach, 1.25, 0.13, 0.45, M.darkIron, 0.35, 0.72, -1.08);
for (const x of [-2.4, 2.4]) {
trainWheel(x, 0.48);
}
}
makeCoach(-1.65, M.trainGreen);
makeCoach(5.75, M.trainRed);
// Buffer beam.
box(train, 0.22, 0.32, 2.3, M.trainBlack, 9.55, 0.72, -2.4);
// -------------------------------------------------------------------------
// People: low-poly fictional arrivals
// -------------------------------------------------------------------------
const people = [];
function badgeTexture(number, color) {
const canvas = document.createElement("canvas");
canvas.width = 128;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.arc(64, 64, 53, 0, Math.PI * 2);
ctx.fillStyle = color;
ctx.fill();
ctx.lineWidth = 7;
ctx.strokeStyle = "#f4ead0";
ctx.stroke();
ctx.fillStyle = "#ffffff";
ctx.font = "700 62px Arial";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(String(number), 64, 67);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
}
function makeSuitcase(parent, x, z, color) {
const suitcaseMaterial = mat(color);
box(parent, 0.46, 0.3, 0.22, suitcaseMaterial, x, 0.18, z);
box(parent, 0.49, 0.035, 0.235, M.woodDark, x, 0.18, z);
box(parent, 0.07, 0.31, 0.235, M.brass, x - 0.13, 0.18, z);
const handle = new THREE.Mesh(
new THREE.TorusGeometry(0.08, 0.022, 5, 10, Math.PI),
M.woodDark
);
handle.position.set(x, 0.34, z);
handle.rotation.z = Math.PI;
parent.add(handle);
}
function makePerson(options) {
const group = new THREE.Group();
group.position.set(options.x, 0.37, options.z);
group.scale.setScalar(options.scale || 1);
scene.add(group);
const coat = mat(options.coat);
const trousers = mat(options.trousers || 0x343d42);
const skin = mat(options.skin);
const hair = mat(options.hair || 0x382b24);
const shoes = mat(0x292a29);
// Legs and shoes.
const leftLeg = new THREE.Group();
const rightLeg = new THREE.Group();
leftLeg.position.set(-0.13, 0.78, 0);
rightLeg.position.set(0.13, 0.78, 0);
group.add(leftLeg, rightLeg);
for (const leg of [leftLeg, rightLeg]) {
cylinder(leg, 0.09, 0.085, 0.59, 6, trousers, 0, -0.29, 0);
box(leg, 0.19, 0.12, 0.31, shoes, 0, -0.62, 0.07);
}
if (options.walking) {
leftLeg.rotation.z = -0.16;
rightLeg.rotation.z = 0.18;
}
// Torso and optional skirt.
cylinder(group, 0.26, 0.34, 0.72, 7, coat, 0, 1.06, 0);
box(group, 0.07, 0.63, 0.025, M.woodDark, 0, 1.05, 0.29);
if (options.skirt) {
cylinder(group, 0.25, 0.43, 0.58, 8, mat(options.skirt), 0, 0.76, 0);
}
// Head and hair.
lowSphere(group, 0.205, skin, 0, 1.61, 0);
const hairCap = lowSphere(group, 0.208, hair, 0, 1.7, -0.025);
hairCap.scale.set(1.0, 0.55, 1.0);
// Arms with pivots at the shoulders.
const leftArm = new THREE.Group();
const rightArm = new THREE.Group();
leftArm.position.set(-0.31, 1.36, 0);
rightArm.position.set(0.31, 1.36, 0);
group.add(leftArm, rightArm);
cylinder(leftArm, 0.075, 0.065, 0.55, 6, coat, 0, -0.25, 0);
cylinder(rightArm, 0.075, 0.065, 0.55, 6, coat, 0, -0.25, 0);
lowSphere(leftArm, 0.075, skin, 0, -0.55, 0);
lowSphere(rightArm, 0.075, skin, 0, -0.55, 0);
if (options.pose === "carry") {
rightArm.rotation.z = -0.72;
leftArm.rotation.z = 0.12;
} else if (options.pose === "gesture") {
rightArm.rotation.z = -0.55;
leftArm.rotation.z = 0.22;
} else {
leftArm.rotation.z = -0.1;
rightArm.rotation.z = 0.1;
}
// Hats.
if (options.hat === "brim") {
cylinder(group, 0.31, 0.31, 0.055, 10, mat(options.hatColor), 0, 1.79, 0);
cylinder(group, 0.18, 0.2, 0.22, 8, mat(options.hatColor), 0, 1.94, 0);
} else if (options.hat === "cap") {
const cap = lowSphere(group, 0.215, mat(options.hatColor), 0, 1.73, 0);
cap.scale.set(1.05, 0.55, 1.05);
box(group, 0.36, 0.035, 0.22, mat(options.hatColor), 0, 1.73, 0.18);
} else if (options.hat === "bonnet") {
lowSphere(group, 0.25, mat(options.hatColor), 0, 1.72, -0.03);
box(group, 0.35, 0.035, 0.35, mat(options.hatColor), 0, 1.68, 0.08);
}
// Luggage.
if (options.luggage === "suitcase") {
makeSuitcase(group, 0.48, 0.1, options.bagColor || 0x9b6c3f);
} else if (options.luggage === "bundle") {
const bundle = lowSphere(
group,
0.27,
mat(options.bagColor || 0xb6a277),
0.42,
0.36,
0.08
);
bundle.scale.set(1.2, 0.85, 0.9);
box(group, 0.06, 0.48, 0.48, M.woodDark, 0.42, 0.37, 0.08);
} else if (options.luggage === "basket") {
cylinder(group, 0.23, 0.17, 0.28, 8, mat(0xa67a44), 0.47, 0.2, 0.08);
const basketHandle = new THREE.Mesh(
new THREE.TorusGeometry(0.18, 0.022, 5, 10, Math.PI),
M.woodDark
);
basketHandle.position.set(0.47, 0.35, 0.08);
group.add(basketHandle);
} else if (options.luggage === "satchel") {
box(group, 0.38, 0.32, 0.17, mat(options.bagColor || 0x665044), 0.36, 0.72, 0.12);
box(group, 0.05, 0.7, 0.05, M.woodDark, 0.2, 1.08, 0.15);
} else if (options.luggage === "parcel") {
box(group, 0.38, 0.3, 0.32, mat(0xa98b62), 0.46, 0.29, 0.08);
box(group, 0.06, 0.31, 0.33, M.woodDark, 0.46, 0.29, 0.08);
} else if (options.luggage === "crate") {
box(group, 0.48, 0.35, 0.4, M.wood, 0.48, 0.22, 0.12);
box(group, 0.5, 0.055, 0.42, M.woodDark, 0.48, 0.39, 0.12);
}
// World-space number badge matching the arrivals panel.
const badge = new THREE.Sprite(
new THREE.SpriteMaterial({
map: badgeTexture(options.number, options.badgeColor),
depthTest: false,
depthWrite: false
})
);
badge.position.set(0, 2.23, 0);
badge.scale.set(0.43, 0.43, 0.43);
badge.renderOrder = 20;
group.add(badge);
people.push(group);
return group;
}
makePerson({
number: 1,
badgeColor: "#a86f45",
x: 0.2,
z: -0.05,
scale: 1.03,
coat: 0x9e633d,
trousers: 0x3e403c,
skin: 0xc58e68,
hair: 0x302722,
hat: "brim",
hatColor: 0x4d4034,
luggage: "suitcase",
bagColor: 0x98673b,
pose: "carry",
walking: true
});
makePerson({
number: 2,
badgeColor: "#87505b",
x: 2.25,
z: 0.25,
scale: 0.98,
coat: 0x743f49,
skirt: 0x5d3841,
trousers: 0x46383a,
skin: 0xe0b38f,
hair: 0x5a382a,
hat: "bonnet",
hatColor: 0x835b62,
luggage: "suitcase",
bagColor: 0x6b5849,
pose: "carry"
});
makePerson({
number: 3,
badgeColor: "#536f83",
x: 4.9,
z: 0.7,
scale: 1.08,
coat: 0x49677b,
trousers: 0x303a40,
skin: 0x9d6d50,
hair: 0x26231f,
hat: "cap",
hatColor: 0x354b55,
luggage: "bundle",
bagColor: 0xb4a17a,
pose: "carry",
walking: true
});
makePerson({
number: 4,
badgeColor: "#b18b3e",
x: 7.1,
z: 2.0,
scale: 0.83,
coat: 0xb0873d,
trousers: 0x48443b,
skin: 0xb77e5d,
hair: 0x392820,
hat: "bonnet",
hatColor: 0xc3a060,
luggage: "satchel",
bagColor: 0x6f5944,
pose: "gesture"
});
makePerson({
number: 5,
badgeColor: "#477d73",
x: 9.8,
z: 1.55,
scale: 1.0,
coat: 0x3f756c,
skirt: 0x315953,
trousers: 0x343d3a,
skin: 0x7f553f,
hair: 0x211e1b,
hat: "brim",
hatColor: 0x304c47,
luggage: "parcel",
bagColor: 0xa48862,
pose: "carry"
});
makePerson({
number: 6,
badgeColor: "#68784a",
x: -4.55,
z: 2.7,
scale: 1.02,
coat: 0x667447,
trousers: 0x363b35,
skin: 0xd09a72,
hair: 0x70462f,
hat: "cap",
hatColor: 0x505d39,
luggage: "crate",
pose: "carry",
walking: true
});
// -------------------------------------------------------------------------
// Local transport: horse-drawn carrier cart
// -------------------------------------------------------------------------
const cart = new THREE.Group();
cart.position.set(13.0, 0.37, 4.5);
scene.add(cart);
const horseBody = mat(0x6b4d39);
const horseDark = mat(0x3b2d25);
// Cart body.
box(cart, 2.8, 0.25, 1.55, M.wood, -2.05, 1.0, 0);
box(cart, 2.8, 0.65, 0.12, M.woodDark, -2.05, 1.35, -0.72);
box(cart, 2.8, 0.65, 0.12, M.wood, -2.05, 1.35, 0.72);
box(cart, 0.12, 0.65, 1.45, M.woodDark, -3.4, 1.35, 0);
box(cart, 0.12, 0.65, 1.45, M.wood, -0.7, 1.35, 0);
// Cargo.
box(cart, 0.75, 0.65, 0.75, M.cream, -2.55, 1.45, 0);
box(cart, 0.62, 0.5, 0.62, M.wood, -1.55, 1.37, 0.1);
lowSphere(cart, 0.32, M.woodDark, -0.95, 1.35, 0.05);
function cartWheel(x, z, radius = 0.7) {
const wheelGroup = new THREE.Group();
wheelGroup.position.set(x, 0.72, z);
cart.add(wheelGroup);
const rim = new THREE.Mesh(
new THREE.TorusGeometry(radius, 0.07, 6, 18),
M.darkIron
);
wheelGroup.add(rim);
for (let i = 0; i < 6; i++) {
const spoke = box(
wheelGroup,
radius * 1.8,
0.055,
0.06,
M.woodDark,
0,
0,
0
);
spoke.rotation.z = (Math.PI / 6) * i;
}
const hub = cylinder(
wheelGroup,
0.13,
0.13,
0.18,
10,
M.brass,
0,
0,
0
);
hub.rotation.x = Math.PI / 2;
}
cartWheel(-2.95, 0.82);
cartWheel(-1.15, 0.82);
cartWheel(-2.95, -0.82);
cartWheel(-1.15, -0.82);
// Shafts.
box(cart, 2.8, 0.1, 0.1, M.woodDark, 0.05, 0.95, 0.55);
box(cart, 2.8, 0.1, 0.1, M.woodDark, 0.05, 0.95, -0.55);
// Horse.
box(cart, 1.65, 0.72, 0.68, horseBody, 1.05, 1.4, 0);
box(cart, 0.65, 0.95, 0.58, horseBody, 1.72, 1.65, 0).rotation.z = -0.32;
box(cart, 0.75, 0.48, 0.46, horseBody, 2.05, 2.02, 0);
box(cart, 0.14, 0.24, 0.12, horseBody, 1.96, 2.38, 0.13);
box(cart, 0.14, 0.24, 0.12, horseBody, 1.96, 2.38, -0.13);
// Eyes and muzzle.
lowSphere(cart, 0.035, M.trainBlack, 2.18, 2.1, 0.235);
lowSphere(cart, 0.035, M.trainBlack, 2.18, 2.1, -0.235);
box(cart, 0.22, 0.17, 0.4, horseDark, 2.36, 1.91, 0);
// Horse legs.
for (const x of [0.45, 1.55]) {
for (const z of [-0.22, 0.22]) {
cylinder(cart, 0.095, 0.07, 1.05, 6, horseBody, x, 0.75, z);
box(cart, 0.2, 0.11, 0.18, horseDark, x, 0.19, z + 0.03);
}
}
// Harness and tail.
box(cart, 0.12, 1.15, 0.78, M.woodDark, 1.3, 1.4, 0);
box(cart, 0.13, 0.8, 0.13, M.woodDark, 1.95, 1.45, 0);
const tail = cylinder(cart, 0.09, 0.16, 0.85, 6, horseDark, 0.15, 1.38, 0);
tail.rotation.z = 0.65;
// -------------------------------------------------------------------------
// Station furniture, cargo, lamps, and period details
// -------------------------------------------------------------------------
function makeLamp(x, z, height = 2.7) {
const lampGroup = new THREE.Group();
lampGroup.position.set(x, 0.38, z);
scene.add(lampGroup);
cylinder(lampGroup, 0.13, 0.18, 0.22, 8, M.darkIron, 0, 0.11, 0);
cylinder(lampGroup, 0.045, 0.07, height, 8, M.darkIron, 0, height / 2, 0);
box(lampGroup, 0.32, 0.42, 0.32, M.lamp, 0, height + 0.08, 0);
box(lampGroup, 0.39, 0.08, 0.39, M.darkIron, 0, height + 0.33, 0);
box(lampGroup, 0.39, 0.08, 0.39, M.darkIron, 0, height - 0.16, 0);
const light = new THREE.PointLight(0xffbd66, 2.5, 6.5, 2);
light.position.set(0, height, 0);
lampGroup.add(light);
}
makeLamp(-2.0, -4.0, 2.65);
makeLamp(7.5, -4.0, 2.65);
makeLamp(17.0, -4.0, 2.65);
makeLamp(16.6, 0.7, 3.1);
// Coal and luggage stacks.
for (let i = 0; i < 7; i++) {
const coal = lowSphere(
scene,
0.42 + random() * 0.18,
M.coal,
-17 + random() * 1.5,
0.1,
2.1 + random() * 1.4
);
coal.scale.y = 0.65;
}
for (let i = 0; i < 5; i++) {
const crate = box(
scene,
0.72,
0.48,
0.65,
i % 2 ? M.wood : M.woodDark,
7.4 + (i % 2) * 0.76,
0.62 + Math.floor(i / 2) * 0.49,
-5.2
);
crate.rotation.y = (random() - 0.5) * 0.16;
}
// Milk cans and barrels.
for (let i = 0; i < 3; i++) {
cylinder(scene, 0.16, 0.2, 0.5, 8, M.iron, 5.0 + i * 0.5, 0.64, -5.7);
cylinder(scene, 0.11, 0.16, 0.12, 8, M.iron, 5.0 + i * 0.5, 0.94, -5.7);
}
for (let i = 0; i < 2; i++) {
cylinder(scene, 0.35, 0.35, 0.8, 10, M.wood, 12.2 + i * 0.85, 0.78, -5.8);
for (const y of [0.52, 1.02]) {
const band = new THREE.Mesh(
new THREE.TorusGeometry(0.355, 0.035, 5, 12),
M.darkIron
);
band.rotation.x = Math.PI / 2;
band.position.set(12.2 + i * 0.85, y, -5.8);
scene.add(band);
}
}
// A freestanding arrivals board.
const arrivalBoard = new THREE.Group();
arrivalBoard.position.set(3.3, 0, -5.25);
scene.add(arrivalBoard);
box(arrivalBoard, 0.12, 2.05, 0.12, M.darkIron, -1.3, 1.4, 0);
box(arrivalBoard, 0.12, 2.05, 0.12, M.darkIron, 1.3, 1.4, 0);
makeSign(
arrivalBoard,
["NORTH LINE ARRIVALS", "MILLFORD · 6 IN · FOUNDRY ROAD"],
3.2,
1.25,
0,
2.15,
0.04,
{ background: "#35423b", color: "#ead5a3" }
);
// -------------------------------------------------------------------------
// Industrial skyline
// -------------------------------------------------------------------------
const city = new THREE.Group();
scene.add(city);
function makeFactory(x, z, width, depth, height, color) {
const factoryMaterial = mat(color);
box(city, width, height, depth, factoryMaterial, x, height / 2, z);
gableRoof(
city,
width + 0.4,
depth + 0.4,
Math.min(1.6, height * 0.25),
M.roof,
x,
height,
z
);
// Tall factory windows.
const columns = Math.max(2, Math.floor(width / 1.7));
for (let i = 0; i < columns; i++) {
const wx = x - width / 2 + 1.1 + i * ((width - 2.2) / (columns - 1));
box(city, 0.65, 1.4, 0.08, M.glass, wx, height * 0.58, z + depth / 2 + 0.05);
}
}
makeFactory(3.8, -20.3, 8.5, 7.0, 5.3, 0x65594e);
makeFactory(11.6, -21.3, 8.0, 7.8, 6.6, M.brickDark);
makeFactory(18.5, -22.2, 7.2, 6.5, 4.7, 0x6e6355);
makeFactory(-15.5, -22.0, 8.2, 7.2, 5.8, M.brick);
makeSign(
city,
["HARTWELL MILLS", "WOOL · YARN · CLOTH"],
5.2,
1.15,
10.8,
5.25,
-17.35,
{ background: "#55352f", color: "#e3c994" }
);
// Factory chimneys.
function makeChimney(x, z, height) {
cylinder(city, 0.48, 0.78, height, 10, M.brickDark, x, height / 2, z);
cylinder(city, 0.58, 0.58, 0.22, 10, M.darkIron, x, height, z);
cylinder(city, 0.58, 0.58, 0.22, 10, M.darkIron, x, height - 0.25, z);
}
makeChimney(8.0, -24.1, 11.5);
makeChimney(15.3, -24.8, 13.0);
makeChimney(-12.2, -25.2, 9.5);
// Distant silhouettes.
for (let i = 0; i < 16; i++) {
const height = 2.5 + random() * 4.5;
box(
city,
2.2 + random() * 2.8,
height,
3.5 + random() * 3,
mat(i % 3 === 0 ? 0x67685f : 0x59635f),
-27 + i * 3.7,
height / 2,
-29 - random() * 5
);
}
// Water tower.
const towerLegs = new THREE.Group();
towerLegs.position.set(-13.0, 0, -14.4);
scene.add(towerLegs);
for (const x of [-0.8, 0.8]) {
for (const z of [-0.8, 0.8]) {
box(towerLegs, 0.15, 4.8, 0.15, M.darkIron, x, 2.4, z);
}
}
cylinder(towerLegs, 1.25, 1.25, 2.1, 10, M.wood, 0, 5.1, 0);
cylinder(towerLegs, 0, 1.35, 0.85, 10, M.roof, 0, 6.55, 0);
// Trees.
function makeTree(x, z, scale = 1) {
const tree = new THREE.Group();
tree.position.set(x, -0.3, z);
tree.scale.setScalar(scale);
scene.add(tree);
cylinder(tree, 0.18, 0.25, 2.2, 6, M.trunk, 0, 1.1, 0);
const crown = lowSphere(tree, 1.1, M.leaf, 0, 2.7, 0);
crown.scale.set(1, 1.15, 1);
const side = lowSphere(tree, 0.75, M.leafLight, 0.65, 2.4, 0.1);
side.scale.set(1, 0.9, 1);
}
makeTree(-19, -8, 1.2);
makeTree(-21, -12, 0.9);
makeTree(21, -11, 1.1);
makeTree(23, -14, 0.8);
makeTree(-20, 7, 1.0);
makeTree(22, 9, 1.2);
// -------------------------------------------------------------------------
// Smoke system
// -------------------------------------------------------------------------
const smokePuffs = [];
function addSmokeEmitter(x, y, z, count, speed, color, spread) {
for (let i = 0; i < count; i++) {
const puffMaterial = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.38,
depthWrite: false
});
const puff = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.34 + random() * 0.16, 1),
puffMaterial
);
puff.position.set(x, y, z);
puff.castShadow = false;
scene.add(puff);
smokePuffs.push({
mesh: puff,
phase: random(),
speed,
baseX: x,
baseY: y,
baseZ: z,
driftX: (random() - 0.5) * spread,
driftZ: (random() - 0.5) * spread,
rise: 4.0 + random() * 2.5
});
}
}
addSmokeEmitter(-14.1, 3.4, -2.4, 12, 0.18, 0xe3dfd4, 1.0);
addSmokeEmitter(8.0, 11.8, -24.1, 8, 0.085, 0x747b78, 2.0);
addSmokeEmitter(15.3, 13.3, -24.8, 9, 0.075, 0x6f7774, 2.4);
addSmokeEmitter(-12.2, 9.8, -25.2, 7, 0.09, 0x7a807b, 2.0);
// -------------------------------------------------------------------------
// Sky details
// -------------------------------------------------------------------------
const sunDisk = new THREE.Mesh(
new THREE.IcosahedronGeometry(3.2, 2),
new THREE.MeshBasicMaterial({ color: 0xf2d39a, fog: false })
);
sunDisk.position.set(-27, 22, -44);
scene.add(sunDisk);
function makeCloud(x, y, z, scale) {
const cloud = new THREE.Group();
cloud.position.set(x, y, z);
cloud.scale.setScalar(scale);
scene.add(cloud);
const cloudMaterial = new THREE.MeshBasicMaterial({
color: 0xe5e7de,
fog: false
});
for (let i = 0; i < 5; i++) {
const puff = new THREE.Mesh(
new THREE.DodecahedronGeometry(1.2 + random() * 0.7, 0),
cloudMaterial
);
puff.position.set(i * 1.45 - 2.8, random() * 0.6, random() * 0.6);
puff.scale.y = 0.55;
cloud.add(puff);
}
}
makeCloud(-16, 14, -39, 1.6);
makeCloud(15, 17, -43, 2.0);
makeCloud(28, 12, -36, 1.3);
// -------------------------------------------------------------------------
// Direct camera controls: drag, wheel, and keyboard
// -------------------------------------------------------------------------
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
cameraState.theta -= dx * 0.005;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.004,
0.34,
1.46
);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (
event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.025,
12,
58
);
updateCamera();
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
const key = event.key;
let handled = true;
if (key === "ArrowLeft") {
cameraState.theta += 0.08;
} else if (key === "ArrowRight") {
cameraState.theta -= 0.08;
} else if (key === "ArrowUp") {
cameraState.phi = Math.max(0.34, cameraState.phi - 0.06);
} else if (key === "ArrowDown") {
cameraState.phi = Math.min(1.46, cameraState.phi + 0.06);
} else if (key === "+" || key === "=") {
cameraState.radius = Math.max(12, cameraState.radius - 1.5);
} else if (key === "-" || key === "_") {
cameraState.radius = Math.min(58, cameraState.radius + 1.5);
} else {
handled = false;
}
if (handled) {
event.preventDefault();
updateCamera();
}
});
function resetView() {
cameraState.target.set(-1, 1.2, -1.5);
cameraState.radius = 31;
cameraState.theta = 0.68;
cameraState.phi = 1.11;
updateCamera();
}
document.getElementById("reset-view").addEventListener("click", resetView);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
for (const puff of smokePuffs) {
const age = (puff.phase + elapsed * puff.speed) % 1;
puff.mesh.position.set(
puff.baseX + puff.driftX * age,
puff.baseY + age * puff.rise,
puff.baseZ + puff.driftZ * age
);
const scale = 0.65 + age * 1.65;
puff.mesh.scale.setScalar(scale);
puff.mesh.material.opacity = Math.sin(age * Math.PI) * 0.38;
puff.mesh.rotation.x = age * 0.8;
puff.mesh.rotation.z = age * 0.5;
}
// Very slight life in the scene without making the station feel busy.
people[0].position.y = 0.37 + Math.sin(elapsed * 1.6) * 0.012;
people[3].rotation.y = Math.sin(elapsed * 0.55) * 0.025;
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("hidden");
});
</script>
</body>
</html>
```