Prompt specification
Build or customize the Three.js 3D scene "Ferry passenger reaching a waterfront market stall" 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: Ferry passenger reaching a waterfront market stall
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/ferry-passenger-reaching-a-waterfront-market-stall-x2782
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts San Francisco's Ferry Building and Embarcadero. Create a compact terminal-edge vignette with pier, entrance, and original food stall. Show a continuous passenger route from boat landing to public promenade. Voxel style.
Working Three.js Starter (ferry-passenger-reaching-a-waterfront-market-stall-x2782):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ferry Building & the Embarcadero</title>
<style>
:root {
--ink: #173b45;
--paper: #fff9e9;
--muted: #54717a;
--accent: #ee8f3c;
--accent-soft: #ffe0aa;
--line: rgba(23, 59, 69, .16);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce9e8;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.panel {
position: fixed;
z-index: 5;
pointer-events: none;
}
#intro {
top: 24px;
left: 24px;
max-width: 390px;
padding: 18px 20px 17px;
border: 1px solid rgba(255,255,255,.65);
border-radius: 16px;
background: rgba(255, 249, 233, .88);
box-shadow: 0 12px 40px rgba(25, 61, 70, .12);
backdrop-filter: blur(12px);
}
.eyebrow {
margin-bottom: 7px;
color: var(--accent);
font-size: 10px;
font-weight: 850;
letter-spacing: .2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(24px, 3vw, 38px);
line-height: .98;
letter-spacing: -.045em;
}
#intro p:last-child {
margin: 10px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
#legend {
left: 24px;
bottom: 24px;
display: flex;
align-items: center;
gap: 13px;
padding: 12px 15px;
border: 1px solid rgba(255,255,255,.72);
border-radius: 13px;
background: rgba(255, 249, 233, .9);
box-shadow: 0 10px 35px rgba(25, 61, 70, .12);
backdrop-filter: blur(10px);
}
.legend-line {
position: relative;
width: 42px;
height: 6px;
overflow: hidden;
border-radius: 99px;
background: var(--accent);
}
.legend-line::after {
content: "";
position: absolute;
top: 1px;
left: 7px;
width: 13px;
height: 4px;
border-radius: 2px;
background: var(--paper);
}
#legend strong {
display: block;
font-size: 11px;
letter-spacing: .04em;
}
#legend span {
color: var(--muted);
font-size: 10px;
}
#controls {
right: 24px;
bottom: 24px;
display: flex;
gap: 8px;
align-items: center;
pointer-events: auto;
}
button {
border: 1px solid rgba(255,255,255,.7);
border-radius: 10px;
padding: 10px 13px;
background: rgba(255, 249, 233, .92);
color: var(--ink);
box-shadow: 0 8px 25px rgba(25, 61, 70, .12);
font: 700 11px/1 ui-sans-serif, system-ui, sans-serif;
cursor: pointer;
backdrop-filter: blur(10px);
}
button:hover { background: #fffdf5; }
button:active { transform: translateY(1px); }
.hint {
margin-right: 5px;
color: var(--muted);
font-size: 10px;
text-shadow: 0 1px 2px rgba(255,255,255,.8);
}
.world-label {
position: fixed;
z-index: 4;
padding: 7px 9px;
border: 1px solid rgba(255,255,255,.72);
border-radius: 8px;
background: rgba(255, 249, 233, .91);
box-shadow: 0 6px 18px rgba(23, 59, 69, .14);
color: var(--ink);
font-size: 9px;
font-weight: 850;
letter-spacing: .08em;
text-transform: uppercase;
pointer-events: none;
transform: translate(-50%, -115%);
white-space: nowrap;
backdrop-filter: blur(7px);
}
.world-label::before {
content: "";
display: inline-block;
width: 6px;
height: 6px;
margin-right: 6px;
border-radius: 50%;
background: var(--accent);
vertical-align: 1px;
}
@media (max-width: 700px) {
#intro {
top: 12px;
left: 12px;
right: 12px;
max-width: none;
padding: 13px 15px;
}
#intro p:last-child { display: none; }
#legend {
left: 12px;
bottom: 66px;
}
#controls {
right: 12px;
bottom: 12px;
}
.hint { display: none; }
.world-label { font-size: 8px; }
}
</style>
</head>
<body>
<div id="scene"></div>
<section id="intro" class="panel">
<div class="eyebrow">San Francisco · Waterfront Study</div>
<h1>Ferry Building<br>& the Embarcadero</h1>
<p>
A compact voxel vignette tracing a passenger’s continuous route from
a bay landing, along the pier and public promenade, to the Ferry Building.
</p>
</section>
<div id="legend" class="panel">
<div class="legend-line"></div>
<div>
<strong>Continuous passenger route</strong>
<span>Boat landing → promenade → terminal entrance</span>
</div>
</div>
<div id="controls" class="panel">
<span class="hint">Drag to orbit · Scroll to zoom</span>
<button id="routeButton" type="button">Hide route</button>
<button id="resetButton" type="button">Reset view</button>
</div>
<div id="label1" class="world-label">01 · Boat landing</div>
<div id="label2" class="world-label">02 · Public promenade</div>
<div id="label3" class="world-label">03 · Ferry Hall</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------------
// Renderer, camera, and lighting
// ------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce9e8);
scene.fog = new THREE.Fog(0xdce9e8, 48, 82);
const camera = new THREE.OrthographicCamera(-25, 25, 18, -18, 0.1, 120);
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.12;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel scene of San Francisco's Ferry Building and Embarcadero"
);
document.querySelector("#scene").appendChild(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xeaf8ff, 0x7d6854, 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffe9bd, 3.15);
sun.position.set(-15, 26, 18);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -24;
sun.shadow.camera.right = 24;
sun.shadow.camera.top = 24;
sun.shadow.camera.bottom = -24;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 65;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9ed7ea, 0.9);
fill.position.set(18, 12, -14);
scene.add(fill);
const orbit = {
yaw: 0.56,
pitch: 0.69,
radius: 45,
zoom: 1
};
const cameraTarget = new THREE.Vector3(0, 2.4, 1.4);
function applyCamera() {
const { yaw, pitch, radius } = orbit;
camera.position.set(
cameraTarget.x + radius * Math.sin(yaw) * Math.cos(pitch),
cameraTarget.y + radius * Math.sin(pitch),
cameraTarget.z + radius * Math.cos(yaw) * Math.cos(pitch)
);
camera.lookAt(cameraTarget);
camera.zoom = orbit.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const aspect = window.innerWidth / window.innerHeight;
const halfHeight = Math.max(18, 16 / aspect);
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.updateProjectionMatrix();
applyCamera();
}
window.addEventListener("resize", resize);
resize();
// ------------------------------------------------------------------
// Voxel construction helpers
// ------------------------------------------------------------------
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function material(color) {
const key = String(color);
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.02
})
);
}
return materialCache.get(key);
}
function box(parent, w, h, d, x, y, z, color, castShadow = true) {
const mat = color && color.isMaterial ? color : material(color);
const mesh = new THREE.Mesh(unitBox, mat);
mesh.scale.set(w, h, d);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeSign(
parent, width, height, x, y, z,
title, subtitle,
bg = "#173b45", fg = "#fff5d9"
) {
const group = new THREE.Group();
group.position.set(x, y, z);
parent.add(group);
box(group, width + 0.12, height + 0.12, 0.14, 0, 0, 0, bg);
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.fillStyle = bg;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = fg;
ctx.lineWidth = 9;
ctx.strokeRect(18, 18, canvas.width - 36, canvas.height - 36);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = fg;
ctx.font = "900 76px monospace";
ctx.fillText(title, 512, subtitle ? 100 : 130, 930);
if (subtitle) {
ctx.fillStyle = "#f3ad4c";
ctx.font = "700 29px monospace";
ctx.fillText(subtitle, 512, 182, 900);
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
const plane = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({ map: texture })
);
plane.position.z = 0.078;
group.add(plane);
return group;
}
const glass = new THREE.MeshStandardMaterial({
color: 0x245867,
roughness: 0.3,
metalness: 0.12
});
const darkGlass = new THREE.MeshStandardMaterial({
color: 0x163d49,
roughness: 0.28,
metalness: 0.14
});
const waterMaterial = new THREE.MeshStandardMaterial({
color: 0x5ea7b6,
roughness: 0.34,
metalness: 0.08
});
// ------------------------------------------------------------------
// Diorama base, bay, promenade, and Embarcadero roadway
// ------------------------------------------------------------------
const diorama = new THREE.Group();
scene.add(diorama);
box(diorama, 29, 0.7, 22, 0, -0.82, 1.05, 0x284c58);
box(diorama, 28.8, 0.25, 12.2, 0, -0.325, 6.0, waterMaterial, false);
box(diorama, 28.8, 0.55, 10, 0, -0.1, -4.8, 0xc9bea7);
// Public waterfront promenade.
box(diorama, 28.5, 0.28, 3.15, 0, 0.25, 1.1, 0xe9dfc9);
// Subtle promenade paving joints.
for (let x = -12; x <= 13; x += 2) {
box(diorama, 0.035, 0.018, 2.95, x, 0.401, 1.1, 0xc7baa4, false);
}
for (const z of [0.05, 1.1, 2.15]) {
box(diorama, 28.2, 0.018, 0.035, 0, 0.402, z, 0xc7baa4, false);
}
// Embarcadero roadway between the promenade and terminal.
box(diorama, 28.4, 0.22, 1.55, 0, 0.245, -1.08, 0x536469);
for (let x = -12; x <= 13; x += 2.8) {
box(diorama, 1.25, 0.022, 0.08, x, 0.368, -1.08, 0xf3e9d2, false);
}
// Pixelated water highlights.
let seed = 17;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
for (let i = 0; i < 115; i++) {
const x = -13.5 + random() * 27;
const z = 0.25 + random() * 11.4;
if (x > -7.1 && x < -0.9 && z > 2.2 && z < 11.1) continue;
const w = 0.25 + random() * 0.9;
const d = 0.045 + random() * 0.055;
const waveColor = random() > 0.48 ? 0x9bd1d3 : 0x78bdc6;
box(
diorama, w, 0.018, d,
x, -0.184 + random() * 0.015, z,
waveColor, false
);
}
// ------------------------------------------------------------------
// Ferry Building
// ------------------------------------------------------------------
const terminal = new THREE.Group();
diorama.add(terminal);
box(terminal, 13.1, 0.28, 5.65, 7, 0.35, -4.9, 0xd5c9b3);
box(terminal, 12.4, 3.15, 5.0, 7, 1.93, -4.9, 0xe9dfc7);
box(terminal, 12.85, 0.28, 5.32, 7, 3.57, -4.9, 0xf2e8ce);
box(terminal, 12.45, 0.22, 5.02, 7, 3.78, -4.9, 0xc4b89f);
// Waterfront arcade and door bays.
const bayXs = [2.15, 4.0, 9.85, 11.65];
for (const x of bayXs) {
box(terminal, 1.35, 1.85, 0.12, x, 1.52, -2.34, darkGlass);
box(terminal, 1.52, 0.16, 0.2, x, 0.66, -2.28, 0xcbbfa6);
box(terminal, 1.48, 0.16, 0.2, x, 2.45, -2.28, 0xd7cbb2);
}
for (const x of [1.3, 3.1, 4.8, 8.9, 10.7, 12.45]) {
box(terminal, 0.28, 2.65, 0.28, x, 1.67, -2.22, 0xf3e9cf);
}
// Central public entrance.
box(terminal, 2.45, 2.45, 0.13, 7, 1.54, -2.34, darkGlass);
box(terminal, 0.12, 2.4, 0.18, 7, 1.55, -2.20, 0xe9ddc2);
box(terminal, 2.7, 0.18, 0.35, 7, 0.59, -2.20, 0xf2e8cd);
box(terminal, 2.62, 0.15, 0.25, 7, 2.78, -2.23, 0xc9bda5);
// Upper-story windows.
for (const x of [2.2, 3.65, 5.05, 8.95, 10.35, 11.75]) {
box(terminal, 0.73, 0.68, 0.12, x, 3.02, -2.34, glass);
box(terminal, 0.86, 0.12, 0.2, x, 2.65, -2.25, 0xf2e7cd);
}
// Clock tower.
box(terminal, 3.85, 0.34, 3.85, 7, 3.96, -4.9, 0xd4c8ae);
box(terminal, 3.4, 4.62, 3.4, 7, 6.19, -4.9, 0xeee3c9);
box(terminal, 3.72, 0.25, 3.72, 7, 8.57, -4.9, 0xf3e9d0);
box(terminal, 3.0, 0.72, 3.0, 7, 9.01, -4.9, 0x315b61);
box(terminal, 2.3, 0.58, 2.3, 7, 9.61, -4.9, 0x3b686c);
box(terminal, 1.55, 0.52, 1.55, 7, 10.10, -4.9, 0xe9dec5);
// Tower openings.
for (const y of [4.8, 5.8]) {
box(terminal, 0.58, 0.75, 0.11, 7, y, -3.16, glass);
}
// Voxel clock faces.
function makeClockFace(parent, x, y, z, rotationY) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotationY;
parent.add(group);
box(group, 1.68, 1.68, 0.09, 0, 0, 0, darkGlass);
const step = 0.118;
for (let ix = -6; ix <= 6; ix++) {
for (let iy = -6; iy <= 6; iy++) {
const r = Math.hypot(ix, iy);
if (r >= 4.25 && r <= 5.15) {
box(
group, 0.112, 0.112, 0.07,
ix * step, iy * step, 0.075,
0xf2c76d
);
}
}
}
const hourHand = box(group, 0.09, 0.55, 0.08, 0, 0, 0.145, 0xf2c76d);
hourHand.rotation.z = 0.66;
const minuteHand = box(group, 0.075, 0.43, 0.08, 0, 0, 0.16, 0xf2c76d);
minuteHand.rotation.z = -1.02;
box(group, 0.16, 0.16, 0.09, 0, 0, 0.19, 0xee8f3c);
}
makeClockFace(terminal, 7, 7.13, -3.16, 0);
makeClockFace(terminal, 8.74, 7.13, -4.9, Math.PI / 2);
// Roof flag.
box(terminal, 0.08, 1.75, 0.08, 7, 11.15, -4.9, 0x3d5153);
box(terminal, 0.85, 0.45, 0.055, 7.43, 11.69, -4.9, 0xdc654d);
makeSign(
terminal, 5.7, 0.73, 7, 3.14, -2.18,
"FERRY BUILDING", "SAN FRANCISCO · 1898"
);
// ------------------------------------------------------------------
// Promenade railing, lamps, benches, and planters
// ------------------------------------------------------------------
function railingSegment(x1, x2, z, baseY, postHeight = 0.72) {
const length = x2 - x1;
box(
diorama, length, 0.09, 0.10,
(x1 + x2) / 2, baseY + postHeight, z,
0x315b61
);
for (let x = x1; x <= x2 + 0.01; x += 1.65) {
box(diorama, 0.10, postHeight, 0.10, x, baseY + postHeight / 2, z, 0x315b61);
box(diorama, 0.21, 0.08, 0.21, x, baseY + 0.04, z, 0x24494f);
}
}
railingSegment(-12.8, -7.1, 2.63, 0.4);
railingSegment(-0.9, 13.4, 2.63, 0.4);
function lamp(x, z) {
box(diorama, 0.46, 0.12, 0.46, x, 0.46, z, 0x31565b);
box(diorama, 0.10, 2.25, 0.10, x, 1.57, z, 0x294c52);
box(diorama, 0.48, 0.13, 0.48, x, 2.69, z, 0x294c52);
const glow = new THREE.MeshStandardMaterial({
color: 0xffd994,
emissive: 0xffc966,
emissiveIntensity: 0.7,
roughness: 0.5
});
box(diorama, 0.34, 0.36, 0.34, x, 2.48, z, glow, false);
}
lamp(-11.4, 2.25);
lamp(10.7, 2.25);
lamp(12.7, -0.12);
function bench(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.4, z);
group.rotation.y = rotation;
diorama.add(group);
box(group, 2.25, 0.14, 0.54, 0, 0.48, 0, 0xa86f45);
box(group, 2.25, 0.58, 0.13, 0, 0.80, -0.22, 0xb77a49);
box(group, 0.14, 0.47, 0.54, -0.85, 0.23, 0, 0x31565b);
box(group, 0.14, 0.47, 0.54, 0.85, 0.23, 0, 0x31565b);
}
bench(-9.1, 0.05, Math.PI);
bench(11.9, 0.05, Math.PI);
function planter(x, z) {
box(diorama, 1.25, 0.55, 1.25, x, 0.69, z, 0xb69a77);
box(diorama, 1.05, 0.12, 1.05, x, 1.01, z, 0x5a4b37);
box(diorama, 0.18, 1.1, 0.18, x, 1.47, z, 0x795c3f);
box(diorama, 0.88, 0.72, 0.88, x, 2.08, z, 0x668b5d);
box(diorama, 0.65, 0.48, 0.68, x - 0.15, 2.54, z + 0.08, 0x789e66);
}
planter(-12.1, 0.3);
planter(13.0, 0.25);
makeSign(
diorama, 4.15, 0.74, -9.7, 1.45, 2.52,
"THE EMBARCADERO", "PUBLIC WATERFRONT",
"#173b45", "#fff5d9"
);
// ------------------------------------------------------------------
// Pier and boat landing
// ------------------------------------------------------------------
const pier = new THREE.Group();
diorama.add(pier);
box(pier, 5.4, 0.35, 8.35, -4, 0.385, 6.55, 0x795b43);
for (let i = 0; i < 23; i++) {
const z = 2.47 + i * 0.36;
const plankColor = i % 2 ? 0xb48250 : 0xc39158;
box(pier, 5.25, 0.045, 0.325, -4, 0.579, z, plankColor);
}
box(pier, 5.4, 0.16, 1.05, -4, 0.565, 10.38, 0xb9804e);
// Pilings.
for (const x of [-6.35, -1.65]) {
for (const z of [3.0, 5.1, 7.25, 9.4]) {
box(pier, 0.34, 1.75, 0.34, x, -0.02, z, 0x584739);
box(pier, 0.42, 0.16, 0.42, x, 0.56, z, 0x8b6949);
}
}
// Pier side rails.
for (const x of [-6.66, -1.34]) {
box(pier, 0.09, 0.09, 7.7, x, 1.23, 6.25, 0x315b61);
for (let z = 2.6; z <= 10.0; z += 1.45) {
box(pier, 0.10, 0.67, 0.10, x, 0.91, z, 0x315b61);
}
}
// Short gangway to the ferry.
box(pier, 1.38, 0.16, 1.25, -6.52, 0.55, 9.45, 0x9a7650);
for (let i = 0; i < 5; i++) {
box(pier, 0.12, 0.025, 1.08, -7.12 + i * 0.3, 0.646, 9.45, 0xc08e56, false);
}
// ------------------------------------------------------------------
// Voxel bay ferry
// ------------------------------------------------------------------
const boat = new THREE.Group();
boat.position.set(-8.62, 0, 9.62);
diorama.add(boat);
box(boat, 3.2, 0.88, 4.8, 0, 0.02, 0, 0x244e5b);
box(boat, 3.28, 0.20, 4.72, 0, 0.38, 0, 0xe76d4e);
box(boat, 2.75, 0.20, 4.35, 0, 0.54, 0, 0xf1dfbd);
// Stepped bow and stern.
box(boat, 2.45, 0.72, 0.64, 0, 0.04, 2.56, 0x244e5b);
box(boat, 1.55, 0.62, 0.48, 0, 0.07, 3.02, 0x244e5b);
box(boat, 2.3, 0.72, 0.55, 0, 0.04, -2.48, 0x244e5b);
box(boat, 2.45, 1.16, 3.48, 0, 1.22, -0.10, 0xf4e6c9);
box(boat, 2.68, 0.16, 3.72, 0, 1.87, -0.10, 0x2f6068);
// Window blocks.
for (const z of [-1.3, -0.48, 0.34, 1.15]) {
box(boat, 0.09, 0.52, 0.58, 1.27, 1.34, z, darkGlass);
box(boat, 0.09, 0.52, 0.58, -1.27, 1.34, z, darkGlass);
}
box(boat, 1.62, 0.70, 1.45, 0, 2.26, -0.70, 0xf1e4c5);
box(boat, 1.82, 0.15, 1.65, 0, 2.67, -0.70, 0x315f65);
box(boat, 1.30, 0.42, 0.08, 0, 2.30, -0.02, darkGlass);
box(boat, 0.28, 1.25, 0.28, -0.72, 3.12, -0.86, 0xe56e4d);
box(boat, 0.38, 0.20, 0.38, -0.72, 3.79, -0.86, 0x2c4247);
box(boat, 0.07, 1.7, 0.07, 0.70, 3.42, 0.45, 0x40565a);
box(boat, 0.62, 0.34, 0.055, 0.98, 4.02, 0.45, 0xf0ae45);
makeSign(
boat, 2.15, 0.46, 0, 0.18, 2.41,
"BAY FERRY", "EMBARCADERO"
);
// Water foam around the hull.
for (let i = 0; i < 22; i++) {
const x = -10.2 + random() * 3.2;
const z = 6.9 + random() * 5.3;
box(diorama, 0.3 + random() * 0.7, 0.018, 0.07, x, -0.17, z, 0xc2e1df, false);
}
// ------------------------------------------------------------------
// Original food stall: Brine & Bun
// ------------------------------------------------------------------
const stall = new THREE.Group();
stall.position.set(-0.25, 0.4, -0.38);
diorama.add(stall);
box(stall, 3.25, 1.35, 1.50, 0, 0.73, 0, 0xd96d51);
box(stall, 3.42, 0.18, 1.66, 0, 0.12, 0, 0x31565b);
box(stall, 3.50, 0.16, 1.72, 0, 1.47, 0, 0xf2e3c4);
// Wheels and supports.
for (const x of [-1.25, 1.25]) {
box(stall, 0.22, 0.48, 0.42, x, 0.28, 0.48, 0x2b4b50);
box(stall, 0.10, 0.74, 0.10, x, 1.76, 0.57, 0x31565b);
}
// Serving counter.
box(stall, 3.65, 0.18, 0.48, 0, 1.25, 0.70, 0xf2dfb7);
box(stall, 3.45, 0.08, 0.10, 0, 1.36, 0.96, 0xe8b455);
// Striped awning.
for (let i = 0; i < 8; i++) {
const x = -1.58 + i * 0.45;
const awningColor = i % 2 ? 0xf5e8c9 : 0x397176;
box(stall, 0.45, 0.13, 1.95, x, 1.86, 0.22, awningColor);
box(stall, 0.45, 0.35, 0.12, x, 1.67, 1.15, awningColor);
}
makeSign(
stall, 3.35, 0.74, 0, 2.42, 0.20,
"BRINE & BUN", "SMOKE & SANDWICHES",
"#173b45", "#fff1cf"
);
// Food and drink details on the counter.
box(stall, 0.52, 0.18, 0.42, -0.90, 1.43, 0.69, 0xd58a3e);
box(stall, 0.45, 0.07, 0.36, -0.90, 1.55, 0.69, 0xf0b654);
box(stall, 0.28, 0.42, 0.28, -0.30, 1.55, 0.68, 0xf2dfb7);
box(stall, 0.18, 0.08, 0.18, 0.02, 1.56, 0.68, 0x7d4d2c);
box(stall, 0.65, 0.28, 0.08, 1.18, 1.57, 0.50, 0x31565b);
// A small menu chalkboard.
box(stall, 0.12, 1.02, 0.12, 1.90, 0.88, 0.32, 0x795c3f);
box(stall, 0.82, 1.08, 0.13, 2.27, 1.30, 0.24, 0x244c50);
for (let i = 0; i < 4; i++) {
box(stall, 0.46 - i * 0.045, 0.045, 0.03, 2.24, 1.61 - i * 0.20, 0.315, 0xf2ddac, false);
}
// Small animated steam voxels.
const steam = [];
for (let i = 0; i < 3; i++) {
const steamMaterial = new THREE.MeshStandardMaterial({
color: 0xf4f5ed,
transparent: true,
opacity: 0.6,
depthWrite: false,
roughness: 1
});
const puff = new THREE.Mesh(unitBox, steamMaterial);
puff.scale.set(0.12, 0.16, 0.12);
puff.position.set(-0.28 + i * 0.16, 1.8, 0.64);
puff.castShadow = false;
stall.add(puff);
steam.push({ mesh: puff, offset: i * 0.32, x: puff.position.x });
}
// ------------------------------------------------------------------
// Continuous pedestrian route
// ------------------------------------------------------------------
const routeGroup = new THREE.Group();
diorama.add(routeGroup);
const routeColor = 0xee8f3c;
// Pier segment.
box(routeGroup, 1.46, 0.055, 8.38, -4, 0.627, 6.57, routeColor, false);
// Promenade segment.
box(routeGroup, 11.45, 0.055, 1.42, 1.33, 0.43, 1.35, routeColor, false);
// Crossing and terminal approach.
box(routeGroup, 1.42, 0.055, 3.95, 7, 0.43, -0.63, routeColor, false);
// Pale crossing bars under the amber route.
for (let i = 0; i < 8; i++) {
box(
routeGroup, 2.42, 0.025, 0.17,
7, 0.37, -1.95 + i * 0.20,
0xf4ead2, false
);
}
function routeArrow(x, y, z, rotation) {
const arrow = new THREE.Group();
arrow.position.set(x, y, z);
arrow.rotation.y = rotation;
box(arrow, 0.17, 0.025, 0.48, 0, 0, -0.03, 0xfff0c9, false);
box(arrow, 0.58, 0.025, 0.13, 0, 0, 0.22, 0xfff0c9, false);
box(arrow, 0.42, 0.025, 0.13, 0, 0, 0.34, 0xfff0c9, false);
box(arrow, 0.24, 0.025, 0.13, 0, 0, 0.46, 0xfff0c9, false);
routeGroup.add(arrow);
}
// Local arrows point toward +Z, then are rotated for each segment.
routeArrow(-4, 0.675, 9.25, Math.PI);
routeArrow(-4, 0.675, 7.1, Math.PI);
routeArrow(-4, 0.675, 4.85, Math.PI);
routeArrow(-2.4, 0.482, 1.35, Math.PI / 2);
routeArrow(1.0, 0.482, 1.35, Math.PI / 2);
routeArrow(4.2, 0.482, 1.35, Math.PI / 2);
routeArrow(7, 0.482, 0.15, Math.PI);
routeArrow(7, 0.482, -1.65, Math.PI);
// ------------------------------------------------------------------
// Voxel passengers
// ------------------------------------------------------------------
function person(x, y, z, jacket, skin = 0xdca77d, rotation = 0, bag = true) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
diorama.add(group);
box(group, 0.19, 0.48, 0.20, -0.14, 0.25, 0, 0x29454e);
box(group, 0.19, 0.48, 0.20, 0.14, 0.25, 0, 0x29454e);
box(group, 0.46, 0.61, 0.31, 0, 0.78, 0, jacket);
box(group, 0.32, 0.33, 0.31, 0, 1.27, 0, skin);
box(group, 0.34, 0.10, 0.32, 0, 1.47, 0, 0x4a4038);
box(group, 0.13, 0.45, 0.17, -0.31, 0.77, 0, jacket);
box(group, 0.13, 0.45, 0.17, 0.31, 0.77, 0, jacket);
if (bag) {
box(group, 0.30, 0.38, 0.22, 0.48, 0.24, 0.03, 0x9d6048);
box(group, 0.035, 0.52, 0.035, 0.48, 0.69, 0.03, 0x5e493d);
}
}
person(-4.00, 0.66, 9.30, 0xd75d48, 0xc98d67, 0.1);
person(-4.24, 0.66, 7.20, 0x32717a, 0xe1b58c, -0.2);
person(-3.78, 0.66, 4.85, 0xd6a33f, 0x8e5d43, 0.3, false);
person(-2.55, 0.47, 1.35, 0x315b71, 0xd9a179, Math.PI / 2);
person(0.72, 0.47, 1.35, 0xd96b4e, 0x80513d, Math.PI / 2);
person(3.42, 0.47, 1.35, 0xe0bd68, 0xe0ad82, Math.PI / 2, false);
person(7.00, 0.47, -0.10, 0x55846e, 0xb87551, Math.PI);
person(7.00, 0.47, -1.72, 0xe59745, 0xe5bd93, Math.PI);
// ------------------------------------------------------------------
// Projected scene labels
// ------------------------------------------------------------------
const labels = [
{
element: document.querySelector("#label1"),
point: new THREE.Vector3(-4.1, 1.25, 10.55)
},
{
element: document.querySelector("#label2"),
point: new THREE.Vector3(-0.4, 1.0, 1.35)
},
{
element: document.querySelector("#label3"),
point: new THREE.Vector3(7, 2.0, -2.25)
}
];
function updateLabels() {
for (const label of labels) {
const p = label.point.clone().project(camera);
const visible = p.z > -1 && p.z < 1;
label.element.style.display = visible ? "block" : "none";
label.element.style.left = `${(p.x * 0.5 + 0.5) * window.innerWidth}px`;
label.element.style.top = `${(-p.y * 0.5 + 0.5) * window.innerHeight}px`;
}
}
// ------------------------------------------------------------------
// Direct camera controls — no Three.js addons
// ------------------------------------------------------------------
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
orbit.yaw -= dx * 0.006;
orbit.pitch = THREE.MathUtils.clamp(orbit.pitch + dy * 0.004, 0.34, 1.16);
applyCamera();
});
function endDrag(event) {
dragging = false;
if (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();
orbit.zoom = THREE.MathUtils.clamp(
orbit.zoom * Math.exp(-event.deltaY * 0.001),
0.65,
1.65
);
applyCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", resetView);
window.addEventListener("keydown", event => {
if (event.key === "ArrowLeft") orbit.yaw += 0.09;
else if (event.key === "ArrowRight") orbit.yaw -= 0.09;
else if (event.key === "ArrowUp") orbit.pitch = Math.min(1.16, orbit.pitch + 0.06);
else if (event.key === "ArrowDown") orbit.pitch = Math.max(0.34, orbit.pitch - 0.06);
else return;
applyCamera();
});
function resetView() {
orbit.yaw = 0.56;
orbit.pitch = 0.69;
orbit.zoom = 1;
cameraTarget.set(0, 2.4, 1.4);
applyCamera();
}
document.querySelector("#resetButton").addEventListener("click", resetView);
const routeButton = document.querySelector("#routeButton");
routeButton.addEventListener("click", () => {
routeGroup.visible = !routeGroup.visible;
routeButton.textContent = routeGroup.visible ? "Hide route" : "Show route";
});
// ------------------------------------------------------------------
// Animation
// ------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
boat.position.y = Math.sin(elapsed * 1.15) * 0.035;
boat.rotation.z = Math.sin(elapsed * 0.78) * 0.008;
boat.rotation.x = Math.cos(elapsed * 0.91) * 0.004;
for (const puff of steam) {
const cycle = (elapsed * 0.42 + puff.offset) % 1.1;
puff.mesh.position.y = 1.78 + cycle;
puff.mesh.position.x = puff.x + Math.sin(elapsed * 1.6 + puff.offset) * 0.07;
const scale = 0.10 + cycle * 0.14;
puff.mesh.scale.set(scale, scale * 1.25, scale);
puff.mesh.material.opacity = 0.62 * (1 - cycle / 1.1);
}
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
applyCamera();
animate();
</script>
</body>
</html>
```