Prompt specification
Build or customize the Three.js 3D scene "Delivery boat unloading beside a Venice footpath" 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: Delivery boat unloading beside a Venice footpath
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/delivery-boat-unloading-beside-a-venice-footpath-x2874
Scene Description Prompt:
Create a compact Cannaregio vignette with delivery boat, cart, and narrow fondamenta. Animate goods crossing the landing while maintaining a clear pedestrian passage. Use Three.js from cdnjs in a single HTML file, with low-poly forms.
Working Three.js Starter (delivery-boat-unloading-beside-a-venice-footpath-x2874):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Cannaregio — Fondamenta Delivery</title>
<style>
:root {
color-scheme: light;
--ink: #18383b;
--paper: rgba(248, 244, 230, 0.92);
--ochre: #d9953f;
--teal: #4d9b94;
}
* { box-sizing: border-box; }
html, body {
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #cbd9d3;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
}
#stage {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
#hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.title-card {
position: absolute;
top: 22px;
left: 24px;
max-width: 340px;
padding: 16px 18px 14px;
border: 1px solid rgba(24, 56, 59, 0.16);
border-radius: 4px;
background: var(--paper);
box-shadow: 0 10px 30px rgba(25, 50, 52, 0.12);
backdrop-filter: blur(8px);
}
.eyebrow {
margin: 0 0 4px;
color: #a2672d;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(25px, 3vw, 36px);
font-weight: 500;
letter-spacing: -0.025em;
line-height: 1;
}
.subtitle {
margin: 8px 0 0;
color: rgba(24, 56, 59, 0.72);
font-size: 12px;
line-height: 1.45;
}
.controls {
position: absolute;
top: 22px;
right: 24px;
display: flex;
gap: 8px;
pointer-events: auto;
}
button {
min-height: 38px;
padding: 0 14px;
border: 1px solid rgba(24, 56, 59, 0.18);
border-radius: 3px;
background: var(--paper);
color: var(--ink);
font: 700 11px/1 ui-sans-serif, system-ui, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
box-shadow: 0 6px 18px rgba(25, 50, 52, 0.1);
}
button:hover { background: #fffaf0; }
button:active { transform: translateY(1px); }
.legend {
position: absolute;
left: 24px;
bottom: 24px;
width: 258px;
padding: 14px 16px;
border: 1px solid rgba(24, 56, 59, 0.14);
border-radius: 4px;
background: var(--paper);
box-shadow: 0 10px 30px rgba(25, 50, 52, 0.12);
backdrop-filter: blur(8px);
}
.legend-row {
display: flex;
align-items: center;
gap: 10px;
margin: 8px 0;
font-size: 11px;
font-weight: 650;
}
.swatch {
width: 28px;
height: 5px;
flex: 0 0 auto;
border-radius: 5px;
}
.swatch.goods { background: var(--ochre); }
.swatch.walk { background: var(--teal); }
.clear-note {
display: flex;
align-items: center;
gap: 8px;
margin-top: 12px;
padding-top: 11px;
border-top: 1px solid rgba(24, 56, 59, 0.12);
color: #347d78;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.clear-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: #4d9b94;
box-shadow: 0 0 0 4px rgba(77, 155, 148, 0.15);
}
.hint {
position: absolute;
right: 24px;
bottom: 24px;
padding: 8px 11px;
border-radius: 3px;
background: rgba(248, 244, 230, 0.76);
color: rgba(24, 56, 59, 0.68);
font-size: 10px;
letter-spacing: 0.04em;
}
@media (max-width: 680px) {
.title-card {
top: 12px;
left: 12px;
max-width: calc(100vw - 118px);
padding: 12px;
}
.subtitle { display: none; }
.controls {
top: 12px;
right: 12px;
flex-direction: column;
}
button {
min-height: 34px;
padding: 0 10px;
font-size: 9px;
}
.legend {
left: 12px;
bottom: 12px;
width: 220px;
padding: 11px 13px;
}
.hint { display: none; }
}
</style>
</head>
<body>
<div id="stage"></div>
<div id="hud">
<section class="title-card">
<p class="eyebrow">Cannaregio · Venice</p>
<h1>Fondamenta del Pescatore</h1>
<p class="subtitle">
A compact morning delivery scene. Cargo remains on the outer landing,
while the inland pedestrian passage stays open.
</p>
</section>
<div class="controls">
<button id="reset-view" type="button">Reset view</button>
<button id="toggle-motion" type="button">Pause</button>
</div>
<section class="legend">
<div class="legend-row">
<span class="swatch goods"></span>
Goods crossing · outer landing
</div>
<div class="legend-row">
<span class="swatch walk"></span>
Clear pedestrian passage
</div>
<div class="clear-note">
<span class="clear-dot"></span>
Passage clear
</div>
</section>
<div class="hint">Drag to orbit · scroll to zoom · double-click to reset</div>
</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 stage = document.querySelector("#stage");
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.08;
renderer.domElement.setAttribute("aria-label", "Interactive 3D Cannaregio vignette");
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color("#cbd9d3");
scene.fog = new THREE.Fog("#cbd9d3", 30, 58);
const camera = new THREE.OrthographicCamera(-16, 16, 9, -9, 0.1, 100);
const cameraState = {
azimuth: 0.57,
elevation: 0.57,
radius: 27,
target: new THREE.Vector3(0, 0.8, 1.0)
};
function updateCamera() {
const { azimuth, elevation, radius, target } = cameraState;
const horizontal = Math.cos(elevation) * radius;
camera.position.set(
target.x + Math.sin(azimuth) * horizontal,
target.y + Math.sin(elevation) * radius,
target.z + Math.cos(azimuth) * horizontal
);
camera.lookAt(target);
camera.zoom = 27 / radius;
camera.updateProjectionMatrix();
}
function resize() {
const aspect = window.innerWidth / window.innerHeight;
const viewHeight = Math.max(18, 31 / aspect);
camera.left = -viewHeight * aspect / 2;
camera.right = viewHeight * aspect / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
resize();
updateCamera();
const hemisphere = new THREE.HemisphereLight("#e6f2ec", "#77654f", 2.1);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight("#fff0cf", 3.1);
sun.position.set(-10, 18, 13);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -21;
sun.shadow.camera.right = 21;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.bias = -0.00025;
scene.add(sun);
const fill = new THREE.DirectionalLight("#8bbbc0", 0.55);
fill.position.set(12, 8, -10);
scene.add(fill);
// ------------------------------------------------------------
// Utilities
// ------------------------------------------------------------
function material(color, extra = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0,
flatShading: true,
...extra
});
}
function box(parent, w, h, d, x, y, z, mat, cast = true, receive = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = receive;
parent.add(mesh);
return mesh;
}
function cylinder(parent, r1, r2, h, x, y, z, mat, segments = 8) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(r1, r2, h, segments),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function line(points, color = "#403b31", opacity = 1) {
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const mat = new THREE.LineBasicMaterial({ color, transparent: opacity < 1, opacity });
const result = new THREE.Line(geometry, mat);
scene.add(result);
return result;
}
function seededRandom(seed) {
let value = seed % 2147483647;
return () => {
value = value * 16807 % 2147483647;
return (value - 1) / 2147483646;
};
}
const random = seededRandom(82317);
function makeTextTexture(text, options = {}) {
const {
width = 1024,
height = 256,
background = null,
color = "#f4e9cb",
font = "700 92px Georgia",
outline = null
} = options;
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
if (background) {
ctx.fillStyle = background;
ctx.fillRect(0, 0, width, height);
}
ctx.font = font;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
if (outline) {
ctx.strokeStyle = outline;
ctx.lineWidth = 8;
ctx.strokeText(text, width / 2, height / 2);
}
ctx.fillStyle = color;
ctx.fillText(text, width / 2, height / 2);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function textPlane(text, width, height, options = {}) {
const texture = makeTextTexture(text, options);
const mat = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
side: THREE.DoubleSide
});
return new THREE.Mesh(new THREE.PlaneGeometry(width, height), mat);
}
// ------------------------------------------------------------
// Canal, quay and paved fondamenta
// ------------------------------------------------------------
const stone = material("#c4b99f");
const darkStone = material("#8d826d");
const trimStone = material("#e1d7bf");
const wood = material("#8a5936");
const darkWood = material("#563b2b");
box(scene, 31, 0.7, 7.4, 0, -0.35, 0.35, stone, false, true);
box(scene, 31, 0.16, 5.8, 0, 0.01, 0.72, material("#d5cbb4"), false, true);
box(scene, 31, 0.72, 0.26, 0, -0.34, 3.91, darkStone, false, true);
// Paving joints.
const jointMat = material("#b5aa93");
for (let x = -14; x <= 14; x += 0.82) {
box(scene, 0.018, 0.012, 5.65, x, 0.095, 0.73, jointMat, false, false);
}
for (const z of [-0.85, 0.15, 1.15, 2.15, 2.7]) {
box(scene, 30.5, 0.012, 0.018, 0, 0.096, z, jointMat, false, false);
}
// Canal water.
const waterGeometry = new THREE.PlaneGeometry(34, 15, 34, 15);
waterGeometry.rotateX(-Math.PI / 2);
const waterPositions = waterGeometry.attributes.position;
const waterBase = new Float32Array(waterPositions.count * 2);
for (let i = 0; i < waterPositions.count; i++) {
waterBase[i * 2] = waterPositions.getX(i);
waterBase[i * 2 + 1] = waterPositions.getZ(i);
}
const waterMaterial = material("#4e8d8d", {
roughness: 0.36,
metalness: 0.16,
side: THREE.DoubleSide
});
const water = new THREE.Mesh(waterGeometry, waterMaterial);
water.position.set(0, -0.03, 11.3);
water.receiveShadow = true;
scene.add(water);
// Low, warm reflections.
const ripples = [];
const rippleMaterial = new THREE.MeshBasicMaterial({
color: "#d9eee2",
transparent: true,
opacity: 0.26,
depthWrite: false
});
for (let i = 0; i < 42; i++) {
const ripple = new THREE.Mesh(
new THREE.BoxGeometry(0.45 + random() * 1.3, 0.012, 0.025),
rippleMaterial.clone()
);
ripple.position.set(
-16 + random() * 32,
0.015,
4.35 + random() * 12.5
);
ripple.rotation.y = (random() - 0.5) * 0.18;
scene.add(ripple);
ripples.push({
mesh: ripple,
speed: 0.035 + random() * 0.05,
baseX: ripple.position.x
});
}
// ------------------------------------------------------------
// Outer delivery landing
// ------------------------------------------------------------
const landing = new THREE.Group();
scene.add(landing);
const plankMaterials = [
material("#9a6942"),
material("#8b5b37"),
material("#a8754b")
];
for (let x = -6.25; x < 6.25; x += 0.33) {
box(
landing,
0.305,
0.13,
1.08,
x,
0.095,
3.37,
plankMaterials[Math.floor(random() * plankMaterials.length)],
false,
true
);
}
for (const z of [2.9, 3.84]) {
box(landing, 12.6, 0.11, 0.12, 0, 0.08, z, darkWood, false, true);
}
// Ochre goods route.
for (let x = -5.8; x < 5.4; x += 0.72) {
box(landing, 0.42, 0.014, 0.07, x, 0.168, 3.7,
material("#e1a048", { emissive: "#5b2d06", emissiveIntensity: 0.12 }),
false, false);
}
// Ground stencil.
const goodsStencil = textPlane("GOODS →", 3.1, 0.64, {
color: "#f0bf6d",
font: "800 78px Arial"
});
goodsStencil.rotation.x = -Math.PI / 2;
goodsStencil.position.set(-0.6, 0.169, 3.2);
landing.add(goodsStencil);
// Teal pedestrian edge marking, on the inland side.
for (let x = -14; x < 14; x += 0.9) {
box(scene, 0.56, 0.014, 0.065, x, 0.106, 2.48,
material("#589d96"), false, false);
}
// Rope barrier separates the goods lane from the clear passage.
const barrierPostXs = [-5.8, -2.0, 1.9, 5.8];
for (const x of barrierPostXs) {
cylinder(scene, 0.075, 0.09, 0.72, x, 0.42, 2.73, darkWood, 7);
cylinder(scene, 0.105, 0.105, 0.07, x, 0.76, 2.73, darkWood, 7);
}
for (let i = 0; i < barrierPostXs.length - 1; i++) {
const x1 = barrierPostXs[i];
const x2 = barrierPostXs[i + 1];
const curve = new THREE.CatmullRomCurve3([
new THREE.Vector3(x1, 0.68, 2.73),
new THREE.Vector3((x1 + x2) / 2, 0.53, 2.73),
new THREE.Vector3(x2, 0.68, 2.73)
]);
const rope = new THREE.Mesh(
new THREE.TubeGeometry(curve, 12, 0.025, 5, false),
material("#b4a783")
);
rope.castShadow = true;
scene.add(rope);
}
// ------------------------------------------------------------
// Buildings along the narrow fondamenta
// ------------------------------------------------------------
const facadeColors = [
"#c98458", "#d2aa70", "#b8b68d", "#d1bd92", "#a8b7a4",
"#c88d61", "#dfc899", "#b3c0b2", "#cfa072"
];
function makeBuilding(cx, width, height, color, index) {
const group = new THREE.Group();
group.position.set(cx, 0, -3.72);
scene.add(group);
const facade = material(color);
const paleTrim = material("#e7dcc2");
const darkOpening = material("#314b4c");
const shutter = material(index % 2 ? "#567b72" : "#3e6b72");
const roofMat = material(index % 2 ? "#85543e" : "#6f5040");
box(group, width, height, 3.65, 0, height / 2, 0, facade);
box(group, width + 0.12, 0.19, 3.77, 0, height + 0.08, 0, roofMat);
box(group, width + 0.16, 0.16, 3.8, 0, 0.12, 0, paleTrim);
// Ground-floor stone base.
box(group, width + 0.04, 0.55, 0.10, 0, 0.3, 1.85, paleTrim);
const doorX = -width * 0.22;
box(group, 0.67, 1.72, 0.09, doorX, 0.89, 1.88, darkOpening);
box(group, 0.82, 0.12, 0.15, doorX, 1.79, 1.91, paleTrim);
const rows = Math.max(2, Math.floor((height - 1.3) / 1.55));
for (let row = 0; row < rows; row++) {
const wy = 2.72 + row * 1.48;
if (wy > height - 0.55) continue;
for (const wx of [-width * 0.29, width * 0.02, width * 0.31]) {
if (row === 0 && Math.abs(wx - doorX) < 0.82) continue;
box(group, 0.55, 0.74, 0.07, wx, wy, 1.88, paleTrim);
box(group, 0.39, 0.57, 0.075, wx, wy, 1.93, darkOpening);
box(group, 0.46, 0.045, 0.085, wx, wy, 1.97, paleTrim);
box(group, 0.035, 0.59, 0.085, wx, wy, 1.97, paleTrim);
box(group, 0.16, 0.66, 0.06, wx - 0.36, wy, 1.94, shutter);
box(group, 0.16, 0.66, 0.06, wx + 0.36, wy, 1.94, shutter);
}
}
// Occasional shallow balcony.
if (index % 2 === 0 && height > 5.5) {
const by = 4.12;
box(group, 1.16, 0.12, 0.48, 0.15, by, 2.02, paleTrim);
for (let i = 0; i < 6; i++) {
box(group, 0.035, 0.5, 0.035,
-0.34 + i * 0.2, by + 0.27, 2.22, darkOpening);
}
box(group, 1.12, 0.04, 0.04, 0.15, by + 0.52, 2.22, darkOpening);
}
// Small awning.
if (index % 3 === 0) {
const awningX = width * 0.21;
const awning = box(group, 1.3, 0.09, 0.78,
awningX, 1.95, 2.18, index % 2 ? material("#f0dfbd") : material("#d87b54"));
awning.rotation.x = -0.12;
for (let stripe = 0; stripe < 4; stripe++) {
const strip = box(group, 0.11, 0.035, 0.78,
awningX - 0.48 + stripe * 0.32, 2.005, 2.18,
index % 2 ? material("#b95f46") : material("#6f8f82"));
strip.rotation.x = -0.12;
}
}
}
const buildingSpecs = [
[-11.7, 2.7, 5.6],
[-8.7, 2.7, 6.8],
[-5.7, 2.8, 5.9],
[-2.6, 2.8, 7.1],
[0.5, 3.0, 6.0],
[3.8, 3.0, 5.6],
[7.0, 2.8, 6.7],
[10.1, 2.8, 5.8],
[13.0, 2.4, 6.4]
];
buildingSpecs.forEach((spec, i) => {
makeBuilding(spec[0], spec[1], spec[2], facadeColors[i], i);
});
// Narrow shaded alley at the far end.
box(scene, 1.65, 3.65, 0.18, -13.0, 1.82, -2.0, material("#273f40"));
const arch = new THREE.Mesh(
new THREE.TorusGeometry(0.72, 0.14, 6, 14, Math.PI),
trimStone
);
arch.position.set(-13.0, 1.83, -1.86);
scene.add(arch);
box(scene, 0.18, 1.9, 0.24, -13.72, 0.95, -1.83, trimStone);
box(scene, 0.18, 1.9, 0.24, -12.28, 0.95, -1.83, trimStone);
// Fondamenta sign.
const signBoard = box(scene, 3.15, 0.61, 0.10, 0.45, 3.72, -1.72, darkWood);
const signText = textPlane("FONDAMENTA", 2.95, 0.43, {
color: "#f2dfad",
font: "700 78px Georgia"
});
signText.position.set(0.45, 3.72, -1.655);
scene.add(signText);
// Laundry line.
line([
new THREE.Vector3(-4.7, 5.45, -1.55),
new THREE.Vector3(-0.5, 5.18, -1.55)
], "#5e5a4b", 0.8);
const laundryColors = ["#eee0bd", "#6e9e9b", "#d88460", "#d7c48b"];
for (let i = 0; i < 4; i++) {
const cloth = box(scene, 0.43, 0.67, 0.025,
-4.15 + i * 0.88, 5.05 - i * 0.05, -1.53,
material(laundryColors[i]));
cloth.rotation.z = (random() - 0.5) * 0.08;
}
// Street lamps and a bench, kept against the building side.
for (const x of [-10, -3.7, 3.1, 9.5]) {
cylinder(scene, 0.055, 0.075, 3.0, x, 1.55, -1.15, darkWood, 7);
box(scene, 0.30, 0.34, 0.30, x, 3.13, -1.15, material("#f2d894"));
box(scene, 0.42, 0.09, 0.42, x, 3.34, -1.15, darkWood);
}
const bench = new THREE.Group();
bench.position.set(7.5, 0, -0.85);
scene.add(bench);
box(bench, 1.7, 0.12, 0.48, 0, 0.56, 0, wood);
box(bench, 1.7, 0.55, 0.10, 0, 0.94, -0.2, wood);
for (const x of [-0.63, 0.63]) {
box(bench, 0.10, 0.56, 0.42, x, 0.28, 0, darkWood);
}
// ------------------------------------------------------------
// Delivery boat
// ------------------------------------------------------------
const boat = new THREE.Group();
boat.position.set(-6.8, 0.02, 6.25);
scene.add(boat);
const hullShape = new THREE.Shape();
hullShape.moveTo(-3.8, -0.55);
hullShape.lineTo(-2.6, -1.04);
hullShape.lineTo(2.3, -1.04);
hullShape.lineTo(3.7, 0);
hullShape.lineTo(2.3, 1.04);
hullShape.lineTo(-2.6, 1.04);
hullShape.lineTo(-3.8, 0.55);
hullShape.closePath();
const hullGeometry = new THREE.ExtrudeGeometry(hullShape, {
depth: 0.9,
bevelEnabled: false,
steps: 1
});
hullGeometry.rotateX(-Math.PI / 2);
const hull = new THREE.Mesh(
hullGeometry,
material("#8f3f35", { side: THREE.DoubleSide })
);
hull.position.y = -0.48;
hull.castShadow = true;
hull.receiveShadow = true;
boat.add(hull);
box(boat, 4.85, 0.12, 1.82, -0.1, 0.46, 0, wood);
box(boat, 4.75, 0.12, 0.12, -0.1, 0.24, 1.02, material("#d7c49e"));
box(boat, 4.75, 0.12, 0.12, -0.1, 0.24, -1.02, material("#d7c49e"));
// Cabin.
box(boat, 1.62, 1.22, 1.43, 1.0, 1.07, 0, material("#e7d9b7"));
box(boat, 1.84, 0.15, 1.62, 1.0, 1.75, 0, material("#b44e3f"));
box(boat, 0.08, 0.49, 0.92, 1.83, 1.16, 0, material("#36585b"));
box(boat, 1.02, 0.47, 0.07, 0.92, 1.18, 0.73, material("#36585b"));
box(boat, 0.07, 0.47, 0.92, 0.2, 1.18, 0, material("#36585b"));
// Boat cargo.
box(boat, 0.78, 0.62, 0.7, -1.75, 0.82, 0.05, material("#9b6b3f"));
box(boat, 0.10, 0.65, 0.74, -1.75, 0.82, 0.05, darkWood);
box(boat, 0.82, 0.09, 0.74, -1.75, 0.83, 0.05, darkWood);
const sack = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.38, 0),
material("#b9a47c")
);
sack.position.set(-0.85, 0.87, -0.34);
sack.scale.set(0.9, 1.2, 0.85);
sack.castShadow = true;
boat.add(sack);
// Mast and pennant.
cylinder(boat, 0.035, 0.045, 2.2, -1.2, 1.63, 0, darkWood, 6);
const flag = box(boat, 0.63, 0.29, 0.025, -0.92, 2.53, 0,
material("#d88450"));
flag.rotation.y = 0.15;
// Fenders.
for (const x of [-2.2, -0.4, 1.35]) {
for (const z of [-1.08, 1.08]) {
const fender = new THREE.Mesh(
new THREE.CylinderGeometry(0.11, 0.11, 0.34, 7),
material("#343b38")
);
fender.rotation.x = Math.PI / 2;
fender.position.set(x, 0.2, z);
fender.castShadow = true;
boat.add(fender);
}
}
// Gangplank from the boat to the landing.
const gangplank = box(scene, 0.82, 0.11, 1.52,
-5.6, 0.40, 4.57, wood);
gangplank.rotation.x = -0.04;
for (let i = 0; i < 4; i++) {
box(scene, 0.83, 0.035, 0.06, -5.6, 0.47, 4.04 + i * 0.34, darkWood);
}
// Mooring bollards.
for (const x of [-10.4, -2.5, 7.2, 12.3]) {
cylinder(scene, 0.10, 0.13, 0.72, x, 0.39, 3.96, darkWood, 8);
cylinder(scene, 0.16, 0.16, 0.08, x, 0.77, 3.96, darkWood, 8);
}
const mooringLine = line([
new THREE.Vector3(-10.4, 0.65, 3.96),
new THREE.Vector3(-9.5, 0.48, 5.18)
], "#594b37");
// ------------------------------------------------------------
// Handcart
// ------------------------------------------------------------
const cart = new THREE.Group();
cart.position.set(5.25, 0.12, 3.37);
scene.add(cart);
box(cart, 2.25, 0.16, 1.18, 0, 0.73, 0, wood);
for (const z of [-0.55, 0.55]) {
box(cart, 2.25, 0.38, 0.10, 0, 0.96, z, wood);
}
for (let x = -0.95; x <= 1.0; x += 0.48) {
box(cart, 0.10, 0.32, 1.16, x, 0.93, 0, wood);
}
// Handles.
for (const z of [-0.46, 0.46]) {
const handle = box(cart, 1.65, 0.10, 0.10, -1.75, 0.76, z, darkWood);
handle.rotation.z = -0.07;
}
// Wheels.
for (const x of [-0.66, 0.72]) {
for (const z of [-0.66, 0.66]) {
const wheel = new THREE.Mesh(
new THREE.CylinderGeometry(0.37, 0.37, 0.12, 10),
darkWood
);
wheel.rotation.x = Math.PI / 2;
wheel.position.set(x, 0.38, z);
wheel.castShadow = true;
cart.add(wheel);
const rim = new THREE.Mesh(
new THREE.TorusGeometry(0.29, 0.035, 5, 12),
material("#b8a17a")
);
rim.position.set(x, 0.38, z + Math.sign(z) * 0.07);
cart.add(rim);
}
}
// Standing legs.
for (const z of [-0.43, 0.43]) {
const leg = box(cart, 0.10, 0.72, 0.10, 0.85, 0.39, z, darkWood);
leg.rotation.z = -0.12;
}
// Cart cargo.
box(cart, 0.76, 0.58, 0.72, 0.15, 1.10, 0.02, material("#b37a44"));
box(cart, 0.09, 0.61, 0.76, 0.15, 1.10, 0.02, darkWood);
// ------------------------------------------------------------
// People and animated cargo
// ------------------------------------------------------------
function makePerson({
coat = "#547b82",
trousers = "#3e4b4d",
skin = "#c99167",
hat = null,
scale = 1
} = {}) {
const root = new THREE.Group();
root.scale.setScalar(scale);
const coatMat = material(coat);
const trouserMat = material(trousers);
const skinMat = material(skin);
const shoeMat = material("#303536");
box(root, 0.39, 0.61, 0.30, 0, 1.12, 0, coatMat);
box(root, 0.33, 0.13, 0.27, 0, 0.77, 0, trouserMat);
const head = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.215, 0),
skinMat
);
head.position.set(0, 1.64, 0);
head.castShadow = true;
root.add(head);
if (hat) {
cylinder(root, 0.23, 0.25, 0.12, 0, 1.84, 0, material(hat), 8);
cylinder(root, 0.15, 0.17, 0.20, 0, 1.94, 0, material(hat), 8);
} else {
const hair = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.215, 0),
material("#493c31")
);
hair.position.set(0, 1.72, 0);
hair.scale.set(1, 0.52, 1);
root.add(hair);
}
const legs = [];
for (const z of [-0.105, 0.105]) {
const pivot = new THREE.Group();
pivot.position.set(0, 0.79, z);
box(pivot, 0.14, 0.54, 0.15, 0, -0.27, 0, trouserMat);
box(pivot, 0.23, 0.10, 0.17, 0.045, -0.53, 0, shoeMat);
root.add(pivot);
legs.push(pivot);
}
const arms = [];
for (const z of [-0.245, 0.245]) {
const pivot = new THREE.Group();
pivot.position.set(0, 1.36, z);
box(pivot, 0.12, 0.48, 0.13, 0, -0.23, 0, coatMat);
const hand = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.075, 0),
skinMat
);
hand.position.set(0, -0.48, 0);
pivot.add(hand);
root.add(pivot);
arms.push(pivot);
}
root.userData.legs = legs;
root.userData.arms = arms;
return root;
}
function makeCargo(type) {
const group = new THREE.Group();
if (type === "crate") {
box(group, 0.68, 0.56, 0.60, 0, 0, 0, material("#a56d3d"));
box(group, 0.09, 0.59, 0.63, 0, 0, 0, darkWood);
box(group, 0.71, 0.07, 0.63, 0, 0.05, 0, darkWood);
} else if (type === "barrel") {
cylinder(group, 0.27, 0.32, 0.68, 0, 0, 0, material("#8a5a36"), 8);
for (const y of [-0.22, 0.22]) {
const band = new THREE.Mesh(
new THREE.TorusGeometry(0.30, 0.028, 5, 12),
material("#3f3a32")
);
band.rotation.x = Math.PI / 2;
band.position.y = y;
group.add(band);
}
} else {
const sack = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.38, 0),
material("#c0aa7f")
);
sack.scale.set(0.88, 1.14, 0.88);
sack.castShadow = true;
group.add(sack);
cylinder(group, 0.10, 0.15, 0.15, 0, 0.35, 0, material("#8e7652"), 7);
}
return group;
}
const workerSpecs = [
{ coat: "#bf6c48", trousers: "#43565a", skin: "#c98960", hat: "#e0c18a", cargo: "crate" },
{ coat: "#567d7b", trousers: "#47454a", skin: "#9e674b", hat: "#d8d0b5", cargo: "sack" },
{ coat: "#c49b4f", trousers: "#3d4b52", skin: "#d4a27a", hat: "#66848b", cargo: "barrel" }
];
const workers = workerSpecs.map((spec, index) => {
const person = makePerson({
coat: spec.coat,
trousers: spec.trousers,
skin: spec.skin,
hat: spec.hat,
scale: 0.96
});
scene.add(person);
const cargo = makeCargo(spec.cargo);
scene.add(cargo);
return {
person,
cargo,
offset: index * 0.29,
duration: 10.8 + index * 0.45,
phase: index * 2.3
};
});
// Pedestrians remain entirely on the inland, clear side of the rope.
const pedestrianSpecs = [
{ coat: "#d7c7a0", trousers: "#4f5557", skin: "#c48e67", z: 1.35, dir: 1, speed: 0.56 },
{ coat: "#6e8f8a", trousers: "#4a4848", skin: "#8d5c43", z: 1.85, dir: -1, speed: 0.48 },
{ coat: "#b96f50", trousers: "#394e58", skin: "#d0a07a", z: 2.05, dir: 1, speed: 0.43 },
{ coat: "#8e9ca4", trousers: "#65584d", skin: "#b77c58", z: 1.55, dir: 1, speed: 0.63 },
{ coat: "#d6b56f", trousers: "#4d5356", skin: "#9f694c", z: 1.95, dir: -1, speed: 0.52 }
];
const pedestrians = pedestrianSpecs.map((spec, index) => {
const person = makePerson({
coat: spec.coat,
trousers: spec.trousers,
skin: spec.skin,
hat: index === 2 ? "#9b5847" : null,
scale: index === 1 ? 0.84 : 0.94
});
scene.add(person);
return { person, spec, phase: index * 4.1 };
});
// Pigeons near the wall.
const pigeons = [];
for (let i = 0; i < 3; i++) {
const pigeon = new THREE.Group();
pigeon.position.set(-4.7 + i * 0.55, 0.12, -0.65);
scene.add(pigeon);
const body = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.17, 0),
material(i === 1 ? "#a7aaa0" : "#d1d0c4")
);
body.scale.set(1.2, 0.9, 0.9);
body.castShadow = true;
pigeon.add(body);
const head = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.105, 0),
material("#d1d0c4")
);
head.position.set(0.17, 0.12, 0);
pigeon.add(head);
const beak = box(pigeon, 0.13, 0.045, 0.045, 0.28, 0.11, 0, material("#c9943f"));
beak.rotation.z = -0.15;
pigeons.push({ group: pigeon, phase: i * 1.7, baseX: pigeon.position.x });
}
// ------------------------------------------------------------
// Animation
// ------------------------------------------------------------
const clock = new THREE.Clock();
let elapsed = 0;
let paused = false;
const pauseButton = document.querySelector("#toggle-motion");
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Play" : "Pause";
pauseButton.setAttribute("aria-pressed", String(paused));
});
function updateWater(time) {
for (let i = 0; i < waterPositions.count; i++) {
const x = waterBase[i * 2];
const z = waterBase[i * 2 + 1];
const wave =
Math.sin(x * 0.72 + time * 1.1) * 0.018 +
Math.sin(z * 0.95 - time * 0.75) * 0.014;
waterPositions.setY(i, wave);
}
waterPositions.needsUpdate = true;
waterGeometry.computeVertexNormals();
for (const ripple of ripples) {
ripple.mesh.position.x += ripple.speed * 0.016;
if (ripple.mesh.position.x > 16.5) ripple.mesh.position.x = -16.5;
ripple.mesh.material.opacity = 0.18 + Math.sin(elapsed * 0.7 + ripple.baseX) * 0.07;
}
}
function updateWorker(worker, time) {
const p = (time / worker.duration + worker.offset) % 1;
const visible = p < 0.985;
worker.person.visible = visible;
worker.cargo.visible = visible;
if (!visible) return;
let cargoX;
let cargoY;
let cargoZ;
let groundY;
if (p < 0.17) {
const u = p / 0.17;
cargoX = -5.6;
cargoZ = THREE.MathUtils.lerp(5.35, 3.38, u);
cargoY = THREE.MathUtils.lerp(1.70, 1.18, u);
groundY = THREE.MathUtils.lerp(0.56, 0.12, u);
} else if (p < 0.82) {
const u = (p - 0.17) / 0.65;
cargoX = THREE.MathUtils.lerp(-5.6, 3.18, u);
cargoZ = 3.38;
cargoY = 1.18;
groundY = 0.12;
} else {
const u = (p - 0.82) / 0.165;
cargoX = THREE.MathUtils.lerp(3.18, 5.0, u);
cargoZ = 3.38;
cargoY = THREE.MathUtils.lerp(1.18, 1.20, u);
groundY = 0.12;
}
worker.cargo.position.set(cargoX, cargoY, cargoZ);
worker.cargo.rotation.y = Math.sin(time * 1.7 + worker.offset * 8) * 0.035;
worker.person.position.set(
cargoX - 0.35,
groundY,
p < 0.17 ? cargoZ : cargoZ + 0.02
);
const walkAmount = p < 0.82 ? 1 : 0.3;
const step = Math.sin(time * 8.5 + worker.phase) * 0.52 * walkAmount;
worker.person.userData.legs[0].rotation.z = step;
worker.person.userData.legs[1].rotation.z = -step;
worker.person.userData.arms[0].rotation.z = 1.12;
worker.person.userData.arms[1].rotation.z = 1.02;
worker.person.rotation.z = Math.sin(time * 8.5 + worker.phase) * 0.018;
if (p > 0.82) {
worker.person.userData.arms[0].rotation.z = THREE.MathUtils.lerp(1.12, 0.72, (p - 0.82) / 0.165);
}
}
function updatePedestrian(pedestrian, time) {
const { person, spec, phase } = pedestrian;
const travel = (spec.phase ?? phase) + time * spec.speed;
const wrapped = ((travel + 12) % 24 + 24) % 24;
person.position.x = spec.dir > 0
? -12 + wrapped
: 12 - wrapped;
person.position.z = spec.z;
person.position.y = 0.11;
person.rotation.y = spec.dir > 0 ? 0 : Math.PI;
const step = Math.sin(time * 7.2 + phase) * 0.46;
person.userData.legs[0].rotation.z = step;
person.userData.legs[1].rotation.z = -step;
person.userData.arms[0].rotation.z = -step * 0.75;
person.userData.arms[1].rotation.z = step * 0.75;
person.position.y = 0.11 + Math.abs(Math.sin(time * 7.2 + phase)) * 0.025;
}
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
if (!paused) elapsed += dt;
updateWater(elapsed);
// Gentle boat motion.
boat.position.y = 0.02 + Math.sin(elapsed * 1.1) * 0.045;
boat.rotation.z = Math.sin(elapsed * 0.82) * 0.008;
boat.rotation.x = Math.sin(elapsed * 0.67) * 0.004;
flag.rotation.y = 0.15 + Math.sin(elapsed * 3.2) * 0.12;
const mooringPositions = mooringLine.geometry.attributes.position;
mooringPositions.setXYZ(0, -10.4, 0.65, 3.96);
mooringPositions.setXYZ(
1,
boat.position.x - 2.7,
boat.position.y + 0.48,
boat.position.z - 1.07
);
mooringPositions.needsUpdate = true;
for (const worker of workers) updateWorker(worker, elapsed);
for (const pedestrian of pedestrians) updatePedestrian(pedestrian, elapsed);
for (const pigeon of pigeons) {
pigeon.group.position.x = pigeon.baseX + Math.sin(elapsed * 0.22 + pigeon.phase) * 0.25;
pigeon.group.rotation.y = Math.sin(elapsed * 0.35 + pigeon.phase) * 0.4;
pigeon.group.children[1].rotation.z = Math.sin(elapsed * 4 + pigeon.phase) * 0.18;
}
renderer.render(scene, camera);
}
animate();
// ------------------------------------------------------------
// Direct camera controls, implemented without addons
// ------------------------------------------------------------
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.style.cursor = "grabbing";
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
cameraState.azimuth -= dx * 0.006;
cameraState.elevation = THREE.MathUtils.clamp(
cameraState.elevation + dy * 0.0045,
0.30,
1.02
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
renderer.domElement.style.cursor = "grab";
if (event?.pointerId !== undefined) {
try {
renderer.domElement.releasePointerCapture(event.pointerId);
} catch (_) {}
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener("pointerleave", stopDragging);
renderer.domElement.style.cursor = "grab";
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
15,
39
);
updateCamera();
}, { passive: false });
function resetView() {
cameraState.azimuth = 0.57;
cameraState.elevation = 0.57;
cameraState.radius = 27;
cameraState.target.set(0, 0.8, 1.0);
updateCamera();
}
document.querySelector("#reset-view").addEventListener("click", resetView);
renderer.domElement.addEventListener("dblclick", resetView);
</script>
</body>
</html>
```