Prompt specification
Build or customize the Three.js 3D scene "Family arrival at an urban railway platform" 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: Family arrival at an urban railway platform
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/family-arrival-at-an-urban-railway-platform-x2586
Scene Description Prompt:
A low-poly Great Migration arrival vignette with a fictional family, household belongings, and relatives meeting on an urban platform. One HTML file, Three.js from cdnjs.
Working Three.js Starter (family-arrival-at-an-urban-railway-platform-x2586):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="description"
content="A low-poly fictional Great Migration arrival scene at Chicago Union Station."
/>
<title>The Ellis Family Arrives — A Great Migration Vignette</title>
<style>
:root {
--ink: #28241f;
--paper: #f4ead8;
--paper-soft: rgba(244, 234, 216, 0.92);
--gold: #d6a65c;
--rust: #9f4f35;
--teal: #477c78;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #817f7a;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene.dragging {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
background:
radial-gradient(
circle at 50% 48%,
transparent 45%,
rgba(38, 31, 24, 0.12) 78%,
rgba(30, 25, 21, 0.3) 100%
);
mix-blend-mode: multiply;
}
.grain {
position: fixed;
inset: 0;
z-index: 3;
pointer-events: none;
opacity: 0.055;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.65'/%3E%3C/svg%3E");
}
.story-card {
position: fixed;
top: 22px;
left: 22px;
z-index: 5;
width: min(405px, calc(100vw - 44px));
padding: 21px 23px 19px;
border: 1px solid rgba(255, 255, 255, 0.52);
border-radius: 4px;
background: var(--paper-soft);
box-shadow: 0 18px 50px rgba(36, 29, 23, 0.2);
backdrop-filter: blur(9px);
}
.kicker {
margin: 0 0 8px;
color: var(--rust);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 4vw, 42px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.025em;
}
.place {
display: block;
margin-top: 10px;
color: #6f6254;
font-size: 12px;
font-weight: 750;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.story-card p:not(.kicker):not(.place) {
margin: 15px 0 0;
color: #4f473e;
font-family: Georgia, "Times New Roman", serif;
font-size: 15px;
line-height: 1.47;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 15px;
margin-top: 16px;
padding-top: 13px;
border-top: 1px solid rgba(65, 52, 42, 0.17);
color: #63584c;
font-size: 11px;
font-weight: 700;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 7px;
}
.legend i {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--rust);
box-shadow: 0 0 0 3px rgba(159, 79, 53, 0.13);
}
.legend .relatives i {
background: var(--teal);
box-shadow: 0 0 0 3px rgba(71, 124, 120, 0.14);
}
.controls {
position: fixed;
top: 22px;
right: 22px;
z-index: 6;
display: flex;
gap: 7px;
padding: 7px;
border: 1px solid rgba(255, 255, 255, 0.5);
border-radius: 5px;
background: rgba(244, 234, 216, 0.9);
box-shadow: 0 14px 35px rgba(36, 29, 23, 0.18);
backdrop-filter: blur(9px);
}
button {
min-width: 36px;
height: 36px;
padding: 0 11px;
border: 1px solid rgba(72, 58, 45, 0.2);
border-radius: 3px;
background: rgba(255, 252, 244, 0.7);
color: #3f382f;
font: inherit;
font-size: 12px;
font-weight: 750;
cursor: pointer;
transition: background 150ms ease, transform 150ms ease;
}
button:hover {
background: #fffaf0;
transform: translateY(-1px);
}
button:focus-visible {
outline: 2px solid var(--rust);
outline-offset: 2px;
}
button.primary {
border-color: #83422f;
background: var(--rust);
color: #fff7e9;
}
button.primary:hover {
background: #b55a3b;
}
.chapter {
position: fixed;
bottom: 24px;
left: 50%;
z-index: 5;
width: min(620px, calc(100vw - 36px));
padding: 15px 19px 14px;
transform: translateX(-50%);
border: 1px solid rgba(255, 255, 255, 0.44);
border-radius: 4px;
background: rgba(42, 38, 33, 0.83);
color: #fff7e9;
box-shadow: 0 16px 45px rgba(26, 21, 17, 0.24);
backdrop-filter: blur(9px);
}
.chapter-top {
display: flex;
align-items: center;
gap: 12px;
}
.chapter-number {
flex: 0 0 auto;
color: var(--gold);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.17em;
text-transform: uppercase;
}
#chapterText {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(15px, 2.3vw, 20px);
line-height: 1.25;
}
.progress-track {
height: 2px;
margin-top: 12px;
overflow: hidden;
background: rgba(255, 255, 255, 0.15);
}
#progress {
width: 0;
height: 100%;
background: var(--gold);
transition: width 100ms linear;
}
.hint {
position: fixed;
right: 23px;
bottom: 25px;
z-index: 5;
color: rgba(255, 248, 235, 0.82);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
text-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
pointer-events: none;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #d2b995;
color: #3d3328;
transition: opacity 600ms ease, visibility 600ms ease;
}
#loading.hidden {
opacity: 0;
visibility: hidden;
}
.loading-inner {
text-align: center;
}
.loading-mark {
width: 48px;
height: 48px;
margin: 0 auto 15px;
border: 2px solid rgba(61, 51, 40, 0.2);
border-top-color: var(--rust);
border-radius: 50%;
animation: spin 900ms linear infinite;
}
#loading p {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 17px;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@media (max-width: 760px) {
.story-card {
top: 12px;
left: 12px;
width: min(340px, calc(100vw - 24px));
padding: 15px 16px 14px;
}
.story-card p:not(.kicker):not(.place) {
display: none;
}
.legend {
margin-top: 11px;
padding-top: 10px;
}
.controls {
top: auto;
right: 12px;
bottom: 98px;
flex-wrap: wrap;
justify-content: flex-end;
max-width: 178px;
}
.controls button {
padding: 0 9px;
}
.chapter {
bottom: 12px;
width: calc(100vw - 24px);
}
.hint {
display: none;
}
}
@media (prefers-reduced-motion: reduce) {
.loading-mark {
animation: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive low-poly railway platform scene"></canvas>
<div class="vignette"></div>
<div class="grain"></div>
<section class="story-card" aria-labelledby="title">
<p class="kicker">The Great Migration · A fictional family</p>
<h1 id="title">The Ellis family arrives</h1>
<span class="place">Chicago Union Station · 1938</span>
<p>
Ada and Samuel Ellis have brought Mae and Thomas north from Alabama.
Ada’s sister Beatrice, and her husband Alfred, wait beside the arrival gate.
</p>
<div class="legend" aria-label="Character color key">
<span><i></i> Ellis family</span>
<span class="relatives"><i></i> Carter relatives</span>
</div>
</section>
<nav class="controls" aria-label="Scene controls">
<button id="replay" class="primary" type="button" title="Replay the arrival">
Replay
</button>
<button id="pause" type="button" title="Pause or resume the vignette">
Pause
</button>
<button id="zoomIn" type="button" aria-label="Zoom in">+</button>
<button id="zoomOut" type="button" aria-label="Zoom out">−</button>
<button id="reset" type="button" title="Reset camera view">
Reset view
</button>
</nav>
<section class="chapter" aria-live="polite">
<div class="chapter-top">
<span id="chapterNumber" class="chapter-number">Chapter 01</span>
<p id="chapterText">The evening train reaches Union Station.</p>
</div>
<div class="progress-track" aria-hidden="true">
<div id="progress"></div>
</div>
</section>
<div class="hint">DRAG TO ORBIT · SCROLL TO ZOOM · R TO RESET</div>
<div id="loading">
<div class="loading-inner">
<div class="loading-mark"></div>
<p>Preparing the platform…</p>
</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const loading = document.querySelector("#loading");
const chapterText = document.querySelector("#chapterText");
const chapterNumber = document.querySelector("#chapterNumber");
const progressBar = document.querySelector("#progress");
const pauseButton = document.querySelector("#pause");
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight, false);
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(0xbca98e);
scene.fog = new THREE.Fog(0xc7b49b, 28, 66);
const camera = new THREE.PerspectiveCamera(
39,
window.innerWidth / window.innerHeight,
0.1,
120
);
const cameraState = {
target: new THREE.Vector3(0, 1.05, 0),
yaw: 0.36,
pitch: 0.43,
distance: 22,
dragging: false,
pointerX: 0,
pointerY: 0
};
const hemi = new THREE.HemisphereLight(0xffdfae, 0x58636a, 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffd39a, 3.25);
sun.position.set(-13, 20, 13);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -25;
sun.shadow.camera.right = 25;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 65;
sun.shadow.bias = -0.0003;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x91b9c1, 0.65);
fill.position.set(15, 8, -12);
scene.add(fill);
let seed = 1938;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
function smoothstep(edge0, edge1, value) {
const t = clamp((value - edge0) / (edge1 - edge0), 0, 1);
return t * t * (3 - 2 * t);
}
function standardMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.84,
metalness: 0,
flatShading: true,
...options
});
}
const materials = {
platform: standardMaterial(0x8f887c),
platformEdge: standardMaterial(0xc4b99e),
concrete: standardMaterial(0x817b72),
darkConcrete: standardMaterial(0x5d5a55),
iron: standardMaterial(0x344442, { roughness: 0.62 }),
trainGreen: standardMaterial(0x244d48),
trainTrim: standardMaterial(0xc6b485),
trainRoof: standardMaterial(0x343b3a),
trainBlack: standardMaterial(0x292a29),
brass: standardMaterial(0xb58b45, { metalness: 0.38, roughness: 0.48 }),
wood: standardMaterial(0x76513b),
woodLight: standardMaterial(0x9b704d),
basket: standardMaterial(0xb1844e),
leather: standardMaterial(0x724333),
cream: standardMaterial(0xe5d7b7),
lamp: standardMaterial(0xf3c774, {
emissive: 0xe7a949,
emissiveIntensity: 1.1
})
};
function addMesh(
geometry,
material,
x = 0,
y = 0,
z = 0,
parent = scene
) {
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 addBox(w, h, d, material, x, y, z, parent = scene) {
return addMesh(
new THREE.BoxGeometry(w, h, d),
material,
x,
y,
z,
parent
);
}
function addCylinder(
topRadius,
bottomRadius,
height,
segments,
material,
x,
y,
z,
parent = scene
) {
return addMesh(
new THREE.CylinderGeometry(
topRadius,
bottomRadius,
height,
segments
),
material,
x,
y,
z,
parent
);
}
function makeCanvasTexture(width, height, draw) {
const c = document.createElement("canvas");
c.width = width;
c.height = height;
const context = c.getContext("2d");
draw(context, width, height);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
// Evening sky.
const skyTexture = makeCanvasTexture(8, 512, (ctx, w, h) => {
const gradient = ctx.createLinearGradient(0, 0, 0, h);
gradient.addColorStop(0, "#617989");
gradient.addColorStop(0.45, "#9c9b91");
gradient.addColorStop(0.76, "#dfb384");
gradient.addColorStop(1, "#e9c59a");
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, w, h);
});
const sky = addMesh(
new THREE.PlaneGeometry(85, 38),
new THREE.MeshBasicMaterial({
map: skyTexture,
fog: false,
depthWrite: false
}),
0,
10,
-32
);
sky.castShadow = false;
sky.receiveShadow = false;
const sunDisc = addMesh(
new THREE.CircleGeometry(2.2, 24),
new THREE.MeshBasicMaterial({
color: 0xf3c27f,
fog: false,
depthWrite: false
}),
-14,
8.8,
-30
);
sunDisc.castShadow = false;
// Distant low-poly city.
const cityGroup = new THREE.Group();
scene.add(cityGroup);
const buildingColors = [
0x6d7474,
0x79756e,
0x5e6d70,
0x82776d,
0x727b78
];
const windowMaterials = [
standardMaterial(0xd2b36f, {
emissive: 0xb47d39,
emissiveIntensity: 0.28
}),
standardMaterial(0x4d5b5c)
];
for (let i = 0; i < 13; i++) {
const width = 2.5 + random() * 2.3;
const depth = 3 + random() * 3;
const height = 4 + random() * 8;
const x = -25 + i * 4.15 + random() * 0.7;
const z = -15 - random() * 5;
const building = addBox(
width,
height,
depth,
standardMaterial(buildingColors[i % buildingColors.length]),
x,
height / 2,
z,
cityGroup
);
const roof = addBox(
width + 0.12,
0.25,
depth + 0.12,
materials.darkConcrete,
x,
height + 0.1,
z,
cityGroup
);
roof.castShadow = false;
const columns = Math.max(2, Math.floor(width / 0.75));
const rows = Math.max(2, Math.floor(height / 1.15));
for (let row = 0; row < rows; row++) {
for (let column = 0; column < columns; column++) {
if (random() > 0.72) continue;
addBox(
0.22,
0.37,
0.035,
windowMaterials[random() > 0.27 ? 0 : 1],
x - width / 2 + 0.45 + column * (width - 0.8) / columns,
0.7 + row * 0.95,
z + depth / 2 + 0.025,
cityGroup
);
}
}
}
// A few low-poly clouds.
const cloudMaterial = standardMaterial(0xc8c4b8);
for (let i = 0; i < 5; i++) {
const cloud = new THREE.Group();
cloud.position.set(-25 + i * 11 + random() * 4, 12 + random() * 3, -24);
scene.add(cloud);
for (let j = 0; j < 4; j++) {
const puff = addMesh(
new THREE.DodecahedronGeometry(1.5 + random() * 0.7, 0),
cloudMaterial,
j * 1.5,
random() * 0.35,
random() * 0.7,
cloud
);
puff.scale.set(1.5, 0.55, 0.75);
puff.castShadow = false;
}
}
// Platform and paving.
addBox(37, 0.65, 9, materials.platform, 0, -0.34, 1.5);
addBox(37, 0.17, 0.28, materials.platformEdge, 0, 0.02, -2.82);
const pavingTexture = makeCanvasTexture(512, 512, (ctx, w, h) => {
ctx.fillStyle = "#a39b8e";
ctx.fillRect(0, 0, w, h);
ctx.strokeStyle = "rgba(58, 54, 49, 0.25)";
ctx.lineWidth = 2;
for (let x = 0; x <= w; x += 64) {
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, h);
ctx.stroke();
}
for (let y = 0; y <= h; y += 64) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(w, y);
ctx.stroke();
}
for (let i = 0; i < 1100; i++) {
const shade = Math.floor(95 + random() * 80);
ctx.fillStyle = `rgba(${shade},${shade},${shade},0.12)`;
ctx.fillRect(random() * w, random() * h, 1 + random() * 2, 1);
}
});
pavingTexture.wrapS = THREE.RepeatWrapping;
pavingTexture.wrapT = THREE.RepeatWrapping;
pavingTexture.repeat.set(12, 3);
const paving = addMesh(
new THREE.PlaneGeometry(36.8, 8.8),
standardMaterial(0xffffff, { map: pavingTexture }),
0,
0.008,
1.5
);
paving.rotation.x = -Math.PI / 2;
paving.castShadow = false;
// Track bed and rails.
addBox(45, 0.35, 4.4, materials.darkConcrete, 0, -0.64, -5.05);
addBox(45, 0.14, 0.18, materials.trainBlack, 0, -0.38, -4.25);
addBox(45, 0.14, 0.18, materials.trainBlack, 0, -0.38, -5.85);
for (let x = -22; x <= 22; x += 1.15) {
addBox(0.24, 0.12, 2.2, materials.wood, x, -0.44, -5.05);
}
// Passenger coaches.
function createCoach(x) {
const coach = new THREE.Group();
coach.position.x = x;
coach.position.z = -5.05;
scene.add(coach);
addBox(9.55, 2.45, 3, materials.trainGreen, 0, 1.48, 0, coach);
addBox(9.82, 0.38, 3.28, materials.trainRoof, 0, 2.78, 0, coach);
addBox(9.7, 0.16, 3.12, materials.trainTrim, 0, 0.47, 0, coach);
addBox(9.68, 0.12, 3.12, materials.trainTrim, 0, 2.5, 0, coach);
const glass = standardMaterial(0xe0c17f, {
emissive: 0xd99c45,
emissiveIntensity: 0.5,
roughness: 0.42
});
for (let i = 0; i < 7; i++) {
const wx = -3.75 + i * 1.25;
addBox(0.87, 0.84, 0.06, materials.trainBlack, wx, 1.72, 1.53, coach);
addBox(0.73, 0.66, 0.07, glass, wx, 1.72, 1.57, coach);
}
for (const doorX of [-4.55, 4.55]) {
addBox(0.72, 1.78, 0.08, materials.trainBlack, doorX, 1.35, 1.54, coach);
addBox(0.46, 0.7, 0.09, glass, doorX, 1.83, 1.59, coach);
addBox(0.05, 0.45, 0.08, materials.brass, doorX + 0.23, 1.12, 1.6, coach);
}
for (const wheelX of [-3.25, -1.1, 1.1, 3.25]) {
const wheel = addCylinder(
0.37,
0.37,
0.22,
10,
materials.trainBlack,
wheelX,
0.18,
1.53,
coach
);
wheel.rotation.x = Math.PI / 2;
}
}
createCoach(-12);
createCoach(-2.1);
createCoach(7.8);
// Locomotive.
const locomotive = new THREE.Group();
locomotive.position.set(17.2, 0, -5.05);
scene.add(locomotive);
addBox(3.4, 2.7, 3.05, materials.trainGreen, -1.25, 1.65, 0, locomotive);
addBox(3.55, 0.3, 3.18, materials.trainRoof, -1.25, 3.05, 0, locomotive);
const boiler = addCylinder(
0.86,
0.86,
3.8,
10,
materials.trainBlack,
1.2,
1.4,
0,
locomotive
);
boiler.rotation.z = Math.PI / 2;
addCylinder(0.3, 0.4, 1.35, 8, materials.trainBlack, 0.5, 2.85, 0, locomotive);
addCylinder(0.48, 0.3, 0.28, 8, materials.brass, 0.5, 3.55, 0, locomotive);
const headlight = addCylinder(
0.25,
0.25,
0.15,
10,
materials.lamp,
3.15,
1.55,
0,
locomotive
);
headlight.rotation.z = Math.PI / 2;
for (const wheelX of [-1.9, 0, 2.35]) {
const wheel = addCylinder(
0.53,
0.53,
0.28,
10,
materials.trainBlack,
wheelX,
0.27,
1.48,
locomotive
);
wheel.rotation.x = Math.PI / 2;
}
// Platform canopy.
const canopy = new THREE.Group();
scene.add(canopy);
addBox(15, 0.24, 5.3, materials.iron, 9.2, 5.12, 3.6, canopy);
addBox(15.15, 0.3, 0.25, materials.brass, 9.2, 4.94, 5.17, canopy);
for (const x of [2.2, 7.3, 12.4, 16.2]) {
addCylinder(0.12, 0.16, 4.9, 8, materials.iron, x, 2.47, 5.15, canopy);
addBox(0.55, 0.13, 0.55, materials.darkConcrete, x, 0.08, 5.15, canopy);
}
for (let x = 3; x < 16; x += 1.4) {
const brace = addBox(0.08, 0.1, 4.8, materials.iron, x, 4.92, 3.7, canopy);
brace.rotation.z = -0.08;
}
// Station sign.
const stationSignTexture = makeCanvasTexture(1024, 256, (ctx, w, h) => {
ctx.fillStyle = "#203d3b";
ctx.fillRect(0, 0, w, h);
ctx.strokeStyle = "#c9a45f";
ctx.lineWidth = 9;
ctx.strokeRect(14, 14, w - 28, h - 28);
ctx.textAlign = "center";
ctx.fillStyle = "#f1dfb8";
ctx.font = "700 76px Georgia";
ctx.fillText("CHICAGO", w / 2, 112);
ctx.font = "700 34px Arial";
ctx.letterSpacing = "8px";
ctx.fillText("UNION STATION", w / 2, 180);
});
addBox(6.5, 1.62, 0.14, materials.iron, 8.2, 4.15, 4.15, canopy);
const stationSign = addMesh(
new THREE.PlaneGeometry(6.35, 1.52),
new THREE.MeshStandardMaterial({
map: stationSignTexture,
roughness: 0.75
}),
8.2,
4.15,
4.23,
canopy
);
stationSign.castShadow = false;
addCylinder(0.035, 0.035, 0.66, 6, materials.brass, 6.3, 4.94, 4.2, canopy);
addCylinder(0.035, 0.035, 0.66, 6, materials.brass, 10.1, 4.94, 4.2, canopy);
// Benches and their luggage.
function createBench(x, z) {
const bench = new THREE.Group();
bench.position.set(x, 0, z);
scene.add(bench);
for (let i = 0; i < 4; i++) {
addBox(3.1, 0.12, 0.2, materials.woodLight, 0, 0.58, -0.42 + i * 0.25, bench);
}
for (let i = 0; i < 3; i++) {
addBox(3.1, 0.17, 0.11, materials.woodLight, 0, 0.88 + i * 0.26, -0.63, bench);
}
for (const bx of [-1.15, 1.15]) {
addBox(0.12, 0.62, 0.12, materials.iron, bx, 0.28, 0.12, bench);
addBox(0.12, 1.4, 0.12, materials.iron, bx, 0.82, -0.65, bench);
}
}
createBench(7.3, 4.2);
createBench(13.1, 4.2);
function createTrunk(width, depth, height, color, x, y, z, parent = scene) {
const group = new THREE.Group();
group.position.set(x, y, z);
parent.add(group);
const bodyMaterial = standardMaterial(color);
addBox(width, height, depth, bodyMaterial, 0, height / 2, 0, group);
addBox(width + 0.02, 0.09, depth + 0.02, materials.leather, 0, height * 0.34, 0, group);
addBox(width + 0.02, 0.09, depth + 0.02, materials.leather, 0, height * 0.72, 0, group);
for (const sx of [-width * 0.28, width * 0.28]) {
addBox(0.06, height + 0.02, depth + 0.025, materials.leather, sx, height / 2, 0, group);
}
return group;
}
createTrunk(0.9, 0.55, 0.65, 0x785239, 9.55, 0, 3.1);
createTrunk(0.68, 0.48, 0.42, 0x49665b, 9.55, 0.65, 3.1);
addCylinder(
0.34,
0.34,
0.3,
10,
materials.cream,
10.17,
0.15,
3.2
);
addCylinder(
0.36,
0.36,
0.06,
10,
materials.leather,
10.17,
0.32,
3.2
);
// Platform lamps.
function createLamp(x, z, withLight = false) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
addCylinder(0.055, 0.075, 3.3, 8, materials.iron, 0, 1.65, 0, group);
addBox(0.42, 0.09, 0.42, materials.iron, 0, 0.06, 0, group);
addBox(0.42, 0.65, 0.42, materials.lamp, 0, 3.25, 0, group);
addCylinder(0.3, 0.18, 0.25, 4, materials.iron, 0, 3.68, 0, group);
if (withLight) {
const light = new THREE.PointLight(0xffbd67, 8, 8, 2);
light.position.set(0, 3.1, 0);
group.add(light);
}
}
createLamp(-13.8, 4.7);
createLamp(-6.3, 4.7, true);
createLamp(1.1, 4.7);
createLamp(17.4, 4.7, true);
// Low-poly steam puffs.
const steamPuffs = [];
for (let i = 0; i < 8; i++) {
const material = new THREE.MeshStandardMaterial({
color: 0xe7dfce,
transparent: true,
opacity: 0.3,
depthWrite: false,
roughness: 1,
flatShading: true
});
const puff = addMesh(
new THREE.DodecahedronGeometry(0.55, 0),
material,
17.7,
4,
-5
);
puff.castShadow = false;
steamPuffs.push(puff);
}
// Human figures.
function createSuitcase(color = 0x78513c, scale = 1) {
const group = new THREE.Group();
group.scale.setScalar(scale);
addBox(0.66, 0.42, 0.26, standardMaterial(color), 0, -0.34, 0, group);
addBox(0.7, 0.055, 0.285, materials.leather, 0, -0.34, 0, group);
for (const x of [-0.2, 0.2]) {
addBox(0.045, 0.45, 0.285, materials.leather, x, -0.34, 0, group);
addBox(0.035, 0.14, 0.035, materials.brass, x, -0.04, 0, group);
}
addBox(0.28, 0.035, 0.035, materials.leather, 0, -0.04, 0, group);
return group;
}
function createBasket() {
const group = new THREE.Group();
addCylinder(0.25, 0.2, 0.4, 8, materials.basket, 0, -0.24, 0, group);
addCylinder(0.26, 0.26, 0.05, 8, materials.woodLight, 0, -0.42, 0, group);
const bundle = addMesh(
new THREE.IcosahedronGeometry(0.24, 1),
standardMaterial(0xb2a58b),
0.04,
0.02,
0,
group
);
bundle.scale.set(1, 0.7, 0.85);
const cloth = addBox(
0.34,
0.08,
0.29,
standardMaterial(0x8e4d3c),
-0.03,
0.14,
0,
group
);
cloth.rotation.z = 0.18;
return group;
}
function createHatbox() {
const group = new THREE.Group();
addCylinder(0.23, 0.23, 0.3, 10, materials.cream, 0, -0.19, 0, group);
addCylinder(0.25, 0.25, 0.055, 10, standardMaterial(0x76523d), 0, -0.04, 0, group);
addCylinder(0.25, 0.25, 0.055, 10, standardMaterial(0x76523d), 0, -0.34, 0, group);
return group;
}
function createPerson(options) {
const root = new THREE.Group();
scene.add(root);
const skin = standardMaterial(options.skin);
const shirt = standardMaterial(options.shirt);
const trousers = standardMaterial(options.pants);
const hair = standardMaterial(options.hair || 0x241d18);
const shoes = standardMaterial(0x302c29);
const female = options.style === "female";
const child = options.style === "child";
// Torso.
if (female) {
addCylinder(0.31, 0.39, 0.78, 7, shirt, 0, 1.2, 0, root);
addMesh(
new THREE.ConeGeometry(0.53, 0.72, 8),
options.skirt || shirt,
0,
0.47,
0,
root
);
} else {
addCylinder(0.34, 0.41, 0.82, 7, shirt, 0, 1.23, 0, root);
}
if (options.coat) {
addBox(0.73, 0.68, 0.48, shirt, 0, 1.22, 0.02, root);
addBox(0.045, 0.58, 0.03, standardMaterial(options.coat), -0.12, 1.24, 0.275, root);
addBox(0.045, 0.58, 0.03, standardMaterial(options.coat), 0.12, 1.24, 0.275, root);
}
// Head and facial planes.
const head = new THREE.Group();
head.position.y = 1.94;
root.add(head);
addMesh(new THREE.IcosahedronGeometry(0.27, 1), skin, 0, 0, 0, head);
if (options.scarf) {
addMesh(
new THREE.SphereGeometry(
0.292,
7,
4,
0,
Math.PI * 2,
0,
Math.PI * 0.58
),
standardMaterial(options.scarf),
0,
0.015,
0,
head
);
const knot = addMesh(
new THREE.IcosahedronGeometry(0.105, 0),
standardMaterial(options.scarf),
0,
0.13,
-0.24,
head
);
knot.scale.set(1, 0.8, 0.7);
} else {
addMesh(
new THREE.SphereGeometry(
0.285,
7,
4,
0,
Math.PI * 2,
0,
Math.PI * 0.53
),
hair,
0,
0.015,
0,
head
);
}
if (options.hat) {
addCylinder(0.39, 0.39, 0.045, 10, options.hat, 0, 0.235, 0, head);
addCylinder(0.235, 0.265, 0.18, 8, options.hat, 0, 0.32, 0, head);
addCylinder(
0.27,
0.27,
0.055,
10,
options.hatBand || materials.leather,
0,
0.255,
0,
head
);
}
if (options.bun) {
const bun = addMesh(
new THREE.IcosahedronGeometry(0.14, 1),
hair,
0,
0.24,
-0.16,
head
);
bun.scale.set(1, 0.85, 0.9);
}
if (options.braids) {
for (const side of [-1, 1]) {
addCylinder(
0.065,
0.08,
0.42,
6,
hair,
side * 0.23,
-0.18,
-0.04,
head
);
}
}
const eyeMaterial = standardMaterial(0x211b17);
addMesh(
new THREE.SphereGeometry(0.022, 5, 4),
eyeMaterial,
-0.073,
0.018,
0.248,
head
);
addMesh(
new THREE.SphereGeometry(0.022, 5, 4),
eyeMaterial,
0.073,
0.018,
0.248,
head
);
const nose = addMesh(
new THREE.ConeGeometry(0.035, 0.075, 4),
skin,
0,
-0.015,
0.268,
head
);
nose.rotation.x = Math.PI / 2;
addBox(0.075, 0.014, 0.025, standardMaterial(0x6d3b32), 0, -0.105, 0.247, head);
// Arms.
const leftArm = new THREE.Group();
const rightArm = new THREE.Group();
leftArm.position.set(-0.41, 1.49, 0);
rightArm.position.set(0.41, 1.49, 0);
root.add(leftArm, rightArm);
for (const arm of [leftArm, rightArm]) {
addCylinder(
0.105,
0.125,
0.56,
6,
options.sleeves || shirt,
0,
-0.28,
0,
arm
);
addMesh(
new THREE.IcosahedronGeometry(0.115, 0),
skin,
0,
-0.62,
0,
arm
);
}
// Legs.
const leftLeg = new THREE.Group();
const rightLeg = new THREE.Group();
leftLeg.position.set(-0.16, 0.75, 0);
rightLeg.position.set(0.16, 0.75, 0);
root.add(leftLeg, rightLeg);
for (const leg of [leftLeg, rightLeg]) {
addCylinder(
child ? 0.13 : 0.15,
child ? 0.15 : 0.17,
0.62,
6,
trousers,
0,
-0.31,
0,
leg
);
addBox(
child ? 0.2 : 0.23,
0.13,
0.34,
shoes,
0,
-0.67,
0.06,
leg
);
}
if (options.scale) root.scale.setScalar(options.scale);
root.userData.parts = {
leftArm,
rightArm,
leftLeg,
rightLeg
};
return root;
}
// Ada Ellis: mustard cardigan, rust skirt, basket and suitcase.
const ada = createPerson({
skin: 0x754b32,
hair: 0x211a15,
shirt: 0xc69238,
sleeves: 0xc69238,
skirt: 0x8e4435,
pants: 0x503a31,
style: "female",
bun: true
});
const adaBasket = createBasket();
adaBasket.position.set(0, -0.68, 0.04);
ada.userData.parts.leftArm.add(adaBasket);
const adaCase = createSuitcase(0x704637);
adaCase.position.set(0, -0.69, 0.04);
ada.userData.parts.rightArm.add(adaCase);
// Samuel Ellis: work shirt, suspenders and a valise.
const samuel = createPerson({
skin: 0x6d432d,
hair: 0x211c18,
shirt: 0xded2b4,
sleeves: 0xded2b4,
pants: 0x4a5150,
hat: 0x4b4740,
hatBand: 0x282725,
style: "male"
});
addBox(0.075, 0.75, 0.045, materials.leather, -0.19, 1.24, 0.33, samuel);
addBox(0.075, 0.75, 0.045, materials.leather, 0.19, 1.24, 0.33, samuel);
const samuelValise = createSuitcase(0x4b4c43, 0.9);
samuelValise.position.set(0, -0.69, 0.04);
samuel.userData.parts.leftArm.add(samuelValise);
// Mae Ellis, carrying a hatbox.
const mae = createPerson({
skin: 0x805238,
hair: 0x2a201a,
shirt: 0xb9553d,
sleeves: 0xb9553d,
skirt: 0x7c3e32,
pants: 0x665043,
style: "female",
braids: true,
scale: 0.82
});
const maeHatbox = createHatbox();
maeHatbox.position.set(0, -0.7, 0.04);
mae.userData.parts.rightArm.add(maeHatbox);
// Thomas Ellis with a small parcel.
const thomas = createPerson({
skin: 0x794d33,
hair: 0x241c16,
shirt: 0x527a87,
sleeves: 0x527a87,
pants: 0x504944,
hat: 0x765d43,
style: "child",
scale: 0.69
});
const parcel = addBox(
0.34,
0.3,
0.25,
standardMaterial(0x9b7448),
0,
-0.72,
0.08,
thomas.userData.parts.rightArm
);
parcel.rotation.z = -0.08;
addBox(0.05, 0.31, 0.26, standardMaterial(0x6c4d38), 0, -0.72, 0.08, thomas.userData.parts.rightArm);
// Beatrice Carter, Ada's sister.
const beatrice = createPerson({
skin: 0x70442e,
hair: 0x251b16,
shirt: 0x397a75,
sleeves: 0x397a75,
skirt: 0x285b59,
pants: 0x433d37,
scarf: 0xa14d3b,
style: "female"
});
// Alfred Carter.
const alfred = createPerson({
skin: 0x623b29,
hair: 0x1f1a17,
shirt: 0x5a5147,
sleeves: 0x5a5147,
pants: 0x383d3d,
hat: 0x343632,
hatBand: 0x292824,
coat: 0x393531,
style: "male"
});
const umbrella = addCylinder(
0.035,
0.035,
1.2,
7,
materials.leather,
0,
-0.65,
0.07,
alfred.userData.parts.leftArm
);
umbrella.rotation.z = 0.08;
// Character positions and movement plans.
const walkerInfo = {
ada: { start: 0.35, end: 6.55, startX: -13.2, endX: -1.4, z: -0.55 },
samuel: { start: 0.75, end: 6.9, startX: -14.1, endX: -3.15, z: 0.85 },
mae: { start: 1.05, end: 7.15, startX: -11.2, endX: -0.45, z: 0.45 },
thomas: { start: 1.35, end: 7.4, startX: -10.0, endX: 0.45, z: 1.48 }
};
const people = [
{ root: ada, info: walkerInfo.ada, phase: 0.3, kind: "ada" },
{ root: samuel, info: walkerInfo.samuel, phase: 1.8, kind: "samuel" },
{ root: mae, info: walkerInfo.mae, phase: 3.1, kind: "mae" },
{ root: thomas, info: walkerInfo.thomas, phase: 4.4, kind: "thomas" },
{ root: beatrice, phase: 2.2, kind: "beatrice" },
{ root: alfred, phase: 4.7, kind: "alfred" }
];
for (const person of people) {
const { root } = person;
const parts = root.userData.parts;
parts.leftArm.rotation.order = "YXZ";
parts.rightArm.rotation.order = "YXZ";
parts.leftLeg.rotation.order = "YXZ";
parts.rightLeg.rotation.order = "YXZ";
}
ada.rotation.y = Math.PI / 2;
samuel.rotation.y = Math.PI / 2;
mae.rotation.y = Math.PI / 2;
thomas.rotation.y = Math.PI / 2;
beatrice.rotation.y = -Math.PI / 2;
alfred.rotation.y = -Math.PI / 2;
function resetPose(person) {
const { leftArm, rightArm, leftLeg, rightLeg } = person.root.userData.parts;
leftArm.rotation.set(0, 0, 0);
rightArm.rotation.set(0, 0, 0);
leftLeg.rotation.set(0, 0, 0);
rightLeg.rotation.set(0, 0, 0);
}
function updatePeople(time) {
const reunion = smoothstep(8.25, 10.15, time);
for (const person of people) {
resetPose(person);
const { root, info, phase, kind } = person;
const parts = root.userData.parts;
let x = info ? info.endX : (kind === "beatrice" ? 1.55 : 2.85);
let z = info ? info.z : (kind === "beatrice" ? 0.45 : -0.45);
let walking = 0;
let walkPhase = 0;
if (info) {
const progress = smoothstep(info.start, info.end, time);
x = THREE.MathUtils.lerp(info.startX, info.endX, progress);
walking =
time > info.start && time < info.end
? Math.sin(
Math.PI *
clamp((time - info.start) / (info.end - info.start), 0, 1)
)
: 0;
walkPhase = (time - info.start) * 7.2 + phase;
}
if (kind === "ada") {
x += reunion * 0.58;
z += reunion * 0.08;
}
if (kind === "beatrice") {
x -= reunion * 0.58;
z += reunion * 0.05;
}
root.position.x = x;
root.position.z = z;
root.position.y =
Math.abs(Math.sin(walkPhase)) * 0.038 * walking +
Math.sin(time * 1.45 + phase) * 0.008;
parts.leftLeg.rotation.x = Math.sin(walkPhase) * 0.55 * walking;
parts.rightLeg.rotation.x = -Math.sin(walkPhase) * 0.55 * walking;
parts.leftArm.rotation.x = 0.04 + Math.sin(walkPhase) * 0.27 * walking;
parts.rightArm.rotation.x = -0.04 - Math.sin(walkPhase) * 0.27 * walking;
// Gestures begin as the family notices the waiting relatives.
const earlyWave =
smoothstep(2.0, 3.0, time) * (1 - smoothstep(6.4, 7.8, time));
if (kind === "mae") {
parts.rightArm.rotation.z = earlyWave * 1.85;
parts.rightArm.rotation.x += Math.sin(time * 8) * 0.08 * earlyWave;
}
if (kind === "thomas") {
parts.rightArm.rotation.z = earlyWave * 1.35;
}
if (kind === "alfred") {
parts.rightArm.rotation.z = earlyWave * 1.95;
parts.rightArm.rotation.x += Math.sin(time * 7.5) * 0.06 * earlyWave;
}
if (kind === "beatrice") {
parts.rightArm.rotation.z = earlyWave * 2.15;
parts.rightArm.rotation.x += Math.sin(time * 8.5) * 0.09 * earlyWave;
parts.leftArm.rotation.x = -1.25 * reunion;
parts.rightArm.rotation.x = -1.25 * reunion;
parts.rightArm.rotation.z *= 1 - reunion;
}
if (kind === "ada") {
parts.leftArm.rotation.x = -1.16 * reunion;
parts.rightArm.rotation.x = -1.24 * reunion;
}
if (reunion > 0.02) {
root.rotation.y += (kind === "ada" ? 1 : -1) * reunion * 0.07;
}
}
}
// Fine airborne dust catches the warm light.
const dustPositions = new Float32Array(180 * 3);
for (let i = 0; i < 180; i++) {
dustPositions[i * 3] = -18 + random() * 36;
dustPositions[i * 3 + 1] = 0.4 + random() * 5.2;
dustPositions[i * 3 + 2] = -2 + random() * 8;
}
const dustGeometry = new THREE.BufferGeometry();
dustGeometry.setAttribute(
"position",
new THREE.BufferAttribute(dustPositions, 3)
);
const dust = new THREE.Points(
dustGeometry,
new THREE.PointsMaterial({
color: 0xf5dfb4,
size: 0.035,
transparent: true,
opacity: 0.32,
depthWrite: false
})
);
scene.add(dust);
function updateSteam(time) {
steamPuffs.forEach((puff, index) => {
const life = (time * 0.24 + index / steamPuffs.length) % 1;
puff.position.set(
17.7 + life * 0.7 + Math.sin(index * 2.4) * 0.08,
3.95 + life * 5.1,
-5.05 + Math.cos(index * 1.7) * 0.1
);
const size = 0.55 + life * 1.2;
puff.scale.set(size, size * 0.76, size * 0.72);
puff.material.opacity = Math.sin(life * Math.PI) * 0.27;
});
dust.rotation.y = time * 0.008;
dust.position.y = Math.sin(time * 0.18) * 0.1;
}
// Custom camera controls, implemented without addons.
function updateCamera() {
const cp = Math.cos(cameraState.pitch);
camera.position.set(
cameraState.target.x +
cameraState.distance * Math.sin(cameraState.yaw) * cp,
cameraState.target.y + cameraState.distance * Math.sin(cameraState.pitch),
cameraState.target.z +
cameraState.distance * Math.cos(cameraState.yaw) * cp
);
camera.lookAt(cameraState.target);
}
function resetCamera() {
cameraState.yaw = 0.36;
cameraState.pitch = 0.43;
cameraState.distance = 22;
updateCamera();
}
canvas.addEventListener("pointerdown", (event) => {
cameraState.dragging = true;
cameraState.pointerX = event.clientX;
cameraState.pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.classList.add("dragging");
});
canvas.addEventListener("pointermove", (event) => {
if (!cameraState.dragging) return;
const dx = event.clientX - cameraState.pointerX;
const dy = event.clientY - cameraState.pointerY;
cameraState.pointerX = event.clientX;
cameraState.pointerY = event.clientY;
cameraState.yaw -= dx * 0.006;
cameraState.pitch = clamp(
cameraState.pitch - dy * 0.005,
0.12,
1.15
);
});
function endDrag(event) {
cameraState.dragging = false;
canvas.classList.remove("dragging");
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.distance = clamp(
cameraState.distance + event.deltaY * 0.012,
10,
34
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetCamera);
window.addEventListener("keydown", (event) => {
const key = event.key.toLowerCase();
if (key === "arrowleft") cameraState.yaw += 0.08;
if (key === "arrowright") cameraState.yaw -= 0.08;
if (key === "arrowup") {
cameraState.pitch = clamp(cameraState.pitch + 0.06, 0.12, 1.15);
}
if (key === "arrowdown") {
cameraState.pitch = clamp(cameraState.pitch - 0.06, 0.12, 1.15);
}
if (key === "+" || key === "=") {
cameraState.distance = clamp(cameraState.distance - 1.2, 10, 34);
}
if (key === "-" || key === "_") {
cameraState.distance = clamp(cameraState.distance + 1.2, 10, 34);
}
if (key === "r") resetCamera();
});
document.querySelector("#zoomIn").addEventListener("click", () => {
cameraState.distance = clamp(cameraState.distance - 2, 10, 34);
});
document.querySelector("#zoomOut").addEventListener("click", () => {
cameraState.distance = clamp(cameraState.distance + 2, 10, 34);
});
document.querySelector("#reset").addEventListener("click", resetCamera);
let arrivalTime = reducedMotion ? 10.8 : 0;
let paused = false;
let currentChapter = -1;
document.querySelector("#replay").addEventListener("click", () => {
arrivalTime = 0;
paused = false;
pauseButton.textContent = "Pause";
});
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Resume" : "Pause";
});
const chapters = [
{
end: 2.1,
number: "Chapter 01",
text: "The evening train reaches Union Station."
},
{
end: 6.8,
number: "Chapter 02",
text: "Four travelers, one bundle of futures."
},
{
end: 9.2,
number: "Chapter 03",
text: "A familiar silhouette waits beyond the platform."
},
{
end: Infinity,
number: "Chapter 04",
text: "Home begins with a hand held out."
}
];
function updateChapter() {
let index = chapters.findIndex((chapter) => arrivalTime < chapter.end);
if (index < 0) index = chapters.length - 1;
if (index !== currentChapter) {
currentChapter = index;
chapterNumber.textContent = chapters[index].number;
chapterText.textContent = chapters[index].text;
}
progressBar.style.width = `${clamp((arrivalTime / 11.5) * 100, 0, 100)}%`;
}
function onResize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height, false);
}
window.addEventListener("resize", onResize);
resetCamera();
updatePeople(arrivalTime);
updateSteam(arrivalTime);
updateChapter();
renderer.render(scene, camera);
requestAnimationFrame(() => {
loading.classList.add("hidden");
});
let previousTime = performance.now();
function animate(now) {
requestAnimationFrame(animate);
const delta = Math.min((now - previousTime) / 1000, 0.05);
previousTime = now;
if (!paused) arrivalTime += delta;
updatePeople(arrivalTime);
updateSteam(arrivalTime);
updateChapter();
updateCamera();
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```