Prompt specification
Build or customize the Three.js 3D scene "Small ferry unloading beside a market path" 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 unloading beside a market path
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/small-ferry-unloading-beside-a-market-path-x2794
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows a compact Granville Island vignette with ferry landing, waiting passengers, and market entrance. Keep boarding and through-walking routes separate at the narrow dock access. Low-poly.
Working Three.js Starter (small-ferry-unloading-beside-a-market-path-x2794):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Granville Island — Ferry Landing & Market</title>
<style>
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b9dfe4;
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;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.panel {
position: fixed;
z-index: 10;
color: #173f45;
background: rgba(255, 255, 255, 0.88);
border: 1px solid rgba(255, 255, 255, 0.72);
box-shadow: 0 8px 28px rgba(25, 67, 75, 0.14);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
pointer-events: none;
}
#title {
top: 22px;
left: 22px;
padding: 15px 18px 14px;
border-radius: 14px;
}
#title h1 {
margin: 0;
font-size: clamp(20px, 2.2vw, 31px);
line-height: 1;
letter-spacing: -0.04em;
}
#title p {
margin: 7px 0 0;
font-size: 12px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #527078;
}
#legend {
top: 22px;
right: 22px;
width: min(310px, calc(100vw - 44px));
padding: 14px 16px;
border-radius: 14px;
}
#legend h2 {
margin: 0 0 10px;
font-size: 12px;
letter-spacing: 0.1em;
text-transform: uppercase;
color: #527078;
}
.route-key {
display: flex;
align-items: center;
gap: 10px;
margin: 8px 0;
font-size: 13px;
font-weight: 750;
}
.swatch {
width: 27px;
height: 8px;
flex: 0 0 auto;
border-radius: 999px;
}
.swatch.boarding { background: #f2a33a; }
.swatch.through { background: #1599aa; }
#legend .note {
margin: 11px 0 0;
padding-top: 10px;
border-top: 1px solid #d9e5e5;
font-size: 12px;
line-height: 1.45;
color: #527078;
}
#help {
left: 22px;
bottom: 20px;
padding: 9px 12px;
border-radius: 10px;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.025em;
color: #527078;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #b9dfe4;
color: #315e65;
font-size: 14px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
transition: opacity 0.35s ease;
pointer-events: none;
}
#loading.hidden { opacity: 0; }
@media (max-width: 700px) {
#title { top: 12px; left: 12px; padding: 12px 14px; }
#legend { top: auto; right: 12px; bottom: 12px; width: 245px; }
#help { display: none; }
}
</style>
</head>
<body>
<div id="title" class="panel">
<h1>Granville Island</h1>
<p>Ferry landing · Public Market</p>
</div>
<div id="legend" class="panel">
<h2>Route separation</h2>
<div class="route-key">
<span class="swatch boarding"></span>
<span>Boarding to ferry</span>
</div>
<div class="route-key">
<span class="swatch through"></span>
<span>Through walk to market</span>
</div>
<p class="note">
A centre rail divides the narrow dock access so boarding passengers do not
cross the through route.
</p>
</div>
<div id="help" class="panel">Drag to orbit · Wheel to zoom · Double-click to reset</div>
<div id="loading">Building the island…</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(0xb9dfe4);
scene.fog = new THREE.Fog(0xb9dfe4, 29, 58);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
document.body.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-12, 12, 8, -8, 0.1, 100);
const cameraTarget = new THREE.Vector3(-1.35, 0.9, 0);
const view = {
yaw: 0.74,
pitch: 0.93,
zoom: 1,
radius: 28
};
const hemi = new THREE.HemisphereLight(0xe7f7ff, 0x8d755e, 2.0);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff1d0, 3.0);
sun.position.set(-7, 16, 10);
sun.target.position.set(-1, 0, 0);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -17;
sun.shadow.camera.right = 17;
sun.shadow.camera.top = 15;
sun.shadow.camera.bottom = -15;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 42;
sun.shadow.bias = -0.0004;
scene.add(sun, sun.target);
const fill = new THREE.DirectionalLight(0x9ed6ea, 0.75);
fill.position.set(12, 8, -10);
scene.add(fill);
// -------------------------------------------------------------------------
// Materials and reusable helpers
// -------------------------------------------------------------------------
const material = (color, extra = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.9,
metalness: 0,
flatShading: true,
...extra
});
const M = {
water: material(0x70aeb8, { roughness: 0.62, metalness: 0.04 }),
stone: material(0x9e8d78),
stoneDark: material(0x766a5e),
paving: material(0xcbbfa8),
pavingLine: material(0xb4a892),
dock: material(0x806b58),
wood: material(0xb88958),
woodDark: material(0x5d493b),
white: material(0xf2eee3),
cream: material(0xd8c8a6),
teal: material(0x1b6c70),
roof: material(0x365f5d),
coral: material(0xc96d56),
yellow: material(0xf2b735),
blue: material(0x17647d),
window: material(0x244f5b, { roughness: 0.35, metalness: 0.08 }),
orange: material(0xf2a33a),
routeOrange: material(0xf2a33a, {
emissive: 0xf2a33a,
emissiveIntensity: 0.12
}),
routeTeal: material(0x1599aa, {
emissive: 0x1599aa,
emissiveIntensity: 0.14
}),
metal: material(0x687b7c, { roughness: 0.55, metalness: 0.25 }),
dark: material(0x263b40),
foliage: material(0x4d8b61),
foliageLight: material(0x72a66b),
trunk: material(0x7b5a42),
red: material(0xc84f43),
whiteRoute: material(0xe9e7dc)
};
function box(w, h, d, mat, x = 0, y = 0, z = 0, parent = scene, cast = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(rt, rb, h, segments, mat, x = 0, y = 0, z = 0, parent = scene) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(rt, rb, h, segments),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function sign(text, w, h, bg, fg, x, y, z, parent = scene, rotationY = 0) {
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 = 10;
ctx.strokeRect(10, 10, canvas.width - 20, canvas.height - 20);
const lines = text.split("\n");
const largest = Math.max(...lines.map(line => line.length));
let fontSize = Math.min(98, 900 / Math.max(largest, 1));
ctx.font = `900 ${fontSize}px Arial, sans-serif`;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = fg;
if (lines.length === 1) {
ctx.fillText(text, 512, 136);
} else {
fontSize = Math.min(76, 900 / Math.max(largest, 1));
ctx.font = `900 ${fontSize}px Arial, sans-serif`;
lines.forEach((line, i) => {
ctx.fillText(line, 512, 91 + i * 78);
});
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(w, h),
new THREE.MeshBasicMaterial({
map: texture,
side: THREE.DoubleSide
})
);
mesh.position.set(x, y, z);
mesh.rotation.y = rotationY;
parent.add(mesh);
return mesh;
}
function railing(x1, z1, x2, z2, mat = M.metal, parent = scene) {
const dx = x2 - x1;
const dz = z2 - z1;
const length = Math.hypot(dx, dz);
const count = Math.max(1, Math.ceil(length / 0.82));
for (let i = 0; i <= count; i++) {
const t = i / count;
cylinder(
0.045, 0.055, 1.05, 6, mat,
x1 + dx * t, 1.28, z1 + dz * t, parent
);
}
const direction = new THREE.Vector3(dx, 0, dz).normalize();
const up = new THREE.Vector3(0, 1, 0);
for (const y of [1.47, 1.73]) {
const rail = cylinder(
0.035, 0.035, length, 6, mat,
(x1 + x2) / 2, y, (z1 + z2) / 2, parent
);
rail.quaternion.setFromUnitVectors(up, direction);
}
}
function makeGableRoof(w, d, h, mat, x, y, z) {
const p = [
-w/2, 0, d/2, 0, h, d/2, w/2, 0, d/2,
w/2, 0, -d/2, 0, h, -d/2, -w/2, 0, -d/2,
-w/2, 0, d/2, 0, h, -d/2, -w/2, 0, -d/2,
-w/2, 0, d/2, 0, h, d/2, 0, h, -d/2,
w/2, 0, d/2, 0, h, -d/2, w/2, 0, -d/2,
w/2, 0, d/2, 0, h, d/2, 0, h, -d/2,
-w/2, 0, d/2, -w/2, 0, -d/2, w/2, 0, -d/2,
-w/2, 0, d/2, w/2, 0, -d/2, w/2, 0, d/2
];
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute(p, 3));
geometry.computeVertexNormals();
const roofMaterial = mat.clone();
roofMaterial.side = THREE.DoubleSide;
const mesh = new THREE.Mesh(geometry, roofMaterial);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
function archShape(w, h) {
const s = new THREE.Shape();
const r = w / 2;
s.moveTo(-r, 0);
s.lineTo(r, 0);
s.lineTo(r, h - r);
s.absarc(0, h - r, r, 0, Math.PI, false);
s.lineTo(-r, 0);
return s;
}
// -------------------------------------------------------------------------
// Water, quay, dock, and paving
// -------------------------------------------------------------------------
const water = new THREE.Mesh(new THREE.PlaneGeometry(90, 90), M.water);
water.rotation.x = -Math.PI / 2;
water.position.y = -0.5;
water.receiveShadow = true;
scene.add(water);
const waveMaterials = [
new THREE.MeshBasicMaterial({
color: 0xd0eef0, transparent: true, opacity: 0.28,
side: THREE.DoubleSide, depthWrite: false
}),
new THREE.MeshBasicMaterial({
color: 0x4f939e, transparent: true, opacity: 0.19,
side: THREE.DoubleSide, depthWrite: false
})
];
for (let i = 0; i < 56; i++) {
const g = new THREE.BufferGeometry();
g.setAttribute(
"position",
new THREE.Float32BufferAttribute([
-1, 0, 0,
1, 0, 0,
0.25, 0, 0.35
], 3)
);
const wave = new THREE.Mesh(g, waveMaterials[i % 2]);
const side = i < 28 ? -1 : 1;
wave.position.set(
side * (7 + Math.random() * 31),
-0.475,
-17 + Math.random() * 34
);
wave.rotation.y = Math.random() * Math.PI;
wave.scale.set(
0.35 + Math.random() * 1.2,
1,
0.35 + Math.random() * 0.8
);
scene.add(wave);
}
// Main seawall and promenade.
box(15.6, 1.0, 8.0, M.stone, 0.5, 0.25, 0.5);
box(15.42, 0.10, 7.82, M.paving, 0.5, 0.75, 0.5);
// Paving joints.
for (let x = -6; x <= 7; x += 2) {
box(0.025, 0.012, 7.6, M.pavingLine, x, 0.806, 0.5, scene, false);
}
for (let z = -3; z <= 4; z += 2) {
box(15.2, 0.012, 0.025, M.pavingLine, 0.5, 0.807, z, scene, false);
}
// Dark waterline and timber pilings.
box(15.7, 0.16, 8.12, M.stoneDark, 0.5, -0.02, 0.5);
for (const x of [-6.5, -4, -1.5, 1, 3.5, 6, 7.8]) {
cylinder(0.15, 0.18, 1.35, 7, M.woodDark, x, 0.05, 4.42);
}
// Narrow timber dock joining the quay.
box(4.35, 0.66, 2.70, M.dock, -8.40, 0.42, -0.45);
box(4.30, 0.10, 2.64, M.wood, -8.40, 0.78, -0.45);
for (let x = -10.35; x <= -6.45; x += 0.42) {
box(0.022, 0.014, 2.55, M.woodDark, x, 0.838, -0.45, scene, false);
}
// Dock edge rails, leaving ferry-door gaps.
railing(-10.18, -1.83, -6.55, -1.83);
railing(-10.18, 0.95, -6.55, 0.95);
// The key divider: orange and teal traffic run on separate sides.
railing(-10.18, -0.45, -5.40, -0.45, M.teal);
// Mooring bollards.
for (const [x, z] of [[-6.8, -1.78], [-6.8, 0.90], [-10.25, -1.75], [-10.25, 0.88]]) {
cylinder(0.11, 0.16, 0.45, 8, M.woodDark, x, 1.02, z);
cylinder(0.16, 0.12, 0.12, 8, M.woodDark, x, 1.28, z);
}
// -------------------------------------------------------------------------
// Colored circulation routes
// -------------------------------------------------------------------------
const boardingPath = [
[-4.65, -2.65],
[-6.35, -2.65],
[-6.35, -1.35],
[-10.32, -1.35]
];
const throughPath = [
[-10.34, 0.48],
[-5.72, 0.48],
[-5.72, 1.75],
[5.25, 1.75],
[5.25, 0.52]
];
function makeArrow(x, z, dx, dz, mat) {
const shape = new THREE.Shape();
shape.moveTo(0.48, 0);
shape.lineTo(-0.22, 0.25);
shape.lineTo(-0.08, 0);
shape.lineTo(-0.22, -0.25);
shape.closePath();
const mesh = new THREE.Mesh(new THREE.ShapeGeometry(shape), mat);
mesh.rotation.x = -Math.PI / 2;
mesh.rotation.y = -Math.atan2(dz, dx);
mesh.position.set(x, 0.852, z);
scene.add(mesh);
return mesh;
}
function drawRoute(points, mat, width = 0.40) {
for (let i = 0; i < points.length - 1; i++) {
const a = points[i];
const b = points[i + 1];
const dx = b[0] - a[0];
const dz = b[1] - a[1];
const length = Math.hypot(dx, dz);
const angle = Math.atan2(dz, dx);
const strip = box(
length + 0.05, 0.026, width, mat,
(a[0] + b[0]) / 2, 0.847, (a[1] + b[1]) / 2,
scene, false
);
strip.rotation.y = -angle;
const arrowCount = Math.max(1, Math.floor(length / 1.55));
for (let n = 0; n < arrowCount; n++) {
const t = (n + 0.55) / arrowCount;
makeArrow(
a[0] + dx * t,
a[1] + dz * t,
dx,
dz,
mat
);
}
}
for (const [x, z] of points.slice(1, -1)) {
const joint = cylinder(width / 2, width / 2, 0.026, 10, mat, x, 0.847, z);
joint.castShadow = false;
}
}
drawRoute(boardingPath, M.routeOrange, 0.40);
drawRoute(throughPath, M.routeTeal, 0.43);
// -------------------------------------------------------------------------
// Market building
// -------------------------------------------------------------------------
const market = new THREE.Group();
market.position.set(5.25, 0, -1.35);
scene.add(market);
box(4.85, 3.05, 3.50, M.cream, 0, 2.325, 0, market);
box(5.02, 0.18, 3.66, M.teal, 0, 0.88, 0, market);
box(5.08, 0.16, 3.72, M.teal, 0, 3.87, 0, market);
makeGableRoof(5.35, 4.10, 1.12, M.roof, 5.25, 3.94, -1.35);
// Arched entrance, layered to give a thick frame.
const outerArch = new THREE.Mesh(
new THREE.ShapeGeometry(archShape(1.94, 2.44)),
M.teal
);
outerArch.position.set(0, 0.80, 1.765);
market.add(outerArch);
const innerArch = new THREE.Mesh(
new THREE.ShapeGeometry(archShape(1.62, 2.16)),
M.dark
);
innerArch.position.set(0, 0.80, 1.779);
market.add(innerArch);
// Warm sliver suggesting an interior.
box(1.34, 0.045, 0.34, M.yellow, 0, 0.84, 1.72, market, false);
sign("PUBLIC MARKET", 2.42, 0.46, "#f4e6c7", "#174b51", 0, 3.37, 1.775, market);
sign("GRANVILLE ISLAND", 1.75, 0.25, "#1d6267", "#f7e9c9", 0, 3.02, 1.778, market);
// Front windows and frames.
for (const x of [-1.72, 1.72]) {
box(0.82, 0.98, 0.10, M.teal, x, 1.92, 1.77, market);
box(0.67, 0.83, 0.11, M.window, x, 1.92, 1.785, market);
box(0.035, 0.84, 0.025, M.whiteRoute, x, 1.92, 1.85, market);
}
// Side windows on the visible east face.
for (const z of [-0.85, 0.25]) {
box(0.10, 0.84, 0.70, M.teal, 2.44, 1.95, z, market);
box(0.11, 0.68, 0.55, M.window, 2.45, 1.95, z, market);
}
// Small awnings and produce stalls.
function marketStall(x, z, awningColor) {
const group = new THREE.Group();
group.position.set(x, 0.80, z);
scene.add(group);
box(1.38, 0.68, 0.72, M.wood, 0, 0.34, 0, group);
box(1.52, 0.10, 0.88, M.cream, 0, 0.73, 0, group);
for (const px of [-0.72, 0.72]) {
cylinder(0.035, 0.035, 1.38, 6, M.metal, px, 0.69, -0.39, group);
cylinder(0.035, 0.035, 1.38, 6, M.metal, px, 0.69, 0.39, group);
}
for (let i = 0; i < 6; i++) {
const strip = box(
0.29, 0.10, 1.10,
i % 2 ? M.whiteRoute : awningColor,
-0.73 + i * 0.292, 1.41, 0, group
);
strip.rotation.z = i % 2 ? 0.025 : -0.025;
}
const produce = [M.red, M.orange, M.foliageLight, M.yellow];
for (let i = 0; i < 9; i++) {
const fruit = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.095 + Math.random() * 0.025, 0),
produce[i % produce.length]
);
fruit.position.set(
-0.48 + (i % 3) * 0.43,
0.85,
-0.18 + Math.floor(i / 3) * 0.18
);
fruit.castShadow = true;
group.add(fruit);
}
}
marketStall(2.05, 0.12, M.coral);
marketStall(7.35, 0.02, M.yellow);
// Market banners.
for (const [x, color, text] of [[3.18, M.coral, "FISH"], [7.28, M.yellow, "LOCAL"]]) {
cylinder(0.025, 0.025, 2.4, 6, M.metal, x, 2.0, 0.54);
sign(text, 0.55, 0.88, color, "#fff5d8", x, 2.05, 0.57);
}
// -------------------------------------------------------------------------
// Ferry
// -------------------------------------------------------------------------
const ferry = new THREE.Group();
ferry.position.set(-11.75, 0, 0);
scene.add(ferry);
const hullShape = new THREE.Shape();
hullShape.moveTo(-1.18, -3.20);
hullShape.lineTo(1.18, -3.20);
hullShape.lineTo(1.25, 2.15);
hullShape.lineTo(0, 3.48);
hullShape.lineTo(-1.25, 2.15);
hullShape.closePath();
const hullGeometry = new THREE.ExtrudeGeometry(hullShape, {
depth: 0.78,
bevelEnabled: false
});
hullGeometry.rotateX(Math.PI / 2);
const hull = new THREE.Mesh(hullGeometry, M.blue);
hull.position.y = 0.46;
hull.castShadow = true;
hull.receiveShadow = true;
ferry.add(hull);
box(2.24, 0.18, 5.72, M.white, 0, 0.55, -0.28, ferry);
box(2.10, 1.28, 4.55, M.white, 0, 1.26, -0.28, ferry);
box(2.26, 0.20, 4.78, M.yellow, 0, 1.98, -0.28, ferry);
// Upper wheelhouse.
box(1.48, 0.66, 1.50, M.yellow, 0, 2.38, 1.08, ferry);
box(1.54, 0.13, 1.60, M.white, 0, 2.77, 1.08, ferry);
box(1.25, 0.42, 0.04, M.window, 0, 2.42, 1.845, ferry);
// Window bands on the dock-facing side.
for (const z of [-1.90, -0.98, 0.04, 1.06]) {
box(0.035, 0.47, 0.67, M.window, 1.065, 1.43, z, ferry);
}
// Distinct ferry-side boarding and through doors.
box(0.045, 1.12, 0.78, M.orange, 1.075, 1.13, -1.34, ferry);
box(0.05, 1.08, 0.76, M.routeTeal, 1.08, 1.13, 0.48, ferry);
box(0.055, 0.92, 0.56, M.window, 1.10, 1.31, -1.34, ferry);
box(0.06, 0.88, 0.54, M.window, 1.11, 1.31, 0.48, ferry);
// Front and far-side windows.
box(1.72, 0.47, 0.04, M.window, 0, 1.42, 2.005, ferry);
for (const z of [-1.65, -0.72, 0.21]) {
box(0.04, 0.47, 0.66, M.window, -1.06, 1.43, z, ferry);
}
// Orange life ring and ferry name.
const lifeRing = new THREE.Mesh(
new THREE.TorusGeometry(0.21, 0.065, 6, 12),
M.orange
);
lifeRing.rotation.y = Math.PI / 2;
lifeRing.position.set(1.10, 1.05, 1.68);
ferry.add(lifeRing);
sign("AQUA 03", 1.25, 0.30, "#f5d44f", "#154f63", 1.115, 1.83, 1.78, ferry, Math.PI / 2);
cylinder(0.035, 0.035, 1.05, 6, M.metal, 0, 3.19, 0.98, ferry);
box(0.40, 0.27, 0.03, M.yellow, 0, 3.64, 0.98, ferry);
// Gangways align with the two separate ferry doors.
const boardingGangway = box(0.82, 0.08, 0.76, M.metal, -10.32, 0.66, -1.34);
boardingGangway.rotation.z = -0.035;
const throughGangway = box(0.82, 0.08, 0.74, M.metal, -10.32, 0.66, 0.48);
throughGangway.rotation.z = -0.035;
// -------------------------------------------------------------------------
// Route signs, queue barriers, and small waterfront details
// -------------------------------------------------------------------------
function routeSign(x, z, text, bg, fg) {
cylinder(0.055, 0.065, 1.65, 6, M.metal, x, 1.61, z);
sign(text, 2.05, 0.45, bg, fg, x, 2.25, z + 0.04);
}
routeSign(-7.12, -1.92, "FERRY BOARDING", "#f2a33a", "#173f45");
routeSign(-7.12, 1.18, "THROUGH / MARKET", "#1599aa", "#ffffff");
// Queue rails with an opening toward the dock.
railing(-5.05, -3.18, -1.02, -3.18, M.metal);
railing(-5.05, -2.10, -1.02, -2.10, M.metal);
cylinder(0.055, 0.07, 1.75, 6, M.metal, -0.96, 1.64, -3.04);
sign("FERRY QUEUE", 1.50, 0.36, "#f4e8c9", "#174b51", -0.96, 2.35, -3.00);
// Small signs explaining the physical separation.
sign("KEEP LANES SEPARATE", 1.50, 0.30, "#173f45", "#ffffff", -5.40, 2.03, -0.42);
// Vendor cart behind the queue.
const cart = new THREE.Group();
cart.position.set(-0.05, 0.80, -2.70);
scene.add(cart);
box(1.42, 0.70, 0.72, M.coral, 0, 0.35, 0, cart);
box(1.58, 0.10, 0.86, M.whiteRoute, 0, 0.75, 0, cart);
for (const x of [-0.67, 0.67]) {
cylinder(0.035, 0.035, 1.35, 6, M.metal, x, 0.67, -0.30, cart);
}
for (let i = 0; i < 6; i++) {
box(0.25, 0.08, 0.95, i % 2 ? M.coral : M.yellow, -0.65 + i * 0.26, 1.36, 0, cart);
}
// Planters, trees, benches, and lamps.
function planterTree(x, z) {
box(1.02, 0.46, 1.02, M.stone, x, 1.02, z);
box(0.83, 0.08, 0.83, M.woodDark, x, 1.28, z);
cylinder(0.11, 0.16, 1.65, 6, M.trunk, x, 2.0, z);
const crown = new THREE.Mesh(new THREE.IcosahedronGeometry(0.95, 0), M.foliage);
crown.position.set(x, 3.15, z);
crown.scale.set(1, 1.15, 1);
crown.castShadow = true;
scene.add(crown);
const crown2 = new THREE.Mesh(new THREE.IcosahedronGeometry(0.65, 0), M.foliageLight);
crown2.position.set(x + 0.40, 3.52, z + 0.08);
crown2.castShadow = true;
scene.add(crown2);
}
planterTree(7.55, 3.55);
planterTree(-5.95, 3.60);
function bench(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.80, z);
group.rotation.y = rotation;
scene.add(group);
for (let i = 0; i < 3; i++) {
box(1.72, 0.09, 0.16, M.wood, 0, 0.48, -0.22 + i * 0.22, group);
}
for (let i = 0; i < 3; i++) {
box(1.72, 0.16, 0.08, M.wood, 0, 0.78 + i * 0.19, -0.31, group);
}
for (const x2 of [-0.64, 0.64]) {
box(0.08, 0.58, 0.56, M.metal, x2, 0.28, 0, group);
}
}
bench(-1.65, 3.35);
bench(1.15, 3.35);
function lamp(x, z) {
cylinder(0.07, 0.10, 3.25, 6, M.metal, x, 2.43, z);
box(0.42, 0.15, 0.42, M.dark, x, 4.03, z);
box(0.29, 0.08, 0.29, M.yellow, x, 3.93, z);
const arm = box(0.50, 0.06, 0.06, M.metal, x + 0.20, 3.88, z);
arm.rotation.z = -0.15;
}
lamp(-3.15, 3.55);
lamp(3.00, 3.60);
// -------------------------------------------------------------------------
// Low-poly people
// -------------------------------------------------------------------------
const skinMaterials = [
material(0xd7a27c),
material(0xa96d4e),
material(0xefc6a0),
material(0x754b39)
];
const shirtMaterials = [
M.red,
M.yellow,
M.teal,
M.coral,
material(0x6c78ad),
material(0x546a79),
material(0xd77b91)
];
function person(shirt, skin, scale = 1) {
const group = new THREE.Group();
const torso = cylinder(0.17, 0.22, 0.61, 6, shirt, 0, 0.94, 0, group);
torso.rotation.z = 0;
const head = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.165, 0),
skin
);
head.position.y = 1.40;
head.castShadow = true;
group.add(head);
const hair = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.17, 0),
M.woodDark
);
hair.scale.set(1, 0.62, 1);
hair.position.set(0, 1.49, -0.025);
hair.castShadow = true;
group.add(hair);
const legs = [];
const arms = [];
for (const side of [-1, 1]) {
const legPivot = new THREE.Group();
legPivot.position.set(side * 0.095, 0.66, 0);
cylinder(0.052, 0.058, 0.50, 5, M.dark, 0, -0.25, 0, legPivot);
box(0.12, 0.08, 0.22, M.dark, 0, -0.52, 0.045, legPivot);
group.add(legPivot);
legs.push(legPivot);
const armPivot = new THREE.Group();
armPivot.position.set(side * 0.235, 1.14, 0);
cylinder(0.048, 0.052, 0.48, 5, shirt, 0, -0.23, 0, armPivot);
const hand = new THREE.Mesh(new THREE.IcosahedronGeometry(0.06, 0), skin);
hand.position.y = -0.49;
armPivot.add(hand);
group.add(armPivot);
arms.push(armPivot);
}
group.scale.setScalar(scale);
return { group, legs, arms };
}
// Waiting passengers form a loose line behind the queue rails.
const waitingPeople = [];
const queueX = [-4.45, -3.95, -3.45, -2.95, -2.45, -1.95, -1.42];
queueX.forEach((x, i) => {
const p = person(
shirtMaterials[i % shirtMaterials.length],
skinMaterials[i % skinMaterials.length],
0.88 + (i % 3) * 0.055
);
p.group.position.set(x, 0.82, -2.65 + (i % 2 ? 0.06 : -0.04));
p.group.rotation.y = -Math.PI / 2 + (Math.random() - 0.5) * 0.35;
scene.add(p.group);
waitingPeople.push(p);
});
// A few shoppers near the market.
[
[4.35, 2.52, M.red],
[6.15, 2.35, M.teal],
[7.00, 1.92, M.coral],
[1.00, 1.68, M.yellow]
].forEach(([x, z, shirt], i) => {
const p = person(shirt, skinMaterials[(i + 1) % skinMaterials.length], 0.9 + i * 0.03);
p.group.position.set(x, 0.82, z);
p.group.rotation.y = -1.1 + i * 0.65;
scene.add(p.group);
waitingPeople.push(p);
});
// -------------------------------------------------------------------------
// Animated through-walkers
// -------------------------------------------------------------------------
function pathData(points) {
const lengths = [];
let total = 0;
for (let i = 0; i < points.length - 1; i++) {
const length = Math.hypot(
points[i + 1][0] - points[i][0],
points[i + 1][1] - points[i][1]
);
lengths.push(length);
total += length;
}
return { points, lengths, total };
}
function samplePath(data, fraction) {
let distance = ((fraction % 1) + 1) % 1 * data.total;
for (let i = 0; i < data.lengths.length; i++) {
if (distance <= data.lengths[i]) {
const t = distance / data.lengths[i];
const a = data.points[i];
const b = data.points[i + 1];
const dx = b[0] - a[0];
const dz = b[1] - a[1];
return {
x: a[0] + dx * t,
z: a[1] + dz * t,
dx,
dz
};
}
distance -= data.lengths[i];
}
const last = data.points[data.points.length - 1];
return { x: last[0], z: last[1], dx: 1, dz: 0 };
}
const throughData = pathData(throughPath);
const walkers = [];
for (let i = 0; i < 4; i++) {
const p = person(
shirtMaterials[(i + 3) % shirtMaterials.length],
skinMaterials[(i + 2) % skinMaterials.length],
0.90 + i * 0.025
);
scene.add(p.group);
walkers.push({
...p,
offset: i * 0.19,
speed: 0.012 + i * 0.0015,
phase: i * 1.4
});
}
// A boarding passenger approaching the upper ferry door.
const boardingWalker = person(M.coral, skinMaterials[1], 0.96);
scene.add(boardingWalker.group);
const boardingData = pathData(boardingPath);
// -------------------------------------------------------------------------
// Distant low-poly clouds
// -------------------------------------------------------------------------
const cloudMaterial = material(0xf5fbf7);
[
[-13, 9, -18, 1.4],
[8, 11, -23, 1.8],
[20, 8, -13, 1.1]
].forEach(([x, y, z, s]) => {
const cloud = new THREE.Group();
cloud.position.set(x, y, z);
cloud.scale.setScalar(s);
scene.add(cloud);
const pieces = [
[-0.9, 0, 0, 0.75],
[0, 0.18, 0, 1.0],
[0.95, 0, 0, 0.65],
[0.25, -0.12, 0.16, 0.72]
];
pieces.forEach(([px, py, pz, size]) => {
const puff = new THREE.Mesh(new THREE.IcosahedronGeometry(size, 1), cloudMaterial);
puff.position.set(px, py, pz);
cloud.add(puff);
});
});
// -------------------------------------------------------------------------
// Custom camera controls — no external controls module
// -------------------------------------------------------------------------
function updateCamera() {
const sinPitch = Math.sin(view.pitch);
camera.position.set(
cameraTarget.x + view.radius * sinPitch * Math.sin(view.yaw),
cameraTarget.y + view.radius * Math.cos(view.pitch),
cameraTarget.z + view.radius * sinPitch * Math.cos(view.yaw)
);
camera.lookAt(cameraTarget);
}
function resize() {
const aspect = innerWidth / innerHeight;
const halfHeight = Math.max(8.2, 11.5 / aspect) / view.zoom;
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
}
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;
view.yaw -= dx * 0.006;
view.pitch = THREE.MathUtils.clamp(view.pitch + dy * 0.0045, 0.48, 1.28);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined && renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
view.zoom = THREE.MathUtils.clamp(view.zoom * Math.exp(event.deltaY * 0.001), 0.68, 1.75);
resize();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", () => {
view.yaw = 0.74;
view.pitch = 0.93;
view.zoom = 1;
resize();
updateCamera();
});
addEventListener("resize", resize);
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const t = clock.getElapsedTime();
// Gentle ferry movement while moored.
ferry.position.y = Math.sin(t * 0.82) * 0.026;
ferry.rotation.z = Math.sin(t * 0.67) * 0.006;
ferry.rotation.x = Math.sin(t * 0.51 + 1.2) * 0.003;
// Waiting passengers have small idle shifts.
waitingPeople.forEach((p, i) => {
p.group.rotation.z = Math.sin(t * 1.05 + i * 0.9) * 0.008;
p.group.position.y = 0.82 + Math.sin(t * 1.5 + i) * 0.006;
});
// Through walkers follow only the teal route.
walkers.forEach((p, i) => {
const sample = samplePath(throughData, p.offset + t * p.speed);
const stride = Math.sin(t * 7.0 + p.phase);
p.group.position.set(sample.x, 0.83 + Math.abs(stride) * 0.022, sample.z);
p.group.rotation.y = Math.atan2(sample.dx, sample.dz);
p.legs[0].rotation.x = stride * 0.52;
p.legs[1].rotation.x = -stride * 0.52;
p.arms[0].rotation.x = -stride * 0.40;
p.arms[1].rotation.x = stride * 0.40;
});
// A single orange-route walker heads toward the boarding door.
const boardingSample = samplePath(boardingData, (t * 0.030) % 1);
const boardingStride = Math.sin(t * 7.4);
boardingWalker.group.position.set(
boardingSample.x,
0.83 + Math.abs(boardingStride) * 0.02,
boardingSample.z
);
boardingWalker.group.rotation.y = Math.atan2(boardingSample.dx, boardingSample.dz);
boardingWalker.legs[0].rotation.x = boardingStride * 0.48;
boardingWalker.legs[1].rotation.x = -boardingStride * 0.48;
boardingWalker.arms[0].rotation.x = -boardingStride * 0.35;
boardingWalker.arms[1].rotation.x = boardingStride * 0.35;
renderer.render(scene, camera);
}
resize();
updateCamera();
renderer.render(scene, camera);
document.getElementById("loading").classList.add("hidden");
animate();
</script>
</body>
</html>
```