Prompt specification
Build or customize the Three.js 3D scene "Small ferry terminal kiosk area" 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: Small ferry terminal kiosk area
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/small-ferry-terminal-kiosk-area-x0479
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows a stylized ferry-terminal kiosk area. Place two ticket machines beneath a shallow canopy, an assistance desk at one side, and benches facing the dock entrance. Use three destination symbols consistently on tickets, machines, signs, and boarding lanes. Animate one visitor buying a ticket directly and another visiting the desk first; their routes should converge at the correct boarding sign. Keep luggage and a seated visitor clear of the main passage. Use rounded solid forms, pale pavement, blue railings, and a few bright symbol panels. The scene should read as a small working terminal rather than a wall of instructions.
Working Three.js Starter (small-ferry-terminal-kiosk-area-x0479):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>North Quay — Ferry Terminal</title>
<style>
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce9ec;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.brand {
position: fixed;
top: 24px;
left: 26px;
z-index: 5;
pointer-events: none;
color: #15384a;
text-shadow: 0 1px 0 rgba(255, 255, 255, .55);
}
.brand small {
display: block;
margin-bottom: 3px;
font-size: 10px;
font-weight: 800;
letter-spacing: .22em;
text-transform: uppercase;
opacity: .7;
}
.brand strong {
display: block;
font-size: clamp(20px, 3vw, 32px);
font-weight: 750;
letter-spacing: -.035em;
}
.hint {
position: fixed;
right: 22px;
bottom: 18px;
z-index: 5;
padding: 9px 13px;
border: 1px solid rgba(21, 56, 74, .12);
border-radius: 999px;
background: rgba(250, 249, 242, .78);
color: #315767;
font-size: 11px;
font-weight: 650;
letter-spacing: .03em;
backdrop-filter: blur(8px);
pointer-events: none;
}
@media (max-width: 600px) {
.brand { top: 17px; left: 18px; }
.hint { right: 12px; bottom: 12px; }
}
</style>
</head>
<body>
<div class="brand">
<small>North Quay</small>
<strong>Ferry Terminal</strong>
</div>
<div class="hint">Drag to orbit · Scroll to zoom</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 direct camera controls
// ---------------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({ antialias: true });
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.05;
document.body.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce9ec);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraTarget = new THREE.Vector3(0, 1.0, -1.0);
const orbit = {
radius: 27,
yaw: 0.36,
pitch: 0.40,
dragging: false,
pointerX: 0,
pointerY: 0
};
function updateCamera() {
const horizontal = Math.cos(orbit.pitch) * orbit.radius;
camera.position.set(
cameraTarget.x + Math.sin(orbit.yaw) * horizontal,
cameraTarget.y + Math.sin(orbit.pitch) * orbit.radius,
cameraTarget.z + Math.cos(orbit.yaw) * horizontal
);
camera.lookAt(cameraTarget);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
orbit.dragging = true;
orbit.pointerX = event.clientX;
orbit.pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!orbit.dragging) return;
const dx = event.clientX - orbit.pointerX;
const dy = event.clientY - orbit.pointerY;
orbit.yaw -= dx * 0.0055;
orbit.pitch = THREE.MathUtils.clamp(
orbit.pitch + dy * 0.0045,
0.18,
0.88
);
orbit.pointerX = event.clientX;
orbit.pointerY = event.clientY;
updateCamera();
});
function stopDragging(event) {
orbit.dragging = false;
if (event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius + event.deltaY * 0.018,
15,
39
);
updateCamera();
},
{ passive: false }
);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
updateCamera();
// ---------------------------------------------------------------------
// Lighting
// ---------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xf4fbff, 0xb8b29f, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff3d7, 3.0);
sun.position.set(-8, 16, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 45;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb8e5ff, 0.75);
fill.position.set(12, 8, -10);
scene.add(fill);
// ---------------------------------------------------------------------
// Materials and rounded solid geometry
// ---------------------------------------------------------------------
const material = (color, roughness = 0.78, metalness = 0.0) =>
new THREE.MeshStandardMaterial({ color, roughness, metalness });
const M = {
pavement: material(0xe8e7de, 0.96),
pavementAlt: material(0xf1f0e8, 0.95),
path: material(0xf7f5eb, 0.92),
cream: material(0xf7f2e5, 0.78),
white: material(0xfffdf5, 0.66),
navy: material(0x17384a, 0.72),
blue: material(0x1e78a5, 0.58, 0.08),
blueLight: material(0x4ba7c2, 0.66),
screen: material(0x102d3b, 0.42),
wood: material(0xcda874, 0.82),
dark: material(0x27313a, 0.78),
coral: material(0xf26c5b, 0.66),
yellow: material(0xf3bd45, 0.66),
teal: material(0x21b6b2, 0.62),
green: material(0x5d9b74, 0.88),
greenLight: material(0x83b989, 0.9),
skinA: material(0xdca17b, 0.86),
skinB: material(0x9d684f, 0.86),
hairA: material(0x3d302a, 0.9),
hairB: material(0x78624c, 0.9),
pantsA: material(0x314b5c, 0.88),
pantsB: material(0x685d64, 0.88),
shirtA: material(0xec765e, 0.82),
shirtB: material(0x4d9fb4, 0.82),
water: material(0x72b9c5, 0.42, 0.05)
};
function roundedBoxGeometry(width, height, depth, radius = 0.12) {
const bevel = Math.min(
radius * 0.32,
0.09,
depth * 0.2,
height * 0.15,
width * 0.15
);
const shapeWidth = width - bevel * 2;
const shapeHeight = height - bevel * 2;
const corner = Math.max(0.001, radius - bevel);
const x = -shapeWidth / 2;
const y = -shapeHeight / 2;
const shape = new THREE.Shape();
shape.moveTo(x + corner, y);
shape.lineTo(x + shapeWidth - corner, y);
shape.quadraticCurveTo(
x + shapeWidth, y,
x + shapeWidth, y + corner
);
shape.lineTo(
x + shapeWidth,
y + shapeHeight - corner
);
shape.quadraticCurveTo(
x + shapeWidth, y + shapeHeight,
x + shapeWidth - corner, y + shapeHeight
);
shape.lineTo(x + corner, y + shapeHeight);
shape.quadraticCurveTo(
x, y + shapeHeight,
x, y + shapeHeight - corner
);
shape.lineTo(x, y + corner);
shape.quadraticCurveTo(x, y, x + corner, y);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: depth - bevel * 2,
steps: 1,
bevelEnabled: true,
bevelSegments: 3,
bevelSize: bevel,
bevelThickness: bevel,
curveSegments: 8
});
geometry.center();
geometry.computeVertexNormals();
return geometry;
}
function roundedBox(
parent,
width,
height,
depth,
radius,
mat,
position = [0, 0, 0]
) {
const mesh = new THREE.Mesh(
roundedBoxGeometry(width, height, depth, radius),
mat
);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinderBetween(parent, a, b, radius, mat, radialSegments = 10) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, radialSegments),
mat
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// ---------------------------------------------------------------------
// Canvas textures: one reusable visual language for all three symbols
// ---------------------------------------------------------------------
const SYMBOLS = {
sun: { color: "#f3bd45", dark: "#d79b25" },
tide: { color: "#21b6b2", dark: "#138d8b" },
peak: { color: "#f26c5b", dark: "#ca4d42" }
};
const symbolTextures = {};
function roundedRectPath(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 makeSymbolTexture(type) {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 256;
const ctx = canvas.getContext("2d");
const symbol = SYMBOLS[type];
ctx.clearRect(0, 0, 256, 256);
roundedRectPath(ctx, 8, 8, 240, 240, 40);
ctx.fillStyle = symbol.color;
ctx.fill();
ctx.strokeStyle = "rgba(255,255,255,.28)";
ctx.lineWidth = 5;
ctx.stroke();
ctx.fillStyle = "#fffdf5";
ctx.strokeStyle = "#fffdf5";
ctx.lineCap = "round";
ctx.lineJoin = "round";
if (type === "sun") {
ctx.lineWidth = 13;
for (let i = 0; i < 8; i++) {
const angle = i * Math.PI / 4;
const inner = 63;
const outer = 91;
ctx.beginPath();
ctx.moveTo(
128 + Math.cos(angle) * inner,
128 + Math.sin(angle) * inner
);
ctx.lineTo(
128 + Math.cos(angle) * outer,
128 + Math.sin(angle) * outer
);
ctx.stroke();
}
ctx.beginPath();
ctx.arc(128, 128, 43, 0, Math.PI * 2);
ctx.fill();
}
if (type === "tide") {
ctx.lineWidth = 15;
for (let row = 0; row < 3; row++) {
const y = 83 + row * 46;
ctx.beginPath();
ctx.moveTo(54, y);
ctx.bezierCurveTo(80, y - 23, 103, y + 23, 128, y);
ctx.bezierCurveTo(153, y - 23, 176, y + 23, 202, y);
ctx.stroke();
}
}
if (type === "peak") {
ctx.beginPath();
ctx.moveTo(128, 43);
ctx.lineTo(207, 196);
ctx.lineTo(49, 196);
ctx.closePath();
ctx.fill();
ctx.fillStyle = symbol.color;
ctx.beginPath();
ctx.moveTo(128, 76);
ctx.lineTo(174, 176);
ctx.lineTo(82, 176);
ctx.closePath();
ctx.fill();
ctx.strokeStyle = "#fffdf5";
ctx.lineWidth = 11;
ctx.beginPath();
ctx.moveTo(128, 79);
ctx.lineTo(128, 175);
ctx.stroke();
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
for (const type of Object.keys(SYMBOLS)) {
symbolTextures[type] = makeSymbolTexture(type);
}
function symbolTile(parent, type, width, height, position) {
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: symbolTextures[type],
transparent: true,
side: THREE.DoubleSide,
toneMapped: false
})
);
mesh.position.set(...position);
parent.add(mesh);
return mesh;
}
function makeTextTexture(text, background = "#17384a", foreground = "#fffdf5") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = foreground;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
let size = 52;
ctx.font = `800 ${size}px system-ui, sans-serif`;
while (ctx.measureText(text).width > 460 && size > 24) {
size -= 2;
ctx.font = `800 ${size}px system-ui, sans-serif`;
}
ctx.fillText(text, 256, 66);
ctx.fillRect(46, 107, 420, 3);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
function textPlane(
parent,
text,
width,
height,
position,
background = "#17384a",
foreground = "#fffdf5"
) {
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: makeTextTexture(text, background, foreground),
side: THREE.DoubleSide,
toneMapped: false
})
);
mesh.position.set(...position);
parent.add(mesh);
return mesh;
}
// ---------------------------------------------------------------------
// Ground, dock, water and railings
// ---------------------------------------------------------------------
const terminal = new THREE.Group();
scene.add(terminal);
roundedBox(
terminal, 26, 0.28, 22, 0.9,
M.pavement, [0, -0.16, 0]
);
roundedBox(
terminal, 4.2, 0.035, 16.5, 0.18,
M.path, [0, 0.006, 1.6]
);
const water = new THREE.Mesh(
new THREE.PlaneGeometry(52, 20),
M.water
);
water.rotation.x = -Math.PI / 2;
water.position.set(0, -0.11, -21);
water.receiveShadow = true;
scene.add(water);
// Stylized water strokes.
for (let i = 0; i < 9; i++) {
const z = -12.2 - i * 1.75;
const x = -8 + (i % 3) * 5.5;
const curve = new THREE.CatmullRomCurve3([
new THREE.Vector3(x, -0.075, z),
new THREE.Vector3(x + 1.2, -0.075, z + 0.12),
new THREE.Vector3(x + 2.4, -0.075, z),
new THREE.Vector3(x + 3.6, -0.075, z + 0.08)
]);
const ripple = new THREE.Mesh(
new THREE.TubeGeometry(curve, 18, 0.025, 5, false),
material(0xc7e7e5, 0.55)
);
scene.add(ripple);
}
function railSegment(x1, x2, z, height = 1.1) {
const length = Math.abs(x2 - x1);
const count = Math.max(1, Math.ceil(length / 2.15));
for (let i = 0; i <= count; i++) {
const x = THREE.MathUtils.lerp(x1, x2, i / count);
cylinderBetween(
terminal,
[x, 0, z],
[x, height, z],
0.065,
M.blue
);
}
cylinderBetween(
terminal,
[x1, 0.48, z],
[x2, 0.48, z],
0.055,
M.blue
);
cylinderBetween(
terminal,
[x1, 0.98, z],
[x2, 0.98, z],
0.055,
M.blue
);
}
// Gaps correspond to the three boarding lanes.
railSegment(-12.7, -4.05, -10.55);
railSegment(-2.25, -1.05, -10.55);
railSegment(1.05, 2.25, -10.55);
railSegment(4.05, 12.7, -10.55);
railSegment(-12.7, -12.7, -10.55, 1.1);
railSegment(12.7, 12.7, -10.55, 1.1);
// Short side railings.
for (const x of [-11.7, 11.7]) {
cylinderBetween(
terminal,
[x, 0, -8.8],
[x, 1.0, -8.8],
0.065,
M.blue
);
cylinderBetween(
terminal,
[x, 0, -8.8],
[x, 0, -4.7],
0.065,
M.blue
);
cylinderBetween(
terminal,
[x, 0.5, -8.8],
[x, 0.5, -4.7],
0.055,
M.blue
);
cylinderBetween(
terminal,
[x, 0.98, -8.8],
[x, 0.98, -4.7],
0.055,
M.blue
);
}
// ---------------------------------------------------------------------
// Three boarding lanes and signs
// ---------------------------------------------------------------------
const laneDefinitions = [
{ type: "sun", x: -3.15, mat: M.yellow },
{ type: "tide", x: 0, mat: M.teal },
{ type: "peak", x: 3.15, mat: M.coral }
];
const laneSignTiles = [];
for (const lane of laneDefinitions) {
const band = roundedBox(
terminal,
1.22,
0.035,
3.7,
0.14,
lane.mat,
[lane.x, 0.028, -7.45]
);
band.material = band.material.clone();
band.material.transparent = true;
band.material.opacity = 0.42;
const floorSymbol = symbolTile(
terminal,
lane.type,
0.72,
0.72,
[lane.x, 0.055, -8.35]
);
floorSymbol.rotation.x = -Math.PI / 2;
cylinderBetween(
terminal,
[lane.x, 0, -9.18],
[lane.x, 2.72, -9.18],
0.075,
M.blue
);
roundedBox(
terminal,
1.24,
1.24,
0.14,
0.17,
M.white,
[lane.x, 2.72, -9.12]
);
const tileRoot = new THREE.Group();
tileRoot.position.set(lane.x, 2.72, -9.035);
terminal.add(tileRoot);
symbolTile(tileRoot, lane.type, 1.03, 1.03, [0, 0, 0]);
laneSignTiles.push(tileRoot);
}
// ---------------------------------------------------------------------
// Ticket machines and shallow canopy
// ---------------------------------------------------------------------
const machineRight = {};
function makeMachine(x, accentMaterial) {
const group = new THREE.Group();
group.position.set(x, 0, -2.45);
terminal.add(group);
roundedBox(group, 1.42, 2.28, 1.02, 0.18, M.cream, [0, 1.14, 0]);
roundedBox(group, 1.18, 1.92, 0.075, 0.13, M.navy, [0, 1.20, 0.535]);
roundedBox(group, 1.04, 0.63, 0.065, 0.09, M.screen, [0, 1.57, 0.59]);
textPlane(group, "TICKETS", 0.83, 0.22, [0, 2.03, 0.592]);
const sunButton = symbolTile(group, "sun", 0.255, 0.255, [-0.34, 1.54, 0.63]);
const tideButton = symbolTile(group, "tide", 0.255, 0.255, [0, 1.54, 0.63]);
const peakButton = symbolTile(group, "peak", 0.255, 0.255, [0.34, 1.54, 0.63]);
roundedBox(group, 0.72, 0.105, 0.085, 0.04, M.dark, [0, 0.71, 0.59]);
roundedBox(group, 0.49, 0.05, 0.06, 0.02, accentMaterial, [0, 0.93, 0.59]);
const lowerStrip = roundedBox(
group,
0.87,
0.07,
0.05,
0.025,
accentMaterial,
[0, 0.48, 0.59]
);
lowerStrip.rotation.z = -0.025;
const button = new THREE.Mesh(
new THREE.CylinderGeometry(0.10, 0.10, 0.065, 18),
accentMaterial
);
button.rotation.x = Math.PI / 2;
button.position.set(0.38, 0.83, 0.61);
group.add(button);
return { group, sunButton, tideButton, peakButton };
}
const machineLeft = makeMachine(-6.55, M.blueLight);
const rightMachine = makeMachine(-3.95, M.teal);
machineRight.tideButton = rightMachine.tideButton;
const canopy = new THREE.Group();
canopy.position.set(-5.25, 0, -2.55);
terminal.add(canopy);
const canopyRoof = roundedBox(
canopy,
8.35,
0.28,
3.25,
0.18,
M.cream,
[0, 3.31, -0.03]
);
canopyRoof.rotation.x = -0.035;
const canopyTrim = roundedBox(
canopy,
8.42,
0.16,
0.18,
0.07,
M.blue,
[0, 3.17, 1.56]
);
canopyTrim.rotation.x = -0.035;
for (const x of [-8.75, -1.75]) {
cylinderBetween(
canopy,
[x, 0, -0.85],
[x, 3.18, -0.85],
0.095,
M.blue
);
roundedBox(
canopy,
0.43,
0.12,
0.43,
0.08,
M.blue,
[x, 0.07, -0.85]
);
}
// ---------------------------------------------------------------------
// Assistance desk, attendant and ticket samples
// ---------------------------------------------------------------------
const desk = new THREE.Group();
desk.position.set(6.25, 0, -1.8);
terminal.add(desk);
roundedBox(desk, 3.45, 1.28, 1.55, 0.2, M.blue, [0, 0.66, 0]);
roundedBox(desk, 3.65, 0.19, 1.72, 0.15, M.cream, [0, 1.38, 0]);
const deskFront = roundedBox(
desk,
2.9,
0.68,
0.055,
0.09,
M.navy,
[0, 0.74, 0.795]
);
deskFront.material = deskFront.material.clone();
deskFront.material.transparent = true;
deskFront.material.opacity = 0.55;
roundedBox(desk, 0.58, 0.39, 0.11, 0.06, M.navy, [0.7, 1.67, -0.18]);
roundedBox(desk, 0.48, 0.31, 0.06, 0.04, M.screen, [0.7, 1.67, -0.105]);
cylinderBetween(
desk,
[0.7, 1.42, -0.18],
[0.7, 1.50, -0.18],
0.045,
M.dark
);
const deskSign = new THREE.Group();
deskSign.position.set(0, 2.65, -0.8);
desk.add(deskSign);
roundedBox(deskSign, 2.9, 1.12, 0.13, 0.15, M.white);
textPlane(deskSign, "ASSISTANCE", 2.25, 0.28, [0, 0.31, 0.075]);
symbolTile(deskSign, "sun", 0.42, 0.42, [-0.78, -0.23, 0.075]);
symbolTile(deskSign, "tide", 0.42, 0.42, [0, -0.23, 0.075]);
symbolTile(deskSign, "peak", 0.42, 0.42, [0.78, -0.23, 0.075]);
// ---------------------------------------------------------------------
// Benches, seated visitor and luggage
// ---------------------------------------------------------------------
function makeBench(x, z) {
const group = new THREE.Group();
group.position.set(x, 0, z);
terminal.add(group);
// The bench faces the dock at negative Z.
roundedBox(group, 2.65, 0.18, 0.72, 0.11, M.wood, [0, 0.65, 0]);
roundedBox(group, 2.65, 0.72, 0.15, 0.11, M.wood, [0, 1.07, 0.34]);
for (const legX of [-0.93, 0.93]) {
roundedBox(
group,
0.13,
0.62,
0.58,
0.055,
M.blue,
[legX, 0.32, 0]
);
}
return group;
}
makeBench(4.95, 4.45);
makeBench(8.35, 4.45);
const luggage = new THREE.Group();
luggage.position.set(6.5, 0, 4.42);
terminal.add(luggage);
roundedBox(luggage, 0.74, 1.12, 0.42, 0.15, M.coral, [0, 0.64, 0]);
roundedBox(luggage, 0.51, 0.12, 0.08, 0.035, M.dark, [0, 1.17, 0]);
cylinderBetween(
luggage,
[-0.18, 1.18, 0],
[-0.18, 1.48, 0],
0.025,
M.dark
);
cylinderBetween(
luggage,
[0.18, 1.18, 0],
[0.18, 1.48, 0],
0.025,
M.dark
);
cylinderBetween(
luggage,
[-0.18, 1.48, 0],
[0.18, 1.48, 0],
0.028,
M.dark
);
for (const x of [-0.25, 0.25]) {
const wheel = new THREE.Mesh(
new THREE.SphereGeometry(0.09, 12, 8),
M.dark
);
wheel.position.set(x, 0.08, 0.08);
wheel.castShadow = true;
luggage.add(wheel);
}
// ---------------------------------------------------------------------
// Small working-terminal details
// ---------------------------------------------------------------------
function makePlanter(x, z) {
const group = new THREE.Group();
group.position.set(x, 0, z);
terminal.add(group);
const pot = new THREE.Mesh(
new THREE.CylinderGeometry(0.47, 0.36, 0.72, 18),
M.cream
);
pot.position.y = 0.36;
pot.castShadow = true;
pot.receiveShadow = true;
group.add(pot);
const foliage = new THREE.Group();
foliage.position.y = 0.8;
group.add(foliage);
for (let i = 0; i < 7; i++) {
const leaf = new THREE.Mesh(
new THREE.SphereGeometry(0.34, 12, 8),
i % 2 ? M.green : M.greenLight
);
const angle = i * 2.399;
leaf.position.set(
Math.cos(angle) * 0.22,
(i % 3) * 0.13,
Math.sin(angle) * 0.22
);
leaf.scale.set(0.85, 1.25, 0.72);
leaf.rotation.z = Math.cos(angle) * 0.35;
leaf.castShadow = true;
foliage.add(leaf);
}
}
makePlanter(-9.75, 6.1);
makePlanter(9.6, -5.7);
const bin = new THREE.Group();
bin.position.set(-9.7, 0, 2.8);
terminal.add(bin);
const binBody = new THREE.Mesh(
new THREE.CylinderGeometry(0.31, 0.27, 0.85, 18),
M.blue
);
binBody.position.y = 0.43;
binBody.castShadow = true;
bin.add(binBody);
const binLid = new THREE.Mesh(
new THREE.CylinderGeometry(0.34, 0.34, 0.12, 18),
M.navy
);
binLid.position.y = 0.91;
binLid.castShadow = true;
bin.add(binLid);
// ---------------------------------------------------------------------
// People
// ---------------------------------------------------------------------
function createWalkingPerson({
shirt,
pants,
skin,
hair
}) {
const root = new THREE.Group();
scene.add(root);
const torso = roundedBox(
root, 0.64, 0.76, 0.4, 0.16, shirt, [0, 1.12, 0]
);
const head = new THREE.Group();
head.position.set(0, 1.72, 0);
root.add(head);
const face = new THREE.Mesh(
new THREE.SphereGeometry(0.255, 18, 14),
skin
);
face.scale.set(0.94, 1.04, 0.92);
face.castShadow = true;
head.add(face);
const hairCap = new THREE.Mesh(
new THREE.SphereGeometry(0.265, 18, 12, 0, Math.PI * 2, 0, Math.PI * 0.55),
hair
);
hairCap.position.y = 0.055;
hairCap.scale.set(1, 0.82, 1);
hairCap.castShadow = true;
head.add(hairCap);
const nose = new THREE.Mesh(
new THREE.SphereGeometry(0.047, 10, 8),
skin
);
nose.position.set(0, -0.015, 0.238);
head.add(nose);
for (const eyeX of [-0.078, 0.078]) {
const eye = new THREE.Mesh(
new THREE.SphereGeometry(0.018, 8, 6),
M.dark
);
eye.position.set(eyeX, 0.045, 0.231);
head.add(eye);
}
function makeArm(x) {
const pivot = new THREE.Group();
pivot.position.set(x, 1.4, 0);
root.add(pivot);
const arm = new THREE.Mesh(
new THREE.CapsuleGeometry(0.105, 0.39, 5, 9),
shirt
);
arm.position.y = -0.255;
arm.castShadow = true;
pivot.add(arm);
const hand = new THREE.Mesh(
new THREE.SphereGeometry(0.115, 12, 8),
skin
);
hand.position.y = -0.51;
hand.castShadow = true;
pivot.add(hand);
return pivot;
}
function makeLeg(x) {
const pivot = new THREE.Group();
pivot.position.set(x, 0.76, 0);
root.add(pivot);
const leg = new THREE.Mesh(
new THREE.CapsuleGeometry(0.12, 0.43, 5, 9),
pants
);
leg.position.y = -0.285;
leg.castShadow = true;
pivot.add(leg);
const shoe = roundedBox(
pivot,
0.25,
0.14,
0.39,
0.065,
M.dark,
[0, -0.61, 0.075]
);
shoe.castShadow = true;
return pivot;
}
const armL = makeArm(-0.405);
const armR = makeArm(0.405);
const legL = makeLeg(-0.175);
const legR = makeLeg(0.175);
return {
root,
torso,
head,
armL,
armR,
legL,
legR
};
}
function createSeatedPerson({
shirt,
pants,
skin,
hair
}) {
const root = new THREE.Group();
root.position.set(4.82, 0, 4.43);
root.rotation.y = Math.PI;
scene.add(root);
roundedBox(root, 0.63, 0.72, 0.39, 0.15, shirt, [0, 1.12, 0]);
roundedBox(root, 0.54, 0.27, 0.43, 0.11, pants, [0, 0.73, 0.02]);
const head = new THREE.Group();
head.position.set(0, 1.72, 0);
root.add(head);
const face = new THREE.Mesh(
new THREE.SphereGeometry(0.255, 18, 14),
skin
);
face.scale.set(0.94, 1.04, 0.92);
face.castShadow = true;
head.add(face);
const hairCap = new THREE.Mesh(
new THREE.SphereGeometry(0.265, 18, 12, 0, Math.PI * 2, 0, Math.PI * 0.55),
hair
);
hairCap.position.y = 0.055;
hairCap.scale.set(1, 0.82, 1);
hairCap.castShadow = true;
head.add(hairCap);
for (const x of [-0.17, 0.17]) {
const thigh = new THREE.Mesh(
new THREE.CapsuleGeometry(0.12, 0.36, 5, 9),
pants
);
thigh.rotation.x = Math.PI / 2;
thigh.position.set(x, 0.75, 0.25);
thigh.castShadow = true;
root.add(thigh);
const shin = new THREE.Mesh(
new THREE.CapsuleGeometry(0.105, 0.34, 5, 9),
pants
);
shin.position.set(x, 0.39, 0.49);
shin.castShadow = true;
root.add(shin);
roundedBox(
root,
0.24,
0.14,
0.36,
0.06,
M.dark,
[x, 0.11, 0.59]
);
}
for (const x of [-0.39, 0.39]) {
const arm = new THREE.Mesh(
new THREE.CapsuleGeometry(0.10, 0.35, 5, 9),
shirt
);
arm.position.set(x, 1.02, 0.12);
arm.rotation.x = -0.65;
arm.castShadow = true;
root.add(arm);
const hand = new THREE.Mesh(
new THREE.SphereGeometry(0.10, 10, 8),
skin
);
hand.position.set(x, 0.82, 0.38);
root.add(hand);
}
}
const directVisitor = createWalkingPerson({
shirt: M.shirtA,
pants: M.pantsA,
skin: M.skinA,
hair: M.hairA
});
const deskVisitor = createWalkingPerson({
shirt: M.shirtB,
pants: M.pantsB,
skin: M.skinB,
hair: M.hairB
});
const attendant = createWalkingPerson({
shirt: M.cream,
pants: M.navy,
skin: M.skinB,
hair: M.hairA
});
attendant.root.position.set(6.25, 0, -2.62);
attendant.armL.rotation.x = -0.62;
attendant.armR.rotation.x = -0.62;
createSeatedPerson({
shirt: M.teal,
pants: M.navy,
skin: M.skinA,
hair: M.hairB
});
// ---------------------------------------------------------------------
// Tickets
// ---------------------------------------------------------------------
function makeTicket(symbol = "tide") {
const group = new THREE.Group();
roundedBox(group, 0.47, 0.32, 0.035, 0.055, M.white);
symbolTile(group, symbol, 0.205, 0.205, [-0.105, 0, 0.021]);
roundedBox(
group,
0.16,
0.025,
0.012,
0.008,
M.navy,
[0.105, 0.065, 0.022]
);
roundedBox(
group,
0.12,
0.022,
0.012,
0.007,
M.navy,
[0.11, 0.005, 0.022]
);
return group;
}
const directTicket = makeTicket("tide");
directTicket.position.set(0.01, -0.53, 0.115);
directTicket.rotation.x = -0.18;
directVisitor.armR.add(directTicket);
directTicket.visible = false;
const deskTicket = makeTicket("tide");
deskTicket.position.set(0.01, -0.53, 0.115);
deskTicket.rotation.x = -0.18;
deskVisitor.armR.add(deskTicket);
deskTicket.visible = false;
// Three sample tickets on the desk reinforce the same symbol system.
for (let i = 0; i < 3; i++) {
const type = Object.keys(SYMBOLS)[i];
const ticket = makeTicket(type);
ticket.rotation.x = -Math.PI / 2;
ticket.rotation.z = -0.12 + i * 0.12;
ticket.position.set(-0.7 + i * 0.48, 1.495, 0.30);
ticket.scale.setScalar(0.92);
desk.add(ticket);
}
// ---------------------------------------------------------------------
// Animation helpers
// ---------------------------------------------------------------------
function setWalkingPose(person, phase, active = true) {
const amount = active ? 1 : 0;
const swing = Math.sin(phase) * 0.58 * amount;
person.legL.rotation.x = swing;
person.legR.rotation.x = -swing;
person.armL.rotation.x = -swing * 0.82;
person.armR.rotation.x = swing * 0.82;
person.torso.rotation.x = active ? 0.035 : 0;
person.torso.position.y = active
? 1.12 + Math.abs(Math.sin(phase * 2)) * 0.018
: 1.12;
person.head.rotation.x = active ? -0.015 : 0;
}
function setInteractionPose(person, time) {
const pulse = Math.sin(time * 5.0) * 0.06;
person.legL.rotation.x = 0.03;
person.legR.rotation.x = -0.03;
person.armL.rotation.x = 0.18;
person.armR.rotation.x = 1.08 + pulse;
person.torso.rotation.x = 0.06;
person.head.rotation.x = 0.10;
}
function setIdlePose(person) {
person.legL.rotation.x = 0;
person.legR.rotation.x = 0;
person.armL.rotation.x = 0.03;
person.armR.rotation.x = -0.05;
person.torso.rotation.x = 0;
person.torso.position.y = 1.12;
person.head.rotation.x = 0;
}
function travel(person, from, to, progress, phase) {
const p = THREE.MathUtils.clamp(progress, 0, 1);
const eased = p * p * (3 - 2 * p);
person.root.position.x = THREE.MathUtils.lerp(from[0], to[0], eased);
person.root.position.z = THREE.MathUtils.lerp(from[1], to[1], eased);
const dx = to[0] - from[0];
const dz = to[1] - from[1];
person.root.rotation.y = Math.atan2(dx, dz);
setWalkingPose(person, phase, true);
}
const directStart = [-1.15, 7.85];
const directMachine = [-3.95, -1.20];
const directLane = [-0.34, -5.50];
const deskStart = [7.45, 8.00];
const deskPosition = [6.25, -0.20];
const deskLane = [0.34, -5.50];
function updateVisitors(elapsed) {
const t = elapsed % 24;
// Visitor A: goes directly to the ticket machine, buys, then boards.
if (t < 4.1) {
travel(
directVisitor,
directStart,
directMachine,
t / 4.1,
t * 8.2
);
directTicket.visible = false;
} else if (t < 6.4) {
directVisitor.root.position.set(directMachine[0], 0, directMachine[1]);
directVisitor.root.rotation.y = Math.PI;
setInteractionPose(directVisitor, t);
directTicket.visible = t > 5.65;
} else if (t < 11.4) {
travel(
directVisitor,
directMachine,
directLane,
(t - 6.4) / 5.0,
t * 8.2
);
directTicket.visible = true;
} else {
directVisitor.root.position.set(directLane[0], 0, directLane[1]);
directVisitor.root.rotation.y = Math.PI;
setIdlePose(directVisitor);
directVisitor.head.rotation.y = Math.sin(t * 0.7) * 0.12;
directTicket.visible = true;
}
// Visitor B: visits assistance first, receives a ticket, then boards.
if (t < 3.2) {
travel(
deskVisitor,
deskStart,
deskPosition,
t / 3.2,
t * 8.2 + 0.8
);
deskTicket.visible = false;
} else if (t < 6.0) {
deskVisitor.root.position.set(deskPosition[0], 0, deskPosition[1]);
deskVisitor.root.rotation.y = Math.PI;
setInteractionPose(deskVisitor, t);
deskTicket.visible = t > 5.15;
} else if (t < 11.4) {
travel(
deskVisitor,
deskPosition,
deskLane,
(t - 6.0) / 5.4,
t * 8.2 + 0.8
);
deskTicket.visible = true;
} else {
deskVisitor.root.position.set(deskLane[0], 0, deskLane[1]);
deskVisitor.root.rotation.y = Math.PI;
setIdlePose(deskVisitor);
deskVisitor.head.rotation.y = Math.sin(t * 0.65 + 1) * 0.11;
deskTicket.visible = true;
}
}
// ---------------------------------------------------------------------
// Render loop
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
updateVisitors(elapsed);
// Subtle emphasis on the Tide ticket option and its boarding sign.
const pulse = 1 + Math.sin(elapsed * 2.2) * 0.035;
machineRight.tideButton.scale.setScalar(pulse);
laneSignTiles[1].scale.setScalar(pulse);
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```