Prompt specification
Build or customize the Three.js 3D scene "Hanseatic-inspired warehouse courtyard route" 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: Hanseatic-inspired warehouse courtyard route
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/hanseatic-inspired-warehouse-courtyard-route-x2355
Scene Description Prompt:
A voxel Hanseatic-inspired warehouse block connecting waterfront loading, storage bays, and rear carts. Use Three.js from cdnjs in one HTML file.
Working Three.js Starter (hanseatic-inspired-warehouse-courtyard-route-x2355):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hanseatic Quay — Voxel Warehouse District</title>
<style>
:root {
color-scheme: dark;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b7d4d8;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.title-card {
position: fixed;
top: 22px;
left: 22px;
max-width: min(390px, calc(100vw - 44px));
padding: 16px 18px;
border: 1px solid rgba(255, 255, 255, 0.22);
border-radius: 14px;
color: #f8ead1;
background: rgba(34, 43, 43, 0.83);
box-shadow: 0 12px 36px rgba(20, 35, 38, 0.22);
backdrop-filter: blur(12px);
pointer-events: none;
user-select: none;
}
.eyebrow {
margin-bottom: 5px;
color: #e2b675;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(23px, 4vw, 34px);
font-weight: 600;
letter-spacing: -0.025em;
}
.subtitle {
margin: 8px 0 0;
color: #c8d0cb;
font-size: 12px;
line-height: 1.45;
}
.controls {
position: fixed;
right: 18px;
bottom: 18px;
padding: 10px 13px;
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 10px;
color: #f7eee0;
background: rgba(35, 46, 46, 0.78);
box-shadow: 0 8px 26px rgba(20, 35, 38, 0.18);
backdrop-filter: blur(10px);
font-size: 11px;
line-height: 1.55;
pointer-events: none;
user-select: none;
}
.controls b { color: #e6bd78; }
.reset {
position: fixed;
top: 22px;
right: 22px;
padding: 9px 12px;
border: 1px solid rgba(255, 255, 255, 0.22);
border-radius: 9px;
color: #fff3dc;
background: rgba(35, 46, 46, 0.78);
cursor: pointer;
font: 700 11px/1 Inter, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
backdrop-filter: blur(10px);
}
.reset:hover { background: rgba(53, 67, 66, 0.92); }
@media (max-width: 600px) {
.title-card { top: 12px; left: 12px; }
.controls { right: 12px; bottom: 12px; }
.reset { top: 12px; right: 12px; }
}
</style>
</head>
<body>
<div class="title-card">
<div class="eyebrow">Voxel waterfront district</div>
<h1>Hanseatic Quay</h1>
<p class="subtitle">
Brick kontors, open storage bays, cargo cranes, and hand carts connect
the harbor to the rear warehouses.
</p>
</div>
<button class="reset" id="reset">Reset view</button>
<div class="controls">
<b>Drag</b> orbit · <b>Wheel / pinch</b> zoom<br>
<b>Shift-drag / right-drag</b> pan · <b>R</b> reset
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer and scene
// ------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xb7d4d8);
scene.fog = new THREE.Fog(0xb7d4d8, 48, 100);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-25, 25, 25, -25, 0.1, 160);
const cameraTarget = new THREE.Vector3(0, 2.5, -0.5);
const view = {
yaw: 0.57,
pitch: 0.66,
zoom: 1.05,
target: cameraTarget
};
function updateCamera() {
const radius = 46;
const horizontal = Math.cos(view.pitch) * radius;
camera.position.set(
view.target.x + Math.sin(view.yaw) * horizontal,
view.target.y + Math.sin(view.pitch) * radius,
view.target.z + Math.cos(view.yaw) * horizontal
);
camera.lookAt(view.target);
camera.zoom = view.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const aspect = window.innerWidth / window.innerHeight;
const size = 25;
camera.left = -size * aspect;
camera.right = size * aspect;
camera.top = size;
camera.bottom = -size;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
resize();
updateCamera();
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
const hemi = new THREE.HemisphereLight(0xdff2f4, 0x5b5546, 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffedcc, 3.1);
sun.position.set(-18, 30, 20);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -30;
sun.shadow.camera.right = 30;
sun.shadow.camera.top = 28;
sun.shadow.camera.bottom = -28;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 80;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x8ebbd0, 0.65);
fill.position.set(20, 12, -20);
scene.add(fill);
// ------------------------------------------------------------
// Materials and geometry helpers
// ------------------------------------------------------------
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.02,
...options
});
const M = {
land: material(0x817f70),
landDark: material(0x65685e),
stone: material(0x777b73),
stoneLight: material(0xa8a393),
stoneDark: material(0x555b56),
cobble: material(0x727873),
cobbleLight: material(0x8b8c80),
brick: material(0x9d4f3f),
brickDark: material(0x763b35),
brickLight: material(0xb4634c),
trim: material(0xd4c4a1),
timber: material(0x49372d),
timberLight: material(0x76523a),
roof: material(0x773e34),
roofLight: material(0x9b5543),
roofDark: material(0x512f2b),
wood: material(0x9b7048),
woodLight: material(0xc08d58),
woodDark: material(0x60442f),
crate: material(0xb9854d),
crateDark: material(0x79502f),
sack: material(0xc8b58b),
sackDark: material(0xa89570),
iron: material(0x333b3b, { metalness: 0.55, roughness: 0.55 }),
ironLight: material(0x64706d, { metalness: 0.45, roughness: 0.6 }),
glass: material(0x385d61, {
emissive: 0x18343a,
emissiveIntensity: 0.35,
roughness: 0.32
}),
gold: material(0xe0b65e),
flag: material(0xb33f36, { side: THREE.DoubleSide }),
rope: material(0x80684a),
water: material(0x4d9cac, {
roughness: 0.28,
metalness: 0.08,
transparent: true,
opacity: 0.92
}),
ripple: new THREE.MeshBasicMaterial({
color: 0xc7edf0,
transparent: true,
opacity: 0.26,
depthWrite: false
})
};
function box(parent, w, h, d, x, y, z, mat) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function beamBetween(parent, a, b, thickness, depth, mat) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(length, thickness, depth),
mat
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(1, 0, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeSign(text, width, height, background = "#45312a", foreground = "#f0d59c") {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 192;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = "#d2b679";
ctx.lineWidth = 8;
ctx.strokeRect(12, 12, canvas.width - 24, canvas.height - 24);
ctx.fillStyle = foreground;
ctx.font = "700 64px Georgia, serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, canvas.width / 2, canvas.height / 2 + 2);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({ map: texture })
);
}
// ------------------------------------------------------------
// Deterministic decorative randomness
// ------------------------------------------------------------
let seed = 1379;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
// ------------------------------------------------------------
// Ground, quay, water, and paving
// ------------------------------------------------------------
box(scene, 40, 0.9, 24.5, 0, -0.45, -3.15, M.land);
box(scene, 40, 0.75, 0.7, 0, -0.25, 9.2, M.stoneDark);
box(scene, 120, 0.12, 76, 0, -0.88, 38, M.water);
for (let x = -19.5; x < 20; x += 1.15) {
box(
scene,
1.03,
0.25,
0.64,
x,
0.01,
9.1,
random() > 0.5 ? M.stone : M.stoneLight
);
}
// Central route from the quay through the warehouse passage to the rear yard.
for (let z = -13.5; z < 8.9; z += 0.72) {
const offset = ((Math.round(z / 0.72) % 3) - 1) * 0.18;
box(scene, 1.12, 0.08, 0.62, offset, 0.055, z, M.cobble);
box(
scene,
0.68,
0.085,
0.6,
offset + (random() - 0.5) * 0.12,
0.06,
z + 0.16,
random() > 0.45 ? M.cobbleLight : M.cobble
);
}
// Broad cobbled rear cart yard.
for (let x = -18; x <= 18; x += 1.5) {
for (let z = -13.8; z <= -6.2; z += 1.3) {
if (Math.abs(x) < 2.1) continue;
box(
scene,
1.32,
0.075,
1.12,
x + (random() - 0.5) * 0.1,
0.055,
z,
random() > 0.55 ? M.cobbleLight : M.cobble
);
}
}
// ------------------------------------------------------------
// Cargo helpers
// ------------------------------------------------------------
function crate(parent, x, y, z, size = 1, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
parent.add(group);
box(group, size, size * 0.82, size, 0, size * 0.41, 0, M.crate);
box(group, size + 0.035, 0.1, size + 0.035, 0, size * 0.15, 0, M.crateDark);
box(group, size + 0.035, 0.1, size + 0.035, 0, size * 0.68, 0, M.crateDark);
box(group, 0.09, size * 0.84, size + 0.05, 0, size * 0.41, 0, M.woodDark);
box(group, size + 0.05, size * 0.84, 0.09, 0, size * 0.41, 0, M.woodDark);
return group;
}
function sack(parent, x, y, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = (random() - 0.5) * 0.4;
parent.add(group);
box(group, 0.78 * scale, 0.34 * scale, 0.62 * scale, 0, 0.17 * scale, 0, M.sack);
box(group, 0.54 * scale, 0.36 * scale, 0.48 * scale, 0.03 * scale, 0.48 * scale, 0, M.sack);
box(group, 0.26 * scale, 0.12 * scale, 0.24 * scale, 0.03 * scale, 0.7 * scale, 0, M.sackDark);
return group;
}
function barrel(parent, x, y, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
parent.add(group);
box(group, 0.66 * scale, 0.88 * scale, 0.66 * scale, 0, 0.44 * scale, 0, M.woodLight);
box(group, 0.73 * scale, 0.11 * scale, 0.73 * scale, 0, 0.18 * scale, 0, M.iron);
box(group, 0.73 * scale, 0.11 * scale, 0.73 * scale, 0, 0.7 * scale, 0, M.iron);
box(group, 0.69 * scale, 0.08 * scale, 0.69 * scale, 0, 0.9 * scale, 0, M.woodDark);
return group;
}
function pallet(parent, x, y, z, width = 1.7, depth = 1.25) {
box(parent, width, 0.12, depth, x, y + 0.06, z, M.woodDark);
for (let i = 0; i < 4; i++) {
box(
parent,
width - 0.12,
0.12,
depth / 5,
x,
y + 0.18,
z - depth / 2 + 0.14 + i * (depth - 0.28) / 3,
M.wood
);
}
}
// ------------------------------------------------------------
// Warehouse architecture
// ------------------------------------------------------------
function buildRoof(centerX, frontZ, backZ, wallHeight, width, rise) {
const depth = frontZ - backZ;
const segmentDepth = depth / 5;
const angle = Math.atan2(rise, width / 2);
const panelLength = Math.hypot(width / 2, rise) + 0.2;
for (const side of [-1, 1]) {
for (let i = 0; i < 5; i++) {
const panel = box(
scene,
panelLength,
0.27,
segmentDepth - 0.045,
centerX + side * width / 4,
wallHeight + rise / 2,
frontZ - (i + 0.5) * segmentDepth,
i % 2 === 0 ? M.roof : M.roofLight
);
panel.rotation.z = -side * angle;
}
}
box(scene, 0.38, 0.42, depth + 0.35, centerX, wallHeight + rise + 0.04, (frontZ + backZ) / 2, M.roofDark);
}
function steppedGable(centerX, frontZ, wallHeight, width, steps = 5) {
for (let i = 0; i < steps; i++) {
const stepWidth = width - (width / (steps + 0.15)) * i;
box(
scene,
stepWidth,
0.38,
0.38,
centerX,
wallHeight + 0.18 + i * 0.37,
frontZ + 0.16,
i % 2 ? M.brickDark : M.brick
);
box(
scene,
stepWidth + 0.06,
0.09,
0.43,
centerX,
wallHeight + 0.35 + i * 0.37,
frontZ + 0.18,
M.trim
);
}
}
function frontWindow(parent, x, y, z, width = 1.25, height = 1.65) {
box(parent, width, height, 0.09, x, y, z, M.glass);
box(parent, width + 0.24, 0.14, 0.18, x, y + height / 2 + 0.04, z + 0.03, M.trim);
box(parent, width + 0.24, 0.14, 0.18, x, y - height / 2 - 0.04, z + 0.03, M.trim);
box(parent, 0.14, height + 0.22, 0.18, x - width / 2 - 0.05, y, z + 0.03, M.trim);
box(parent, 0.14, height + 0.22, 0.18, x + width / 2 + 0.05, y, z + 0.03, M.trim);
box(parent, 0.1, height, 0.2, x, y, z + 0.05, M.timber);
box(parent, width, 0.1, 0.2, x, y, z + 0.05, M.timber);
}
function sideWindow(parent, x, y, z, width = 1.3, height = 1.65) {
box(parent, 0.09, height, width, x, y, z, M.glass);
box(parent, 0.18, 0.14, width + 0.24, x + 0.03, y + height / 2 + 0.04, z, M.trim);
box(parent, 0.18, 0.14, width + 0.24, x + 0.03, y - height / 2 - 0.04, z, M.trim);
box(parent, 0.2, height + 0.22, 0.14, x + 0.03, y, z - width / 2 - 0.05, M.trim);
box(parent, 0.2, height + 0.22, 0.14, x + 0.03, y, z + width / 2 + 0.05, M.trim);
box(parent, 0.2, 0.1, width, x + 0.05, y, z, M.timber);
}
// Left kontor: solid brick front, large timber doorway, stepped gable.
{
const centerX = -7;
const width = 10;
const front = 4.25;
const back = -4.75;
const height = 6;
box(scene, width, height, 0.38, centerX, height / 2, front, M.brick);
box(scene, 0.38, height, 9, centerX - width / 2, height / 2, -0.25, M.brickDark);
box(scene, 0.38, height, 9, centerX + width / 2, height / 2, -0.25, M.brickDark);
box(scene, width, height, 0.38, centerX, height / 2, back, M.brickDark);
box(scene, width, 0.25, 9, centerX, 0.12, -0.25, M.stoneDark);
// Subtle protruding brick courses.
for (let y = 0.7; y < 5.8; y += 0.85) {
box(scene, width + 0.05, 0.065, 0.43, centerX, y, front + 0.02, M.brickDark);
}
// Timber framing.
box(scene, width, 0.24, 0.46, centerX, 4.1, front + 0.07, M.timber);
box(scene, 0.24, height, 0.46, centerX - 4.65, height / 2, front + 0.07, M.timber);
box(scene, 0.24, height, 0.46, centerX + 4.65, height / 2, front + 0.07, M.timber);
// Recessed doorway.
box(scene, 3.35, 4.25, 0.12, centerX, 2.12, front + 0.24, M.timber);
box(scene, 2.95, 3.95, 0.13, centerX, 1.98, front + 0.32, M.timberDark);
box(scene, 0.18, 4.3, 0.22, centerX - 1.72, 2.15, front + 0.38, M.trim);
box(scene, 0.18, 4.3, 0.22, centerX + 1.72, 2.15, front + 0.38, M.trim);
box(scene, 3.6, 0.2, 0.22, centerX, 4.25, front + 0.38, M.trim);
// An open door board.
const doorPivot = new THREE.Group();
doorPivot.position.set(centerX - 1.45, 0, front + 0.43);
doorPivot.rotation.y = -0.58;
scene.add(doorPivot);
box(doorPivot, 1.4, 3.85, 0.15, 0.7, 1.92, 0, M.woodDark);
box(doorPivot, 1.4, 0.13, 0.19, 0.7, 0.7, 0.02, M.iron);
box(doorPivot, 1.4, 0.13, 0.19, 0.7, 3.1, 0.02, M.iron);
frontWindow(scene, centerX - 3.0, 4.85, front + 0.28, 1.15, 1.45);
frontWindow(scene, centerX + 3.0, 4.85, front + 0.28, 1.15, 1.45);
sideWindow(scene, -11.83, 4.3, -1.9, 1.5, 1.6);
sideWindow(scene, -11.83, 4.3, 1.7, 1.5, 1.6);
steppedGable(centerX, front, height, width, 6);
buildRoof(centerX, front + 0.18, back - 0.15, height, width, 2.0);
const sign = makeSign("HANSISCHE KONTOR", 5.4, 0.72);
sign.position.set(centerX, 5.47, front + 0.47);
scene.add(sign);
}
// Right warehouse: three open storage bays.
{
const centerX = 8;
const width = 12;
const front = 4.8;
const back = -5.2;
const height = 6;
box(scene, 0.38, height, 10, centerX - width / 2, height / 2, -0.2, M.brick);
box(scene, 0.38, height, 10, centerX + width / 2, height / 2, -0.2, M.brick);
box(scene, width, height, 0.38, centerX, height / 2, back, M.brickDark);
box(scene, width, 0.25, 10, centerX, 0.12, -0.2, M.stoneDark);
// Front piers and lintel.
for (const x of [2.15, 6.05, 10.05, 13.85]) {
box(scene, 0.58, height, 0.48, x, height / 2, front, M.brickLight);
box(scene, 0.72, 0.2, 0.62, x, 5.72, front + 0.03, M.trim);
}
box(scene, width, 1.05, 0.48, centerX, 5.47, front, M.brick);
box(scene, width + 0.1, 0.2, 0.62, centerX, 6.02, front + 0.03, M.trim);
// Heavy timber lintels above each bay.
for (const x of [4.1, 8.05, 11.95]) {
box(scene, 3.45, 0.27, 0.58, x, 4.84, front + 0.06, M.timber);
box(scene, 3.1, 0.22, 0.16, x, 4.0, front + 0.33, M.timber);
}
// Interior back panels make the open bays read as deep storage rooms.
for (const x of [4.1, 8.05, 11.95]) {
box(scene, 3.5, 4.75, 0.12, x, 2.4, back + 0.27, M.timberDark);
}
steppedGable(centerX, front, height, width, 6);
buildRoof(centerX, front + 0.18, back - 0.15, height, width, 2.25);
const bayNames = ["ZOLL LAGER I", "ZOLL LAGER II", "ZOLL LAGER III"];
const bayCenters = [4.1, 8.05, 11.95];
bayCenters.forEach((x, i) => {
const sign = makeSign(bayNames[i], 2.75, 0.48, "#302f29", "#dfc890");
sign.position.set(x, 5.48, front + 0.28);
scene.add(sign);
});
// Bay storage.
pallet(scene, 4.1, 0.24, 1.7, 2.3, 1.5);
crate(scene, 3.6, 0.43, 1.65, 0.92, 0.03);
crate(scene, 4.55, 0.43, 1.65, 0.88, -0.05);
crate(scene, 4.08, 1.23, 1.65, 0.8, 0.04);
sack(scene, 3.55, 0.25, -0.2, 1.0);
sack(scene, 4.35, 0.25, -0.25, 0.9);
pallet(scene, 8.0, 0.24, 1.8, 2.4, 1.5);
barrel(scene, 7.45, 0.43, 1.75, 1);
barrel(scene, 8.25, 0.43, 1.75, 1);
barrel(scene, 8.58, 0.43, 1.3, 0.85);
crate(scene, 7.5, 1.32, 1.7, 0.86, 0.02);
crate(scene, 11.5, 0.02, 1.8, 1.15, 0.02);
crate(scene, 12.55, 0.02, 1.8, 1.05, -0.04);
crate(scene, 12.03, 1.07, 1.8, 0.88, 0.02);
sack(scene, 11.3, 0.02, -0.15, 1.1);
sack(scene, 12.05, 0.02, -0.2, 1.0);
sack(scene, 12.72, 0.02, -0.1, 0.9);
}
// Central stone arch connecting the waterfront and rear cart yard.
{
box(scene, 0.5, 5.25, 0.72, -1.75, 2.62, 4.55, M.stoneLight);
box(scene, 0.5, 5.25, 0.72, 1.75, 2.62, 4.55, M.stoneLight);
box(scene, 4.5, 1.2, 0.72, 0, 5.72, 4.55, M.stone);
box(scene, 4.9, 0.18, 0.9, 0, 6.35, 4.55, M.trim);
// Block-like arch shoulders.
for (const side of [-1, 1]) {
box(scene, 0.55, 0.5, 0.78, side * 1.42, 4.72, 4.55, M.stone);
box(scene, 0.55, 0.5, 0.78, side * 1.72, 4.28, 4.55, M.stoneLight);
}
const archSign = makeSign("QUAY 07", 2.2, 0.48, "#394342", "#e4c98d");
archSign.position.set(0, 5.7, 4.93);
scene.add(archSign);
}
// Small rooftop watch lantern.
{
const tower = new THREE.Group();
tower.position.set(11.1, 7.25, -2.2);
scene.add(tower);
box(tower, 2.0, 2.05, 2.0, 0, 1.02, 0, M.brickLight);
box(tower, 2.18, 0.18, 2.18, 0, 2.08, 0, M.trim);
box(tower, 1.2, 0.72, 0.09, 0, 1.35, 1.04, M.glass);
for (let i = 0; i < 3; i++) {
box(tower, 1.9 - i * 0.55, 0.24, 1.9 - i * 0.55, 0, 2.25 + i * 0.22, 0, i % 2 ? M.roof : M.roofLight);
}
box(tower, 0.08, 1.6, 0.08, 0, 3.35, 0, M.timber);
const flag = box(tower, 1.0, 0.48, 0.06, 0.52, 3.75, 0, M.flag);
flag.rotation.z = -0.06;
}
// ------------------------------------------------------------
// Dock, cargo crane, and moored barge
// ------------------------------------------------------------
const dock = new THREE.Group();
scene.add(dock);
box(dock, 7.2, 0.35, 7.1, 8, -0.18, 13.0, M.woodDark);
for (let z = 9.8; z <= 16.2; z += 0.62) {
box(dock, 7.25, 0.14, 0.54, 8, 0.03, z, z % 1.24 < 0.7 ? M.wood : M.woodLight);
}
for (const x of [4.75, 11.25]) {
for (const z of [10.0, 12.7, 15.8]) {
box(dock, 0.48, 2.8, 0.48, x, -0.92, z, M.woodDark);
box(dock, 0.58, 0.2, 0.58, x, 0.45, z, M.iron);
}
}
// Quay cargo staged near the warehouse.
crate(scene, -8.6, 0.02, 7.2, 1.2, 0.04);
crate(scene, -7.25, 0.02, 7.25, 1.05, -0.04);
crate(scene, -7.9, 1.07, 7.25, 0.82, 0.03);
barrel(scene, -4.8, 0.02, 7.4, 1.15);
barrel(scene, -3.8, 0.02, 7.35, 1);
sack(scene, -1.8, 0.02, 7.3, 1.05);
crate(scene, 1.4, 0.02, 7.35, 1.15, -0.03);
crate(scene, 2.65, 0.02, 7.4, 1.0, 0.02);
// Timber-and-iron loading crane.
{
const crane = new THREE.Group();
crane.position.set(15.2, 0, 7.4);
scene.add(crane);
box(crane, 1.55, 0.35, 1.55, 0, 0.18, 0, M.stoneDark);
box(crane, 0.5, 7.4, 0.5, 0, 3.9, 0, M.timber);
box(crane, 0.18, 7.5, 0.18, 0, 3.9, 0, M.iron);
beamBetween(crane, [0, 6.9, 0], [0, 6.55, 7.2], 0.38, 0.42, M.timber);
beamBetween(crane, [0, 4.7, 0], [0, 6.55, 4.7], 0.22, 0.25, M.iron);
beamBetween(crane, [0, 6.5, 0], [0, 8.1, 0], 0.24, 0.26, M.timber);
box(crane, 0.16, 4.25, 0.16, 0, 4.35, 7.05, M.ironLight);
box(crane, 0.65, 0.5, 0.4, 0, 2.05, 7.05, M.iron);
box(crane, 0.16, 0.75, 0.16, 0, 1.45, 7.05, M.iron);
// Counterweight and crank.
box(crane, 1.2, 0.9, 1.0, 0, 1.0, -1.0, M.stone);
beamBetween(crane, [0, 6.6, 0], [1.2, 6.2, 0], 0.15, 0.18, M.iron);
}
// Mooring ropes.
beamBetween(scene, [4.8, 0.2, 15.9], [5.0, 0.0, 19.0], 0.06, 0.06, M.rope);
beamBetween(scene, [11.2, 0.2, 15.8], [11.8, 0.0, 19.1], 0.06, 0.06, M.rope);
const barge = new THREE.Group();
barge.position.set(8.4, -0.35, 20.3);
scene.add(barge);
box(barge, 7.8, 0.55, 3.2, 0, -0.05, 0, M.woodDark);
box(barge, 8.3, 0.45, 3.65, 0, 0.36, 0, M.wood);
box(barge, 7.4, 0.16, 3.05, 0, 0.68, 0, M.woodLight);
box(barge, 0.25, 0.8, 3.65, -4.08, 0.83, 0, M.woodDark);
box(barge, 0.25, 0.8, 3.65, 4.08, 0.83, 0, M.woodDark);
box(barge, 8.3, 0.7, 0.22, 0, 0.82, -1.73, M.woodDark);
box(barge, 8.3, 0.55, 0.22, 0, 0.75, 1.73, M.woodDark);
crate(barge, -1.65, 0.78, 0.2, 1.05, 0.02);
crate(barge, -0.5, 0.78, 0.2, 0.92, -0.03);
crate(barge, 1.4, 0.78, -0.1, 1.0, 0.04);
sack(barge, 2.8, 0.78, 0.25, 1.05);
// ------------------------------------------------------------
// Rear hand carts
// ------------------------------------------------------------
function cart(parent, x, z, rotation = 0, loaded = true) {
const group = new THREE.Group();
group.position.set(x, 0.04, z);
group.rotation.y = rotation;
parent.add(group);
box(group, 2.15, 0.22, 1.48, 0, 0.68, 0, M.wood);
box(group, 2.0, 0.08, 1.3, 0, 0.82, 0, M.woodLight);
box(group, 2.2, 0.16, 0.15, 0, 0.55, 0.64, M.woodDark);
// Voxel wheels made from chunky square blocks.
for (const wheelX of [-1.12, 1.12]) {
for (const wheelZ of [-0.92, 0.92]) {
const pattern = [
[0, 0], [0.24, 0], [-0.24, 0], [0, 0.24], [0, -0.24],
[0.18, 0.18], [-0.18, 0.18], [0.18, -0.18], [-0.18, -0.18]
];
for (const [dy, dz] of pattern) {
box(
group,
0.22,
0.23,
0.23,
wheelX,
0.42 + dy,
wheelZ + dz,
M.timber
);
}
box(group, 0.28, 0.28, 0.28, wheelX, 0.42, wheelZ, M.woodDark);
}
}
// Handles and support shaft.
beamBetween(group, [-0.75, 0.65, 0.58], [-0.72, 1.05, 2.6], 0.11, 0.11, M.wood);
beamBetween(group, [0.75, 0.65, 0.58], [0.72, 1.05, 2.6], 0.11, 0.11, M.wood);
box(group, 0.17, 0.12, 2.15, 0, 0.45, 1.25, M.timber);
if (loaded) {
crate(group, -0.38, 0.88, 0.0, 0.78, 0.03);
sack(group, 0.55, 0.88, -0.03, 0.9);
}
return group;
}
cart(scene, 0.15, -7.0, 0.03, true);
cart(scene, -12.3, -9.2, -0.5, true);
cart(scene, -8.8, -11.2, 0.18, false);
cart(scene, 12.8, -9.4, 0.6, true);
cart(scene, 15.0, -11.2, -0.18, false);
// Rear fence.
for (let x = -18; x <= 18; x += 3) {
box(scene, 0.18, 2.0, 0.18, x, 1.0, -14.3, M.timber);
}
box(scene, 36, 0.14, 0.14, 0, 1.5, -14.3, M.woodDark);
box(scene, 36, 0.14, 0.14, 0, 0.75, -14.3, M.woodDark);
// ------------------------------------------------------------
// Small voxel workers
// ------------------------------------------------------------
function worker(parent, x, z, coatColor = 0x455f68, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.04, z);
group.rotation.y = rotation;
parent.add(group);
const coat = material(coatColor);
const skin = material(0xc89c73);
box(group, 0.48, 0.68, 0.3, 0, 1.18, 0, coat);
box(group, 0.35, 0.32, 0.32, 0, 1.68, 0, skin);
box(group, 0.42, 0.14, 0.4, 0, 1.83, 0, M.timber);
box(group, 0.16, 0.58, 0.17, -0.31, 1.16, 0, coat);
box(group, 0.16, 0.58, 0.17, 0.31, 1.16, 0, coat);
box(group, 0.18, 0.62, 0.22, -0.14, 0.43, 0, M.timber);
box(group, 0.18, 0.62, 0.22, 0.14, 0.43, 0, M.timber);
box(group, 0.22, 0.12, 0.4, -0.14, 0.1, 0.08, M.woodDark);
box(group, 0.22, 0.12, 0.4, 0.14, 0.1, 0.08, M.woodDark);
}
worker(scene, -1.4, 7.8, 0x596a63, 0.7);
worker(scene, 4.0, 8.2, 0x874b3d, -0.8);
worker(scene, 11.3, -7.5, 0x455f68, 2.2);
worker(scene, -13.2, -7.1, 0x6b5846, -1.0);
// ------------------------------------------------------------
// Water ripples and atmospheric details
// ------------------------------------------------------------
const ripples = [];
for (let i = 0; i < 34; i++) {
const mesh = box(
scene,
0.7 + random() * 1.9,
0.025,
0.055,
-27 + random() * 54,
-0.79,
10.3 + random() * 25,
M.ripple
);
mesh.castShadow = false;
mesh.receiveShadow = false;
ripples.push({
mesh,
speed: 0.18 + random() * 0.22,
phase: random() * Math.PI * 2
});
}
// A low mooring post line and distant channel markers.
for (const x of [-18, -9, 18, 24]) {
box(scene, 0.45, 1.7, 0.45, x, -0.02, 30 + (x > 0 ? 2 : 0), M.woodDark);
box(scene, 0.58, 0.16, 0.58, x, 0.83, 30 + (x > 0 ? 2 : 0), M.woodLight);
}
// ------------------------------------------------------------
// Direct camera controls
// ------------------------------------------------------------
let dragging = false;
let panning = false;
let lastX = 0;
let lastY = 0;
const pointers = new Map();
let pinchDistance = 0;
const canvas = renderer.domElement;
function resetView() {
view.yaw = 0.57;
view.pitch = 0.66;
view.zoom = 1.05;
view.target.set(0, 2.5, -0.5);
updateCamera();
}
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
dragging = true;
panning = event.button === 2 || event.shiftKey;
lastX = event.clientX;
lastY = event.clientY;
if (pointers.size === 2) {
const points = [...pointers.values()];
pinchDistance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
});
canvas.addEventListener("pointermove", event => {
if (!pointers.has(event.pointerId)) return;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
const points = [...pointers.values()];
const distance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
if (pinchDistance > 0) {
view.zoom = THREE.MathUtils.clamp(
view.zoom * (distance / pinchDistance),
0.55,
2.7
);
updateCamera();
}
pinchDistance = distance;
return;
}
if (!dragging) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
if (panning) {
const right = new THREE.Vector3(Math.cos(view.yaw), 0, -Math.sin(view.yaw));
const forward = new THREE.Vector3(-Math.sin(view.yaw), 0, -Math.cos(view.yaw));
const scale = 0.025 / view.zoom;
view.target.addScaledVector(right, -dx * scale);
view.target.addScaledVector(forward, dy * scale);
view.target.x = THREE.MathUtils.clamp(view.target.x, -24, 24);
view.target.z = THREE.MathUtils.clamp(view.target.z, -24, 24);
} else {
view.yaw -= dx * 0.005;
view.pitch = THREE.MathUtils.clamp(view.pitch + dy * 0.004, 0.28, 1.28);
}
updateCamera();
});
function endPointer(event) {
pointers.delete(event.pointerId);
dragging = pointers.size > 0;
panning = false;
if (pointers.size < 2) pinchDistance = 0;
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("wheel", event => {
event.preventDefault();
view.zoom = THREE.MathUtils.clamp(
view.zoom * Math.exp(-event.deltaY * 0.001),
0.55,
2.7
);
updateCamera();
}, { passive: false });
canvas.addEventListener("dblclick", resetView);
window.addEventListener("keydown", event => {
const key = event.key.toLowerCase();
if (key === "r") {
resetView();
} else if (key === "arrowleft") {
view.yaw += 0.08;
updateCamera();
} else if (key === "arrowright") {
view.yaw -= 0.08;
updateCamera();
} else if (key === "arrowup") {
view.pitch = Math.min(1.28, view.pitch + 0.05);
updateCamera();
} else if (key === "arrowdown") {
view.pitch = Math.max(0.28, view.pitch - 0.05);
updateCamera();
} else if (key === "+" || key === "=") {
view.zoom = Math.min(2.7, view.zoom + 0.1);
updateCamera();
} else if (key === "-") {
view.zoom = Math.max(0.55, view.zoom - 0.1);
updateCamera();
}
});
document.getElementById("reset").addEventListener("click", resetView);
// ------------------------------------------------------------
// Animation
// ------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
const delta = Math.min(clock.getDelta(), 0.04);
barge.position.y = -0.35 + Math.sin(time * 1.15) * 0.055;
barge.rotation.z = Math.sin(time * 0.9) * 0.008;
barge.rotation.x = Math.sin(time * 0.75 + 1) * 0.004;
for (const ripple of ripples) {
ripple.mesh.position.x += ripple.speed * delta;
ripple.mesh.scale.x = 0.78 + Math.sin(time * 0.8 + ripple.phase) * 0.22;
if (ripple.mesh.position.x > 29) {
ripple.mesh.position.x = -29;
ripple.mesh.position.z = 10.5 + Math.random() * 24;
}
}
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```