Prompt specification
Build or customize the Three.js 3D scene "Synchronized boarding announcement" 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: Synchronized boarding announcement
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/synchronized-boarding-announcement-x0410
Scene Description Prompt:
Synchronized boarding announcement. Trigger a station event that updates a display, flashes a platform marker, and moves a speaker icon; all channels identify the same destination simultaneously. Please build this with Three.js from cdnjs in one self-contained HTML file, using low-poly forms.
Working Three.js Starter (synchronized-boarding-announcement-x0410):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Northline — Synchronized Boarding Station</title>
<style>
:root {
--accent: #f7c948;
--ink: #071522;
--panel: rgba(7, 21, 34, 0.82);
--line: rgba(255, 255, 255, 0.13);
--muted: #91a5b5;
--white: #f5f8fa;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #071522;
color: var(--white);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
select,
input {
font: inherit;
}
#stage {
position: fixed;
inset: 0;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#stage canvas.dragging {
cursor: grabbing;
}
.topbar {
position: fixed;
z-index: 5;
top: 22px;
left: 24px;
right: 24px;
display: flex;
align-items: flex-start;
justify-content: space-between;
pointer-events: none;
}
.brand {
display: flex;
align-items: center;
gap: 13px;
padding: 12px 15px 12px 12px;
border: 1px solid var(--line);
border-radius: 14px;
background: rgba(5, 17, 28, 0.68);
box-shadow: 0 12px 35px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(14px);
}
.brand-mark {
position: relative;
width: 34px;
height: 34px;
border: 2px solid var(--accent);
border-radius: 8px;
transform: rotate(-8deg);
transition: border-color 200ms ease;
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
left: 6px;
right: 6px;
height: 3px;
border-radius: 4px;
background: var(--accent);
transition: background-color 200ms ease;
}
.brand-mark::before {
top: 8px;
}
.brand-mark::after {
bottom: 8px;
}
.brand h1 {
margin: 0;
font-size: 14px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.brand p {
margin: 3px 0 0;
color: var(--muted);
font-size: 11px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.system-status {
display: flex;
align-items: center;
gap: 9px;
padding: 12px 15px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(5, 17, 28, 0.72);
color: #c5d1d9;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
backdrop-filter: blur(14px);
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
transition: background-color 200ms ease;
}
.system-status.live .status-dot {
animation: statusPulse 700ms ease-in-out infinite alternate;
}
@keyframes statusPulse {
to {
transform: scale(1.55);
box-shadow: 0 0 18px var(--accent);
}
}
.control-panel {
position: fixed;
z-index: 6;
top: 91px;
right: 24px;
width: 320px;
padding: 19px;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(18px);
}
.eyebrow {
margin: 0 0 7px;
color: var(--accent);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.control-panel h2 {
margin: 0 0 7px;
font-size: 21px;
line-height: 1.15;
}
.control-panel > p {
margin: 0 0 17px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.field-label {
display: block;
margin-bottom: 7px;
color: #b7c6d1;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.11em;
text-transform: uppercase;
}
select {
width: 100%;
height: 46px;
padding: 0 38px 0 13px;
border: 1px solid rgba(255, 255, 255, 0.17);
border-radius: 10px;
outline: none;
background:
linear-gradient(45deg, transparent 50%, var(--accent) 50%) calc(100% - 18px) 20px / 5px 5px no-repeat,
linear-gradient(135deg, var(--accent) 50%, transparent 50%) calc(100% - 13px) 20px / 5px 5px no-repeat,
rgba(255, 255, 255, 0.055);
color: var(--white);
font-weight: 700;
appearance: none;
}
select:focus {
border-color: var(--accent);
}
.trigger {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
height: 50px;
margin-top: 13px;
padding: 0 15px;
border: 0;
border-radius: 11px;
background: var(--accent);
color: #101820;
font-weight: 900;
letter-spacing: 0.025em;
cursor: pointer;
box-shadow: 0 9px 26px color-mix(in srgb, var(--accent) 22%, transparent);
transition:
transform 150ms ease,
filter 150ms ease;
}
.trigger:hover {
transform: translateY(-1px);
filter: brightness(1.07);
}
.trigger:active {
transform: translateY(1px);
}
.trigger.is-live {
animation: triggerPulse 700ms ease-in-out infinite alternate;
}
@keyframes triggerPulse {
to {
filter: brightness(1.16);
box-shadow: 0 10px 34px color-mix(in srgb, var(--accent) 40%, transparent);
}
}
.trigger-symbol {
display: grid;
place-items: center;
width: 28px;
height: 28px;
border-radius: 8px;
background: rgba(0, 0, 0, 0.12);
font-size: 16px;
}
.sound-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 15px;
padding-top: 14px;
border-top: 1px solid var(--line);
color: #b7c6d1;
font-size: 12px;
}
.sound-row label {
display: flex;
align-items: center;
gap: 9px;
cursor: pointer;
}
.sound-row input {
width: 16px;
height: 16px;
accent-color: var(--accent);
}
kbd {
padding: 4px 7px;
border: 1px solid rgba(255, 255, 255, 0.17);
border-bottom-width: 2px;
border-radius: 5px;
background: rgba(255, 255, 255, 0.055);
color: #8296a6;
font: 9px ui-monospace, SFMono-Regular, Menlo, monospace;
}
.channel-panel {
position: fixed;
z-index: 6;
left: 24px;
bottom: 24px;
width: min(430px, calc(100vw - 48px));
overflow: hidden;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--panel);
box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(18px);
}
.channel-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 15px 17px;
border-bottom: 1px solid var(--line);
}
.channel-header strong {
font-size: 11px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.one-clock {
padding: 5px 8px;
border-radius: 999px;
background: color-mix(in srgb, var(--accent) 12%, transparent);
color: var(--accent);
font-size: 9px;
font-weight: 900;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.channel-row {
display: grid;
grid-template-columns: 28px minmax(0, 1fr) auto;
gap: 10px;
align-items: center;
padding: 11px 17px;
border-bottom: 1px solid rgba(255, 255, 255, 0.065);
}
.channel-index {
display: grid;
place-items: center;
width: 26px;
height: 26px;
border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
border-radius: 8px;
color: var(--accent);
font: 800 10px ui-monospace, SFMono-Regular, Menlo, monospace;
}
.channel-name {
min-width: 0;
}
.channel-name b {
display: block;
font-size: 12px;
}
.channel-name small {
display: block;
margin-top: 2px;
overflow: hidden;
color: var(--muted);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.08em;
text-overflow: ellipsis;
text-transform: uppercase;
white-space: nowrap;
}
.channel-value {
max-width: 145px;
overflow: hidden;
color: var(--accent);
font-size: 12px;
font-weight: 850;
text-align: right;
text-overflow: ellipsis;
white-space: nowrap;
}
.progress-track {
height: 3px;
background: rgba(255, 255, 255, 0.06);
}
.progress-bar {
width: 0;
height: 100%;
background: var(--accent);
box-shadow: 0 0 12px var(--accent);
}
.view-hint {
position: fixed;
z-index: 4;
right: 25px;
bottom: 25px;
color: rgba(210, 225, 235, 0.65);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
pointer-events: none;
}
.toast {
position: fixed;
z-index: 10;
top: 90px;
left: 50%;
max-width: calc(100vw - 40px);
padding: 11px 16px;
border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
border-radius: 999px;
background: rgba(5, 17, 28, 0.9);
color: var(--white);
font-size: 12px;
font-weight: 750;
opacity: 0;
transform: translate(-50%, -10px);
transition:
opacity 180ms ease,
transform 180ms ease;
pointer-events: none;
backdrop-filter: blur(12px);
}
.toast.visible {
opacity: 1;
transform: translate(-50%, 0);
}
.loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: #071522;
color: #aab8c3;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
transition: opacity 400ms ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 720px) {
.topbar {
top: 12px;
left: 12px;
right: 12px;
}
.brand p,
.system-status span:last-child,
.view-hint {
display: none;
}
.control-panel {
top: 78px;
left: 12px;
right: 12px;
width: auto;
padding: 15px;
}
.control-panel > p {
display: none;
}
.control-panel h2 {
font-size: 17px;
}
.channel-panel {
left: 12px;
right: 12px;
bottom: 12px;
width: auto;
}
.channel-row {
grid-template-columns: 26px minmax(0, 1fr) auto;
padding: 8px 12px;
}
.channel-name small {
display: none;
}
.channel-value {
max-width: 112px;
font-size: 11px;
}
.toast {
top: 232px;
}
}
</style>
</head>
<body>
<main id="app">
<div id="stage" aria-label="Interactive low-poly railway station scene"></div>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<h1>Northline / Station 03</h1>
<p>Passenger information system</p>
</div>
</div>
<div class="system-status" id="systemStatus">
<span class="status-dot" aria-hidden="true"></span>
<span id="systemStatusText">System ready</span>
</div>
</header>
<section class="control-panel" aria-label="Station event controls">
<p class="eyebrow">Station Event</p>
<h2>Boarding announcement</h2>
<p>
One destination is dispatched to the station display, platform marker,
and moving speaker on the same event clock.
</p>
<label class="field-label" for="destinationSelect">Destination</label>
<select id="destinationSelect">
<option value="Harbor Point">Harbor Point</option>
<option value="Cedar Square">Cedar Square</option>
<option value="Northgate">Northgate</option>
<option value="Airport Central">Airport Central</option>
<option value="Old Town">Old Town</option>
</select>
<button class="trigger" id="triggerButton" type="button">
<span id="triggerLabel">Trigger boarding event</span>
<span class="trigger-symbol" aria-hidden="true">▶</span>
</button>
<div class="sound-row">
<label for="soundToggle">
<input id="soundToggle" type="checkbox" checked />
Speak the announcement
</label>
<kbd>SPACE</kbd>
</div>
</section>
<section class="channel-panel" aria-label="Synchronized channel monitor">
<div class="channel-header">
<strong>Synchronized channels</strong>
<span class="one-clock">One event clock</span>
</div>
<div class="channel-row">
<span class="channel-index">01</span>
<div class="channel-name">
<b>Station display</b>
<small id="displayStatus">Waiting for event</small>
</div>
<strong class="channel-value" id="displayChannel">—</strong>
</div>
<div class="channel-row">
<span class="channel-index">02</span>
<div class="channel-name">
<b>Platform marker</b>
<small id="platformStatus">Waiting for event</small>
</div>
<strong class="channel-value" id="platformChannel">—</strong>
</div>
<div class="channel-row">
<span class="channel-index">03</span>
<div class="channel-name">
<b>Audio speaker</b>
<small id="audioStatus">Waiting for event</small>
</div>
<strong class="channel-value" id="audioChannel">—</strong>
</div>
<div class="progress-track" aria-hidden="true">
<div class="progress-bar" id="progressBar"></div>
</div>
</section>
<div class="view-hint">Drag to orbit · Wheel to zoom · Double-click to reset</div>
<div class="toast" id="toast" role="status" aria-live="polite"></div>
<div class="loading" id="loading">Building station…</div>
</main>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// UI and shared event state
// ------------------------------------------------------------
const stage = document.getElementById("stage");
const destinationSelect = document.getElementById("destinationSelect");
const triggerButton = document.getElementById("triggerButton");
const triggerLabel = document.getElementById("triggerLabel");
const soundToggle = document.getElementById("soundToggle");
const progressBar = document.getElementById("progressBar");
const systemStatus = document.getElementById("systemStatus");
const systemStatusText = document.getElementById("systemStatusText");
const toast = document.getElementById("toast");
const channelValues = [
document.getElementById("displayChannel"),
document.getElementById("platformChannel"),
document.getElementById("audioChannel")
];
const displayStatus = document.getElementById("displayStatus");
const platformStatus = document.getElementById("platformStatus");
const audioStatus = document.getElementById("audioStatus");
const destinationStyles = {
"Harbor Point": "#f7c948",
"Cedar Square": "#63d7bd",
"Northgate": "#ff8b68",
"Airport Central": "#79c8ff",
"Old Town": "#c7b4ff"
};
const EVENT_DURATION = 3.2;
const SPEAKER_START_X = -5.25;
const SPEAKER_END_X = 4.2;
let eventActive = false;
let eventStart = -100;
let currentDestination = "";
let speechActive = false;
let toastTimer = 0;
function showToast(message) {
clearTimeout(toastTimer);
toast.textContent = message;
toast.classList.add("visible");
toastTimer = window.setTimeout(() => {
toast.classList.remove("visible");
}, 2600);
}
// ------------------------------------------------------------
// Renderer, scene, camera, and lights
// ------------------------------------------------------------
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;
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x071522);
scene.fog = new THREE.Fog(0x071522, 15, 34);
const camera = new THREE.PerspectiveCamera(
39,
window.innerWidth / window.innerHeight,
0.1,
80
);
const cameraView = {
yaw: 0.48,
pitch: 0.31,
radius: window.innerWidth < 720 ? 19 : 16,
target: new THREE.Vector3(0, 2.45, -0.15)
};
function updateCamera() {
const cosPitch = Math.cos(cameraView.pitch);
camera.position.set(
cameraView.target.x +
cameraView.radius * Math.sin(cameraView.yaw) * cosPitch,
cameraView.target.y + cameraView.radius * Math.sin(cameraView.pitch),
cameraView.target.z +
cameraView.radius * Math.cos(cameraView.yaw) * cosPitch
);
camera.lookAt(cameraView.target);
}
updateCamera();
const hemisphere = new THREE.HemisphereLight(0xb8ddff, 0x17202c, 2.1);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffedce, 3.4);
sun.position.set(7, 12, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -15;
sun.shadow.camera.right = 15;
sun.shadow.camera.top = 14;
sun.shadow.camera.bottom = -10;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 38;
sun.shadow.bias = -0.00035;
scene.add(sun);
const rimLight = new THREE.DirectionalLight(0x5bc9ff, 1.4);
rimLight.position.set(-8, 6, -8);
scene.add(rimLight);
// ------------------------------------------------------------
// Low-poly scene helpers
// ------------------------------------------------------------
function standardMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.76,
metalness: 0.04,
flatShading: true,
...options
});
}
function addBox(parent, size, position, material, castShadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const materials = {
platform: standardMaterial(0x304252),
platformEdge: standardMaterial(0xd9b53f),
platformDark: standardMaterial(0x162733),
steel: standardMaterial(0x61717b, { metalness: 0.45, roughness: 0.4 }),
darkSteel: standardMaterial(0x17242e, { metalness: 0.45, roughness: 0.46 }),
train: standardMaterial(0xd7e1e2),
trainStripe: standardMaterial(0xdc6255),
trainRoof: standardMaterial(0x778a94),
window: standardMaterial(0x153e53, {
metalness: 0.35,
roughness: 0.22,
emissive: 0x0a2534,
emissiveIntensity: 0.45
}),
boardFrame: standardMaterial(0x263946, {
metalness: 0.4,
roughness: 0.38
}),
speaker: standardMaterial(0xf3a62e),
speakerDark: standardMaterial(0x1c2830),
concrete: standardMaterial(0x53626b),
bench: standardMaterial(0x82664a)
};
// Ground and platform
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(60, 45),
standardMaterial(0x101c25)
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.64;
ground.receiveShadow = true;
scene.add(ground);
addBox(
scene,
[22, 0.55, 7],
[0, -0.32, 1.05],
materials.platform
);
addBox(
scene,
[22, 0.08, 0.18],
[0, 0.005, -2.22],
materials.platformEdge
);
for (let x = -10; x <= 10; x += 1.25) {
addBox(
scene,
[0.025, 0.018, 6.7],
[x, -0.025, 1.1],
materials.platformDark,
false
);
}
// Track bed and rails
addBox(
scene,
[42, 0.16, 3.5],
[0, -0.56, -4.85],
materials.platformDark
);
addBox(
scene,
[42, 0.12, 0.13],
[0, -0.43, -5.85],
materials.steel
);
addBox(
scene,
[42, 0.12, 0.13],
[0, -0.43, -3.85],
materials.steel
);
for (let x = -18; x <= 18; x += 1.1) {
addBox(
scene,
[0.24, 0.09, 2.7],
[x, -0.48, -4.85],
materials.bench,
false
);
}
// Canopy beams and columns
addBox(
scene,
[18, 0.24, 0.28],
[0, 6.45, -1.75],
materials.steel
);
addBox(
scene,
[18, 0.13, 0.15],
[0, 5.95, -1.75],
materials.darkSteel
);
for (const x of [-7.2, 7.2]) {
addBox(
scene,
[0.27, 6.35, 0.27],
[x, 2.72, -1.75],
materials.steel
);
addBox(
scene,
[0.58, 0.16, 0.58],
[x, -0.02, -1.75],
materials.concrete
);
}
// Low-poly train
const train = new THREE.Group();
train.position.set(-2.6, 0, -4.85);
scene.add(train);
addBox(train, [11.2, 2.25, 2.15], [0, 1.02, 0], materials.train);
addBox(train, [11.35, 0.28, 2.02], [0, 2.25, -0.03], materials.trainRoof);
addBox(train, [11.24, 0.32, 2.17], [0, 0.25, 0], materials.trainStripe);
addBox(train, [10.8, 0.25, 1.85], [0, 2.48, -0.04], materials.darkSteel);
for (let x = -4.55; x <= 4.55; x += 1.55) {
addBox(
train,
[1.16, 0.92, 0.07],
[x, 1.42, 1.095],
materials.window,
false
);
addBox(
train,
[0.07, 0.07, 0.08],
[x, 1.42, 1.145],
materials.steel,
false
);
}
for (const x of [-4.2, 4.2]) {
addBox(
train,
[0.13, 1.88, 0.08],
[x, 1.08, 1.12],
materials.trainStripe,
false
);
}
for (const x of [-3.7, 3.7]) {
for (const z of [-1.08, 1.08]) {
const wheel = new THREE.Mesh(
new THREE.CylinderGeometry(0.36, 0.36, 0.18, 10),
materials.darkSteel
);
wheel.rotation.x = Math.PI / 2;
wheel.position.set(x, -0.12, z);
wheel.castShadow = true;
train.add(wheel);
}
}
// Bench
const bench = new THREE.Group();
bench.position.set(-7.5, 0, 2.2);
scene.add(bench);
addBox(bench, [2.3, 0.16, 0.65], [0, 0.55, 0], materials.bench);
addBox(bench, [2.3, 0.58, 0.12], [0, 0.92, -0.28], materials.bench);
addBox(bench, [0.14, 0.6, 0.52], [-0.78, 0.23, 0], materials.darkSteel);
addBox(bench, [0.14, 0.6, 0.52], [0.78, 0.23, 0], materials.darkSteel);
// Low-poly passengers
function addPassenger(x, z, shirtColor, rotation = 0, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
scene.add(group);
const shirt = standardMaterial(shirtColor);
const trousers = standardMaterial(0x172331);
const skin = standardMaterial(0xb98268);
addBox(group, [0.17, 0.62, 0.19], [-0.14, 0.27, 0], trousers);
addBox(group, [0.17, 0.62, 0.19], [0.14, 0.27, 0], trousers);
const torso = new THREE.Mesh(
new THREE.CylinderGeometry(0.25, 0.35, 0.86, 6),
shirt
);
torso.position.y = 1.0;
torso.castShadow = true;
group.add(torso);
const head = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.23, 0),
skin
);
head.position.y = 1.67;
head.castShadow = true;
group.add(head);
addBox(group, [0.14, 0.65, 0.16], [-0.32, 0.92, 0], shirt);
addBox(group, [0.14, 0.65, 0.16], [0.32, 0.92, 0], shirt);
}
addPassenger(-6.2, 2.7, 0x4c9b88, 0.4, 0.95);
addPassenger(-3.8, 3.0, 0xc16b58, -0.25, 1.05);
addPassenger(2.7, 2.6, 0x6686ae, 0.6, 0.94);
addPassenger(7.1, 2.9, 0xc89c42, -0.7, 1.02);
// ------------------------------------------------------------
// Canvas textures for all information channels
// ------------------------------------------------------------
function makeCanvas(width, height) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
return {
canvas,
context: canvas.getContext("2d")
};
}
function roundedRect(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + width - r, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + r);
ctx.lineTo(x + width, y + height - r);
ctx.quadraticCurveTo(
x + width,
y + height,
x + width - r,
y + height
);
ctx.lineTo(x + r, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function fitText(ctx, text, maxWidth, startingSize, weight = 800) {
let size = startingSize;
let family = "system-ui, -apple-system, Segoe UI, sans-serif";
do {
ctx.font = `${weight} ${size}px ${family}`;
if (ctx.measureText(text).width <= maxWidth) break;
size -= 2;
} while (size > 18);
return size;
}
const mainCanvas = makeCanvas(1024, 320);
const mainTexture = new THREE.CanvasTexture(mainCanvas.canvas);
mainTexture.colorSpace = THREE.SRGBColorSpace;
mainTexture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const markerCanvas = makeCanvas(512, 640);
const markerTexture = new THREE.CanvasTexture(markerCanvas.canvas);
markerTexture.colorSpace = THREE.SRGBColorSpace;
markerTexture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const speakerCanvas = makeCanvas(768, 190);
const speakerTexture = new THREE.CanvasTexture(speakerCanvas.canvas);
speakerTexture.colorSpace = THREE.SRGBColorSpace;
speakerTexture.anisotropy = renderer.capabilities.getMaxAnisotropy();
function drawMainDisplay(destination, accent, live) {
const ctx = mainCanvas.context;
const w = 1024;
const h = 320;
ctx.clearRect(0, 0, w, h);
ctx.fillStyle = "#071622";
ctx.fillRect(0, 0, w, h);
ctx.strokeStyle = "rgba(255,255,255,0.045)";
ctx.lineWidth = 1;
for (let x = 0; x < w; x += 42) {
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, h);
ctx.stroke();
}
for (let y = 0; y < h; y += 42) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(w, y);
ctx.stroke();
}
ctx.fillStyle = accent;
ctx.fillRect(20, 18, 10, 284);
ctx.fillStyle = "#9db0be";
ctx.font = "800 22px system-ui, sans-serif";
ctx.fillText("NORTHLINE / STATION 03", 58, 52);
ctx.fillStyle = accent;
ctx.font = "850 19px system-ui, sans-serif";
ctx.fillText(live ? "BOARDING NOW" : "PASSENGER INFORMATION", 58, 93);
const displayText = live ? destination.toUpperCase() : "AWAITING EVENT";
const size = fitText(ctx, displayText, 615, live ? 67 : 58, 850);
ctx.fillStyle = "#f5f8fa";
ctx.font = `850 ${size}px system-ui, sans-serif`;
ctx.fillText(displayText, 58, 165);
ctx.fillStyle = "#b7c7d1";
ctx.font = "700 22px system-ui, sans-serif";
ctx.fillText(
live ? "Please proceed to Platform 3" : "Select a destination to begin",
60,
210
);
ctx.fillStyle = "rgba(255,255,255,0.08)";
roundedRect(ctx, 58, 239, 605, 48, 10);
ctx.fill();
ctx.fillStyle = accent;
ctx.font = "850 18px system-ui, sans-serif";
ctx.fillText("PLATFORM 03", 78, 269);
ctx.fillStyle = "#91a5b5";
ctx.fillText("•", 230, 269);
ctx.fillText(live ? "TRAIN 08 ARRIVING" : "ALL CHANNELS ONLINE", 252, 269);
// Route diagram
ctx.strokeStyle = "rgba(255,255,255,0.16)";
ctx.lineWidth = 5;
ctx.beginPath();
ctx.moveTo(760, 148);
ctx.lineTo(935, 148);
ctx.stroke();
ctx.fillStyle = "#102633";
ctx.strokeStyle = "#69808f";
ctx.lineWidth = 3;
for (const [x, label] of [[760, "S03"], [935, "NEXT"]]) {
ctx.beginPath();
ctx.arc(x, 148, 19, 0, Math.PI * 2);
ctx.fill();
ctx.stroke();
ctx.fillStyle = "#cbd7de";
ctx.font = "800 14px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.fillText(label, x, 153);
ctx.fillStyle = "#102633";
}
ctx.textAlign = "left";
ctx.fillStyle = "#8195a4";
ctx.font = "750 15px system-ui, sans-serif";
ctx.fillText("ROUTE PROGRESS", 760, 201);
ctx.fillStyle = accent;
ctx.beginPath();
ctx.arc(760, 148, 8, 0, Math.PI * 2);
ctx.fill();
mainTexture.needsUpdate = true;
}
function drawMarker(destination, accent, live) {
const ctx = markerCanvas.context;
const w = 512;
const h = 640;
ctx.clearRect(0, 0, w, h);
ctx.fillStyle = "#f0eee5";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "#142a38";
ctx.fillRect(0, 0, w, 72);
ctx.fillStyle = accent;
ctx.fillRect(0, 72, w, 10);
ctx.fillStyle = "#ffffff";
ctx.font = "850 30px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.fillText("PLATFORM", 256, 46);
ctx.fillStyle = "#132a38";
ctx.font = "900 240px system-ui, sans-serif";
ctx.fillText("3", 256, 320);
ctx.strokeStyle = "#bec5c4";
ctx.lineWidth = 4;
ctx.beginPath();
ctx.moveTo(42, 357);
ctx.lineTo(470, 357);
ctx.stroke();
ctx.fillStyle = live ? accent : "#536772";
ctx.font = "850 21px system-ui, sans-serif";
ctx.fillText(live ? "BOARDING" : "STANDBY", 256, 400);
const destinationText = live ? destination.toUpperCase() : "SELECT ROUTE";
const size = fitText(ctx, destinationText, 430, live ? 49 : 40, 850);
ctx.fillStyle = "#132a38";
ctx.font = `850 ${size}px system-ui, sans-serif`;
ctx.fillText(destinationText, 256, 466);
ctx.fillStyle = "#142a38";
roundedRect(ctx, 44, 510, 424, 82, 15);
ctx.fill();
ctx.fillStyle = accent;
ctx.font = "850 20px system-ui, sans-serif";
ctx.fillText(live ? "TRAIN 08 • BOARD NOW" : "WAITING FOR EVENT", 256, 560);
ctx.textAlign = "left";
markerTexture.needsUpdate = true;
}
function drawSpeakerTag(destination, accent, live) {
const ctx = speakerCanvas.context;
const w = 768;
const h = 190;
ctx.clearRect(0, 0, w, h);
ctx.fillStyle = "#f4f1e8";
roundedRect(ctx, 8, 8, 752, 174, 28);
ctx.fill();
ctx.fillStyle = accent;
roundedRect(ctx, 8, 8, 20, 174, 10);
ctx.fill();
ctx.fillStyle = "#60727e";
ctx.font = "850 22px system-ui, sans-serif";
ctx.fillText(live ? "SOUND / NOW BOARDING" : "SOUND / STANDBY", 58, 58);
const destinationText = live ? destination.toUpperCase() : "READY";
const size = fitText(ctx, destinationText, 660, live ? 55 : 48, 900);
ctx.fillStyle = "#102633";
ctx.font = `900 ${size}px system-ui, sans-serif`;
ctx.fillText(destinationText, 58, 125);
ctx.fillStyle = accent;
ctx.beginPath();
ctx.arc(710, 125, 13, 0, Math.PI * 2);
ctx.fill();
speakerTexture.needsUpdate = true;
}
// ------------------------------------------------------------
// Main station display
// ------------------------------------------------------------
const boardGroup = new THREE.Group();
boardGroup.position.set(-1.2, 3.35, 0.35);
scene.add(boardGroup);
const boardFrameMaterial = materials.boardFrame.clone();
boardFrameMaterial.emissive = new THREE.Color(0x000000);
boardFrameMaterial.emissiveIntensity = 0;
addBox(
boardGroup,
[7.45, 2.57, 0.31],
[0, 0, 0],
boardFrameMaterial
);
const boardScreen = new THREE.Mesh(
new THREE.PlaneGeometry(7.05, 2.18),
new THREE.MeshBasicMaterial({
map: mainTexture,
toneMapped: false
})
);
boardScreen.position.z = 0.165;
boardGroup.add(boardScreen);
const scanBar = new THREE.Mesh(
new THREE.PlaneGeometry(6.95, 0.055),
new THREE.MeshBasicMaterial({
color: 0xffffff,
transparent: true,
opacity: 0.34,
blending: THREE.AdditiveBlending,
depthWrite: false,
toneMapped: false
})
);
scanBar.position.z = 0.18;
scanBar.visible = false;
boardGroup.add(scanBar);
addBox(
scene,
[0.24, 2.45, 0.24],
[-4.0, 1.15, 0.24],
materials.steel
);
addBox(
scene,
[0.24, 2.45, 0.24],
[1.6, 1.15, 0.24],
materials.steel
);
// ------------------------------------------------------------
// Flashing platform marker
// ------------------------------------------------------------
const markerGroup = new THREE.Group();
markerGroup.position.set(5.25, 0, 0.65);
scene.add(markerGroup);
addBox(
markerGroup,
[0.18, 1.0, 0.18],
[0, 0.48, 0],
materials.steel
);
addBox(
markerGroup,
[0.65, 0.12, 0.65],
[0, 0.02, 0],
materials.concrete
);
const markerFrameMaterial = standardMaterial(0x203644, {
metalness: 0.35,
roughness: 0.38,
emissive: 0xf7c948,
emissiveIntensity: 0.04
});
addBox(
markerGroup,
[1.75, 2.62, 0.3],
[0, 1.72, 0],
markerFrameMaterial
);
const markerScreen = new THREE.Mesh(
new THREE.PlaneGeometry(1.55, 2.42),
new THREE.MeshBasicMaterial({
map: markerTexture,
toneMapped: false
})
);
markerScreen.position.set(0, 1.72, 0.16);
markerGroup.add(markerScreen);
const markerFlashMaterial = new THREE.MeshBasicMaterial({
color: 0xf7c948,
transparent: true,
opacity: 0,
blending: THREE.AdditiveBlending,
depthWrite: false,
toneMapped: false
});
const markerFlash = new THREE.Mesh(
new THREE.PlaneGeometry(1.74, 2.61),
markerFlashMaterial
);
markerFlash.position.set(0, 1.72, 0.18);
markerGroup.add(markerFlash);
const beaconMaterial = standardMaterial(0xf7c948, {
emissive: 0xf7c948,
emissiveIntensity: 0.6,
roughness: 0.25
});
const beacon = new THREE.Mesh(
new THREE.OctahedronGeometry(0.22, 0),
beaconMaterial
);
beacon.position.set(0, 3.23, 0);
beacon.castShadow = true;
markerGroup.add(beacon);
const markerLight = new THREE.PointLight(0xf7c948, 0, 5, 2);
markerLight.position.set(0, 3.1, 0.4);
markerGroup.add(markerLight);
const haloMaterial = new THREE.MeshBasicMaterial({
color: 0xf7c948,
transparent: true,
opacity: 0,
side: THREE.DoubleSide,
blending: THREE.AdditiveBlending,
depthWrite: false,
toneMapped: false
});
const markerHalo = new THREE.Mesh(
new THREE.TorusGeometry(0.47, 0.035, 4, 32),
haloMaterial
);
markerHalo.position.set(0, 3.23, 0);
markerHalo.rotation.x = Math.PI / 2;
markerGroup.add(markerHalo);
const rippleMaterial = new THREE.MeshBasicMaterial({
color: 0xf7c948,
transparent: true,
opacity: 0,
side: THREE.DoubleSide,
blending: THREE.AdditiveBlending,
depthWrite: false,
toneMapped: false
});
const markerRipple = new THREE.Mesh(
new THREE.TorusGeometry(1.15, 0.035, 4, 48),
rippleMaterial
);
markerRipple.position.set(5.25, 0.04, 0.65);
markerRipple.rotation.x = Math.PI / 2;
scene.add(markerRipple);
// ------------------------------------------------------------
// Moving low-poly speaker icon
// ------------------------------------------------------------
const announcementRail = new THREE.Mesh(
new THREE.CylinderGeometry(0.045, 0.045, 11.3, 8),
materials.steel
);
announcementRail.rotation.z = Math.PI / 2;
announcementRail.position.set(-0.5, 5.03, 1.58);
scene.add(announcementRail);
const speaker = new THREE.Group();
speaker.position.set(SPEAKER_START_X, 5.03, 1.58);
scene.add(speaker);
addBox(
speaker,
[0.72, 0.86, 0.48],
[-0.32, 0, 0],
materials.speaker
);
addBox(
speaker,
[0.23, 0.96, 0.54],
[-0.32, 0, 0],
materials.speakerDark
);
const horn = new THREE.Mesh(
new THREE.CylinderGeometry(0.4, 0.12, 0.62, 8, 1, false),
materials.speaker
);
horn.rotation.z = -Math.PI / 2;
horn.position.x = 0.25;
horn.castShadow = true;
speaker.add(horn);
const speakerWaves = [];
for (let waveIndex = 0; waveIndex < 3; waveIndex++) {
const radius = 0.43 + waveIndex * 0.18;
const points = [];
for (let pointIndex = 0; pointIndex <= 14; pointIndex++) {
const angle = -1.12 + (pointIndex / 14) * 2.24;
points.push(
new THREE.Vector3(
0.7 + radius * Math.sin(angle),
radius * Math.cos(angle),
0
)
);
}
const waveMaterial = new THREE.LineBasicMaterial({
color: 0xffd765,
transparent: true,
opacity: 0.45
});
const wave = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(points),
waveMaterial
);
wave.position.z = 0.02;
speaker.add(wave);
speakerWaves.push(wave);
}
const speakerTag = new THREE.Sprite(
new THREE.SpriteMaterial({
map: speakerTexture,
transparent: true,
depthTest: false,
depthWrite: false,
toneMapped: false
})
);
speakerTag.position.set(0, 1.02, 0);
speakerTag.scale.set(3.25, 0.8, 1);
speakerTag.renderOrder = 10;
speaker.add(speakerTag);
// Idle artwork
drawMainDisplay("", "#f7c948", false);
drawMarker("", "#f7c948", false);
drawSpeakerTag("", "#f7c948", false);
// ------------------------------------------------------------
// One synchronized event function
// ------------------------------------------------------------
function announce(destination) {
const accent = destinationStyles[destination] || "#f7c948";
currentDestination = destination;
// The shared destination and accent are committed together.
document.documentElement.style.setProperty("--accent", accent);
drawMainDisplay(destination, accent, true);
drawMarker(destination, accent, true);
drawSpeakerTag(destination, accent, true);
channelValues.forEach((element) => {
element.textContent = destination;
});
displayStatus.textContent = "Live · Platform 03";
platformStatus.textContent = "Marker flashing";
audioStatus.textContent = soundToggle.checked
? "Voice + speaker motion"
: "Visual sync · muted";
speaker.position.x = SPEAKER_START_X;
speaker.position.y = 5.03;
eventActive = true;
eventStart = clock.getElapsedTime();
systemStatus.classList.add("live");
systemStatusText.textContent = "Event live";
triggerButton.classList.add("is-live");
triggerLabel.textContent = "Announcing…";
progressBar.style.transition = "none";
progressBar.style.width = "0%";
requestAnimationFrame(() => {
requestAnimationFrame(() => {
progressBar.style.transition = `width ${EVENT_DURATION}s linear`;
progressBar.style.width = "100%";
});
});
speakAnnouncement(destination);
showToast(`${destination} · all three channels synchronized`);
}
function speakAnnouncement(destination) {
speechActive = false;
if (
!soundToggle.checked ||
!("speechSynthesis" in window)
) {
audioStatus.textContent = soundToggle.checked
? "Visual sync · voice unavailable"
: "Visual sync · muted";
return;
}
window.speechSynthesis.cancel();
const utterance = new SpeechSynthesisUtterance(
`Now boarding for ${destination}. Please proceed to platform three.`
);
utterance.lang = "en-US";
utterance.rate = 0.94;
utterance.pitch = 1.0;
utterance.onstart = () => {
speechActive = true;
audioStatus.textContent = "Voice playing";
};
utterance.onend = () => {
speechActive = false;
audioStatus.textContent = eventActive ? "Voice complete" : "Synced";
};
utterance.onerror = () => {
speechActive = false;
audioStatus.textContent = "Visual sync · voice unavailable";
};
window.speechSynthesis.speak(utterance);
}
triggerButton.addEventListener("click", () => {
announce(destinationSelect.value);
});
window.addEventListener("keydown", (event) => {
const tag = document.activeElement?.tagName;
if (
event.code === "Space" &&
tag !== "SELECT" &&
tag !== "INPUT" &&
tag !== "BUTTON"
) {
event.preventDefault();
announce(destinationSelect.value);
}
});
// ------------------------------------------------------------
// Custom camera controls — no Three.js examples/addons
// ------------------------------------------------------------
let dragging = false;
let previousPointerX = 0;
let previousPointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.pointerType === "mouse" && event.button !== 0) return;
dragging = true;
previousPointerX = event.clientX;
previousPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.classList.add("dragging");
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousPointerX;
const deltaY = event.clientY - previousPointerY;
previousPointerX = event.clientX;
previousPointerY = event.clientY;
cameraView.yaw -= deltaX * 0.006;
cameraView.pitch = THREE.MathUtils.clamp(
cameraView.pitch + deltaY * 0.0045,
0.12,
1.02
);
updateCamera();
});
function endDrag(event) {
dragging = false;
renderer.domElement.classList.remove("dragging");
if (
event.pointerType !== "mouse" &&
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();
cameraView.radius = THREE.MathUtils.clamp(
cameraView.radius + event.deltaY * 0.009,
10,
23
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
cameraView.yaw = 0.48;
cameraView.pitch = 0.31;
cameraView.radius = window.innerWidth < 720 ? 19 : 16;
updateCamera();
});
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
// ------------------------------------------------------------
// Resize and animation
// ------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
const clock = new THREE.Clock();
function easeInOutCubic(value) {
return value < 0.5
? 4 * value * value * value
: 1 - Math.pow(-2 * value + 2, 3) / 2;
}
function animate() {
const time = clock.getElapsedTime();
const elapsed = time - eventStart;
if (eventActive) {
const travelProgress = THREE.MathUtils.clamp(elapsed / 2.25, 0, 1);
const easedTravel = easeInOutCubic(travelProgress);
speaker.position.x = THREE.MathUtils.lerp(
SPEAKER_START_X,
SPEAKER_END_X,
easedTravel
);
speaker.position.y =
5.03 +
Math.sin(elapsed * 8) * 0.055 * (1 - travelProgress);
speaker.rotation.z =
Math.sin(elapsed * 5) * 0.025 * (1 - travelProgress);
const flash = 0.5 + 0.5 * Math.sin(elapsed * 10);
markerFrameMaterial.emissive.set(
destinationStyles[currentDestination] || "#f7c948"
);
markerFrameMaterial.emissiveIntensity = 0.1 + flash * 0.65;
beaconMaterial.emissiveIntensity = 0.45 + flash * 2.4;
beacon.scale.setScalar(0.92 + flash * 0.26);
markerLight.intensity = 0.3 + flash * 2.8;
markerFlashMaterial.opacity = flash * 0.12;
markerHalo.scale.setScalar(1 + flash * 0.75);
markerHalo.rotation.z = time * 1.8;
haloMaterial.opacity = 0.12 + flash * 0.48;
const rippleProgress = (elapsed % 1.1) / 1.1;
markerRipple.scale.setScalar(0.45 + rippleProgress * 1.55);
rippleMaterial.opacity = (1 - rippleProgress) * 0.5;
scanBar.visible = true;
scanBar.position.y = -1.02 + ((elapsed * 1.55) % 2.04);
scanBar.material.opacity = 0.16 + flash * 0.2;
boardFrameMaterial.emissive.set(
destinationStyles[currentDestination] || "#f7c948"
);
boardFrameMaterial.emissiveIntensity = 0.025 + flash * 0.055;
speakerWaves.forEach((wave, index) => {
wave.material.opacity =
0.25 + flash * (0.55 - index * 0.08);
wave.scale.x = 1 + flash * 0.06;
wave.scale.y = 1 + flash * 0.06;
});
if (elapsed >= EVENT_DURATION) {
eventActive = false;
systemStatus.classList.remove("live");
systemStatusText.textContent = "Channels synced";
triggerButton.classList.remove("is-live");
triggerLabel.textContent = "Trigger boarding event";
displayStatus.textContent = "Synced · Platform 03";
platformStatus.textContent = "Synced · flash complete";
audioStatus.textContent = speechActive ? "Voice playing" : "Synced";
}
} else {
speaker.position.y = 5.03 + Math.sin(time * 2.2) * 0.025;
speaker.rotation.z = Math.sin(time * 1.5) * 0.012;
markerFrameMaterial.emissiveIntensity = 0.035;
beaconMaterial.emissiveIntensity = 0.55;
markerLight.intensity = 0.22;
markerFlashMaterial.opacity = 0;
haloMaterial.opacity = 0.08;
rippleMaterial.opacity = 0;
boardFrameMaterial.emissiveIntensity = 0;
scanBar.visible = false;
speakerWaves.forEach((wave, index) => {
wave.material.opacity = 0.2 + Math.sin(time * 2 + index) * 0.08;
});
}
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("hidden");
});
</script>
</body>
</html>
```