Prompt specification
Build or customize the Three.js 3D scene "Song-era canal-side loading platform" 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: Song-era canal-side loading platform
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/song-era-canal-side-loading-platform-x2390
Scene Description Prompt:
Song-era canal-side loading platform. Create a historically referenced canal-side loading vignette with boat, baskets, and stepped quay. Keep the pedestrian path open beside the transferred goods. Please build this with Three.js from cdnjs in one self-contained HTML file, using visible voxel blocks.
Working Three.js Starter (song-era-canal-side-loading-platform-x2390):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Song-Era Canal Loading Platform</title>
<style>
:root {
--ink: #24322f;
--paper: #eee7d5;
--muted: #6f746b;
--accent: #a44c35;
--line: rgba(36, 50, 47, 0.25);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d8ddd3;
font-family: Georgia, "Times New Roman", serif;
color: var(--ink);
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.info {
position: fixed;
top: 28px;
left: 30px;
z-index: 5;
width: min(360px, calc(100vw - 60px));
padding: 20px 22px 19px;
background: rgba(238, 231, 213, 0.88);
border: 1px solid rgba(36, 50, 47, 0.24);
box-shadow: 0 12px 35px rgba(38, 47, 43, 0.13);
backdrop-filter: blur(9px);
pointer-events: none;
}
.kicker {
margin-bottom: 9px;
color: var(--accent);
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 36px);
font-weight: 500;
line-height: 1.02;
letter-spacing: -0.025em;
}
.info p {
margin: 12px 0 15px;
color: #505b54;
font-size: 13px;
line-height: 1.55;
}
.details {
display: flex;
flex-wrap: wrap;
gap: 6px 13px;
padding-top: 12px;
border-top: 1px solid var(--line);
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
line-height: 1.45;
letter-spacing: 0.055em;
text-transform: uppercase;
}
.details span::before {
content: "";
display: inline-block;
width: 5px;
height: 5px;
margin-right: 6px;
background: var(--accent);
vertical-align: 1px;
}
#reset {
position: fixed;
top: 29px;
right: 29px;
z-index: 6;
min-width: 106px;
padding: 10px 14px;
border: 1px solid rgba(36, 50, 47, 0.3);
background: rgba(238, 231, 213, 0.86);
color: var(--ink);
font: 600 10px/1 Arial, Helvetica, sans-serif;
letter-spacing: 0.12em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(8px);
transition: background 150ms ease, transform 150ms ease;
}
#reset:hover {
background: #f6efdf;
transform: translateY(-1px);
}
#help {
position: fixed;
right: 28px;
bottom: 25px;
z-index: 5;
padding: 9px 12px;
border: 1px solid rgba(36, 50, 47, 0.18);
background: rgba(238, 231, 213, 0.76);
color: #535e57;
font: 10px/1.4 Arial, Helvetica, sans-serif;
letter-spacing: 0.055em;
pointer-events: none;
backdrop-filter: blur(8px);
}
#route-label {
position: fixed;
z-index: 4;
padding: 7px 10px;
transform: translate(-50%, -100%);
background: rgba(239, 232, 211, 0.92);
border-left: 3px solid #59766e;
color: #344943;
font: 700 9px/1.35 Arial, Helvetica, sans-serif;
letter-spacing: 0.12em;
text-transform: uppercase;
white-space: nowrap;
pointer-events: none;
box-shadow: 0 5px 16px rgba(38, 47, 43, 0.12);
transition: opacity 150ms ease;
}
#route-label::after {
content: "";
position: absolute;
left: 12px;
top: 100%;
height: 25px;
border-left: 1px solid rgba(57, 85, 77, 0.65);
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #d8ddd3;
color: #40514b;
font: 11px/1 Arial, Helvetica, sans-serif;
letter-spacing: 0.2em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 700px) {
.info {
top: 14px;
left: 14px;
width: min(320px, calc(100vw - 28px));
padding: 15px 17px;
}
.info p {
display: none;
}
.details {
margin-top: 12px;
}
#reset {
top: auto;
right: 14px;
bottom: 52px;
}
#help {
right: 14px;
bottom: 14px;
}
#route-label {
display: none;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<section class="info" aria-label="Historical scene description">
<div class="kicker">960–1279 CE · Grand Canal Network</div>
<h1>Freight at the Water’s Edge</h1>
<p>
A Song-era loading quay inspired by the commercial waterways of the
Jiangnan region: bamboo-craft baskets, river freight, masonry steps,
and a clear pedestrian lane beside the transferred goods.
</p>
<div class="details">
<span>Stepped masonry quay</span>
<span>Flat-bottomed cargo boat</span>
<span>Open freight lane</span>
</div>
</section>
<button id="reset" type="button">Reset view</button>
<div id="route-label">Keep clear · pedestrian route</div>
<div id="help">Drag to orbit · wheel to zoom · shift-drag to pan</div>
<div id="loading">Building the canal landing…</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 host = document.getElementById("scene");
const loading = document.getElementById("loading");
const routeLabel = document.getElementById("route-label");
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.04;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
host.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd8ddd3);
scene.fog = new THREE.Fog(0xd8ddd3, 25, 57);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemi = new THREE.HemisphereLight(0xe9eee4, 0x625849, 2.15);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff0d0, 3.15);
sun.position.set(-10, 18, 11);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -20;
sun.shadow.camera.right = 20;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -16;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.bias = -0.00018;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb8d0cf, 0.55);
fill.position.set(12, 8, -8);
scene.add(fill);
const boxGeometry = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function material(color) {
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.84,
metalness: 0.0
})
);
}
return materialCache.get(color);
}
function box(
parent,
x,
y,
z,
width,
height,
depth,
color,
options = {}
) {
const mesh = new THREE.Mesh(boxGeometry, material(color));
mesh.position.set(x, y, z);
mesh.scale.set(width, height, depth);
if (options.rotation) {
mesh.rotation.set(
options.rotation[0] || 0,
options.rotation[1] || 0,
options.rotation[2] || 0
);
}
mesh.castShadow = options.cast !== false;
mesh.receiveShadow = options.receive !== false;
parent.add(mesh);
return mesh;
}
function beam(parent, a, b, width, color) {
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(boxGeometry, material(color));
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.scale.set(width, length, width);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
let seed = 10831;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function choose(list) {
return list[Math.floor(random() * list.length)];
}
// ------------------------------------------------------------
// Canal water: a field of visibly separate surface blocks
// ------------------------------------------------------------
const waterTiles = [];
const waterColors = [
0x527e80,
0x5a8989,
0x4d777a,
0x63918e,
0x567f81
];
box(
scene,
0,
-0.13,
8,
36,
0.22,
16,
0x315c60,
{ cast: false }
);
for (let x = -17; x <= 17; x += 2) {
for (let z = 2; z <= 14; z += 2) {
const tile = box(
scene,
x,
0.015,
z,
1.92,
0.09,
1.92,
choose(waterColors),
{ cast: false, receive: true }
);
waterTiles.push({
mesh: tile,
baseY: tile.position.y,
phase: random() * Math.PI * 2,
speed: 0.55 + random() * 0.45
});
}
}
const ripples = [];
for (let i = 0; i < 38; i++) {
const ripple = box(
scene,
-16 + random() * 32,
0.085 + random() * 0.015,
2.8 + random() * 10.5,
0.45 + random() * 1.1,
0.025,
0.075 + random() * 0.04,
choose([0xa4bbb0, 0x8eaaa4, 0xb7c6b6]),
{ cast: false }
);
ripples.push({
mesh: ripple,
speed: 0.12 + random() * 0.18
});
}
// ------------------------------------------------------------
// Quay foundation and individual masonry blocks
// ------------------------------------------------------------
const stoneColors = [
0x817e6c,
0x8d8875,
0x777461,
0x99917a,
0x85806d
];
box(
scene,
0,
-0.62,
-2.55,
26.2,
1.8,
9.2,
0x5f594b
);
for (let x = -12; x <= 12; x += 2) {
for (let z = -6.5; z <= 1.5; z += 2) {
box(
scene,
x + (random() - 0.5) * 0.08,
0.24,
z + (random() - 0.5) * 0.08,
1.94,
2.3,
1.94,
choose(stoneColors)
);
}
}
// Clear pedestrian path, deliberately separated from the goods.
const pathColors = [0xc0a575, 0xc8ad7d, 0xb99d6c, 0xceb583];
for (let x = -10.4; x <= 10.4; x += 1.2) {
box(
scene,
x,
1.43,
-4.16,
1.1,
0.13,
1.48,
choose(pathColors),
{ cast: false }
);
}
// Narrow dark paving borders, kept flush with the lane.
for (let x = -10.8; x <= 10.8; x += 1.2) {
box(scene, x, 1.45, -3.37, 1.08, 0.06, 0.11, 0x77705c, {
cast: false
});
box(scene, x, 1.45, -4.96, 1.08, 0.06, 0.11, 0x77705c, {
cast: false
});
}
// A stepped landing descending into the canal.
const stepXs = [-7.45, -6.4, -5.35, -4.3];
const stepTops = [1.08, 0.77, 0.46];
for (let s = 0; s < stepTops.length; s++) {
for (const x of stepXs) {
const top = stepTops[s];
box(
scene,
x,
top - 0.58,
2.92 + s * 0.68,
0.98,
1.16,
0.64,
choose(stoneColors)
);
}
}
// Dark waterline blocks and small patches of moss.
for (let x = -3.4; x < 12; x += 1.35) {
box(
scene,
x,
0.32,
2.34,
1.25,
0.55,
0.18,
choose([0x66695b, 0x706d5c, 0x5e6256])
);
if (random() > 0.54) {
box(
scene,
x + 0.25,
0.66,
2.43,
0.42,
0.16,
0.08,
choose([0x65725a, 0x758064]),
{ cast: false }
);
}
}
// ------------------------------------------------------------
// Song-inspired riverside warehouse
// ------------------------------------------------------------
const warehouse = new THREE.Group();
scene.add(warehouse);
const wallColors = [0xd5c9ad, 0xc9bea3, 0xded2b7, 0xbeb39a];
const roofColors = [0x3f5551, 0x465e58, 0x344946, 0x506760];
const timber = 0x784537;
const doorCenters = [-3.0, 2.5];
for (let i = 0; i < 11; i++) {
const x = -7.5 + i * 1.25;
for (let row = 0; row < 3; row++) {
const isDoor =
row === 0 &&
doorCenters.some((doorX) => Math.abs(x - doorX) < 1.08);
if (!isDoor) {
box(
warehouse,
x,
1.78 + row * 0.79,
-6.15,
1.18,
0.72,
0.72,
choose(wallColors)
);
}
}
box(
warehouse,
x,
2.52,
-5.72,
0.13,
2.62,
0.15,
timber
);
}
// Recessed doors.
for (const x of doorCenters) {
box(warehouse, x, 2.42, -6.48, 1.8, 1.95, 0.13, 0x49382e);
for (let j = -2; j <= 2; j++) {
box(
warehouse,
x + j * 0.28,
2.42,
-6.38,
0.065,
1.9,
0.08,
0x73513a
);
}
box(warehouse, x, 3.34, -6.36, 1.95, 0.12, 0.11, timber);
}
// Upper lattice windows.
for (const x of [-6.25, -1.25, 4.0]) {
box(warehouse, x, 2.75, -5.72, 1.05, 1.05, 0.12, 0x4b4539);
for (let j = -1; j <= 1; j++) {
box(
warehouse,
x + j * 0.29,
2.75,
-5.62,
0.055,
1.04,
0.07,
0x9b7954
);
}
box(warehouse, x, 2.75, -5.61, 1.08, 0.055, 0.07, 0x9b7954);
}
// Side wall visible from the default camera.
for (let z = -7.65; z <= -5.9; z += 0.8) {
for (let row = 0; row < 3; row++) {
box(
warehouse,
5.66,
1.78 + row * 0.79,
z,
0.72,
0.72,
0.74,
choose(wallColors)
);
}
}
box(warehouse, -1.0, 3.55, -5.69, 13.9, 0.18, 0.2, timber);
// Stepped tile roof, assembled from individual voxel-like blocks.
const roofRows = [
{ z: -5.38, y: 4.52 },
{ z: -5.88, y: 4.76 },
{ z: -6.40, y: 5.00 },
{ z: -6.92, y: 4.76 },
{ z: -7.42, y: 4.52 }
];
for (const row of roofRows) {
for (let x = -8.7; x <= 5.7; x += 1.22) {
box(
warehouse,
x,
row.y,
row.z,
1.16,
0.30,
0.68,
choose(roofColors)
);
}
}
for (let x = -8.8; x <= 5.8; x += 1.22) {
box(
warehouse,
x,
5.23,
-6.4,
1.16,
0.22,
0.34,
choose([0x304641, 0x3c504b])
);
}
// Upturned corner suggestions.
box(warehouse, -9.0, 4.68, -5.22, 0.55, 0.38, 0.72, 0x3f5551);
box(warehouse, 6.0, 4.68, -5.22, 0.55, 0.38, 0.72, 0x3f5551);
// Plain wooden signboard and a square hanging lantern.
box(warehouse, 0.15, 3.66, -5.55, 1.48, 0.68, 0.12, 0x503c2e);
box(warehouse, 0.15, 3.35, -5.46, 1.62, 0.09, 0.18, 0x9b7447);
box(warehouse, 0.15, 3.97, -5.46, 1.62, 0.09, 0.18, 0x9b7447);
box(warehouse, 0.15, 3.66, -5.47, 1.10, 0.07, 0.08, 0xc3a061);
box(warehouse, 1.1, 3.06, -5.38, 0.48, 0.58, 0.48, 0x943c2f);
box(warehouse, 1.1, 3.06, -5.12, 0.27, 0.37, 0.06, 0xd0a04d);
box(warehouse, 1.1, 3.42, -5.38, 0.08, 0.29, 0.08, 0x47362c);
// ------------------------------------------------------------
// Cargo objects
// ------------------------------------------------------------
function basket(parent, x, y, z, scale = 1, fill = "grain") {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
parent.add(group);
const wicker = 0xb98543;
const wickerDark = 0x80572f;
box(group, 0, 0.07, 0, 0.92, 0.14, 0.76, wickerDark);
for (const level of [0.23, 0.42, 0.61]) {
box(group, 0, level, -0.34, 0.92, 0.10, 0.09, wicker);
box(group, 0, level, 0.34, 0.92, 0.10, 0.09, wicker);
box(group, -0.41, level, 0, 0.09, 0.10, 0.68, wicker);
box(group, 0.41, level, 0, 0.09, 0.10, 0.68, wicker);
}
for (const x of [-0.41, 0.41]) {
for (const z of [-0.33, 0.33]) {
box(group, x, 0.36, z, 0.10, 0.72, 0.10, wickerDark);
}
}
// Squared-off bamboo handle.
box(group, -0.25, 0.87, 0, 0.08, 0.43, 0.08, wickerDark);
box(group, 0.25, 0.87, 0, 0.08, 0.43, 0.08, wickerDark);
box(group, 0, 1.08, 0, 0.58, 0.08, 0.08, wickerDark);
if (fill === "fruit") {
const colors = [0xc46b32, 0xd58a39, 0x8d963e, 0xb5532f];
for (let i = 0; i < 9; i++) {
box(
group,
-0.28 + (i % 3) * 0.27,
0.52 + Math.floor(i / 3) * 0.04,
-0.19 + Math.floor(i / 3) * 0.19,
0.19,
0.19,
0.19,
choose(colors)
);
}
} else if (fill === "greens") {
for (let i = 0; i < 8; i++) {
box(
group,
-0.28 + (i % 3) * 0.27,
0.52 + Math.floor(i / 3) * 0.04,
-0.17 + Math.floor(i / 3) * 0.18,
0.18,
0.18,
0.17,
choose([0x5c7840, 0x768c48, 0x45663a])
);
}
} else {
for (let i = 0; i < 10; i++) {
box(
group,
-0.30 + (i % 4) * 0.20,
0.51 + Math.floor(i / 4) * 0.035,
-0.20 + Math.floor(i / 4) * 0.20,
0.15,
0.14,
0.15,
choose([0xc5a765, 0xb79655, 0xd2b778])
);
}
}
return group;
}
function crate(parent, x, y, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
parent.add(group);
box(group, 0, 0.47, 0, 0.98, 0.94, 0.92, 0x84613c);
box(group, 0, 0.96, 0, 1.06, 0.12, 1.0, 0xa17a49);
for (const px of [-0.34, 0.34]) {
box(group, px, 0.48, 0.48, 0.12, 0.92, 0.09, 0xb08a55);
box(group, px, 0.48, -0.48, 0.12, 0.92, 0.09, 0x65472f);
}
box(group, 0, 0.28, 0.48, 0.94, 0.10, 0.08, 0xb08a55);
box(group, 0, 0.68, 0.48, 0.94, 0.10, 0.08, 0xb08a55);
return group;
}
function sack(parent, x, y, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
parent.add(group);
box(group, 0, 0.19, 0, 0.72, 0.38, 0.56, 0xa99770);
box(group, -0.03, 0.51, 0, 0.61, 0.34, 0.48, 0xb4a27b);
box(group, -0.05, 0.75, 0, 0.30, 0.17, 0.29, 0x887956);
box(group, -0.05, 0.85, 0, 0.34, 0.07, 0.32, 0x6d5e43);
return group;
}
// ------------------------------------------------------------
// Main cargo boat, built entirely from blocks
// ------------------------------------------------------------
const boat = new THREE.Group();
boat.position.set(2.2, 0, 4.65);
boat.rotation.y = -0.025;
scene.add(boat);
const hullColors = [0x69452e, 0x765036, 0x5d3d2a, 0x80583a];
const deckColor = 0xa27a4e;
for (let i = 0; i < 13; i++) {
const x = -4.55 + i * 0.76;
const taper = Math.pow(Math.abs(x) / 4.9, 2);
const halfWidth = 1.24 * (1 - taper * 0.55);
box(
boat,
x,
0.13,
0,
0.72,
0.44,
Math.max(0.7, halfWidth * 1.55),
0x4f3828
);
box(
boat,
x,
1.17,
0,
0.71,
0.18,
Math.max(0.48, halfWidth * 1.72),
choose([deckColor, 0x9b744b, 0xaa8256])
);
for (const side of [-1, 1]) {
box(
boat,
x,
0.77,
side * (halfWidth - 0.14),
0.72,
0.78,
0.31,
choose(hullColors)
);
if (i % 2 === 0) {
box(
boat,
x,
1.20,
side * (halfWidth - 0.10),
0.10,
0.12,
0.34,
0x493425
);
}
}
}
// Raised bow and stern blocks.
box(boat, 4.86, 1.33, 0, 0.58, 0.42, 0.48, 0x68452e);
box(boat, 5.10, 1.50, 0, 0.42, 0.28, 0.28, 0x785037);
box(boat, -4.82, 1.31, 0, 0.52, 0.37, 0.68, 0x68452e);
// Stern cabin and stepped bamboo-mat awning.
box(boat, -2.63, 1.34, 0, 2.1, 0.16, 1.65, 0x8f653f);
for (const x of [-3.55, -1.72]) {
for (const z of [-0.66, 0.66]) {
box(boat, x, 2.12, z, 0.12, 1.55, 0.12, 0x65412e);
}
}
box(boat, -2.64, 2.10, -0.67, 1.82, 1.20, 0.10, 0x9d8057);
box(boat, -2.64, 2.10, 0.67, 1.82, 1.20, 0.10, 0x9d8057);
box(boat, -3.57, 2.10, 0, 0.10, 1.20, 1.25, 0x82613e);
for (const z of [-0.78, -0.46, -0.13, 0.20, 0.53]) {
const height = 1 - Math.abs(z) * 0.18;
box(
boat,
-2.64,
3.08 + height * 0.12,
z,
2.65 - Math.abs(z) * 0.18,
0.20,
0.48,
choose([0xb69a64, 0xa88a54, 0xc0a66f])
);
}
// Mast, yard, and a tightly bundled reed sail.
box(boat, 0.72, 3.02, 0, 0.16, 3.65, 0.16, 0x5c3e2a);
box(boat, 0.72, 4.78, 0, 3.55, 0.13, 0.13, 0x62442e);
for (let i = 0; i < 6; i++) {
box(
boat,
0.72,
2.72 + i * 0.30,
0,
0.72 - i * 0.025,
0.25,
0.55,
choose([0xb69b67, 0xc1a873, 0xa88d57])
);
}
beam(boat, [0.72, 4.75, 0], [4.55, 1.36, 0], 0.045, 0x574230);
beam(boat, [0.72, 4.75, 0], [-4.42, 1.32, 0], 0.045, 0x574230);
// Cargo already in the hold.
basket(boat, 2.55, 1.28, 0.05, 0.92, "grain");
crate(boat, 1.23, 1.28, -0.18, 0.83);
sack(boat, 3.62, 1.28, 0.08, 0.2);
// ------------------------------------------------------------
// Goods and workers on the quay
// ------------------------------------------------------------
basket(scene, -4.15, 1.48, -1.45, 1.0, "fruit");
basket(scene, -3.20, 1.48, -0.66, 0.9, "greens");
basket(scene, -3.62, 1.48, -0.05, 0.76, "grain");
crate(scene, -1.62, 1.48, -1.55, 0.92);
sack(scene, -0.73, 1.48, -1.12, -0.15);
crate(scene, 0.43, 1.48, -1.72, 0.9);
basket(scene, 4.40, 1.48, -1.72, 0.98, "fruit");
basket(scene, 4.45, 1.48, -0.78, 0.84, "grain");
function person(
parent,
x,
y,
z,
robeColor,
rotation = 0,
pose = "plain",
scale = 1
) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
parent.add(group);
const skin = 0xb98260;
const dark = 0x433b32;
box(group, -0.16, 0.27, 0, 0.21, 0.5, 0.24, 0x4e4438);
box(group, 0.16, 0.27, 0, 0.21, 0.5, 0.24, 0x4e4438);
box(group, -0.16, 0.07, 0.07, 0.25, 0.12, 0.38, dark);
box(group, 0.16, 0.07, 0.07, 0.25, 0.12, 0.38, dark);
box(group, 0, 0.83, 0, 0.57, 0.68, 0.39, robeColor);
box(group, 0, 0.52, 0, 0.64, 0.15, 0.43, robeColor);
box(group, -0.39, 0.82, 0, 0.22, 0.53, 0.25, robeColor, {
rotation: [0, 0, -0.08]
});
box(group, 0.39, 0.82, 0, 0.22, 0.53, 0.25, robeColor, {
rotation: [0, 0, 0.08]
});
box(group, 0, 1.19, 0, 0.18, 0.15, 0.18, skin);
box(group, 0, 1.42, 0, 0.38, 0.36, 0.36, skin);
// Cloth head wrap / broad work hat, built as stacked blocks.
box(group, 0, 1.61, 0, 0.58, 0.08, 0.53, 0x8c7041);
box(group, 0, 1.69, 0, 0.40, 0.12, 0.37, 0x9b7b48);
box(group, 0, 1.77, 0, 0.22, 0.08, 0.22, 0x755c37);
if (pose === "yoke") {
box(group, 0, 1.50, 0, 1.95, 0.09, 0.09, 0x62452e);
basket(group, -0.93, 0.47, 0, 0.72, "grain");
basket(group, 0.93, 0.47, 0, 0.72, "greens");
beam(group, [-0.72, 1.48, 0], [-0.70, 1.13, 0], 0.035, 0x79603e);
beam(group, [0.72, 1.48, 0], [0.70, 1.13, 0], 0.035, 0x79603e);
} else if (pose === "shoulder") {
basket(group, 0.48, 0.78, 0.02, 0.68, "fruit");
}
return group;
}
person(scene, 2.20, 1.49, -1.22, 0x526b69, -0.10, "yoke", 1.0);
person(scene, -0.25, 1.49, 0.40, 0x8a5a43, 2.75, "shoulder", 0.98);
person(scene, 3.72, 1.49, -0.03, 0x64704d, 1.45, "plain", 0.94);
person(boat, -0.18, 1.28, -0.52, 0x435d64, 0.15, "plain", 0.84);
// ------------------------------------------------------------
// Transfer plank, bollards, and square-section mooring ropes
// ------------------------------------------------------------
for (let i = 0; i < 4; i++) {
box(
scene,
0.02 + i * 0.26,
1.39,
2.55,
0.22,
0.13,
1.78,
choose([0x9c7448, 0xa98150, 0x89633d])
);
}
box(scene, 0.37, 1.48, 1.78, 1.25, 0.11, 0.16, 0x63452e);
box(scene, 0.37, 1.48, 3.25, 1.25, 0.11, 0.16, 0x63452e);
function bollard(x, z) {
box(scene, x, 1.55, z, 0.22, 0.42, 0.22, 0x5c3e29);
box(scene, x, 1.78, z, 0.40, 0.16, 0.34, 0x64432d);
box(scene, x, 1.88, z, 0.30, 0.12, 0.28, 0x795238);
}
bollard(-1.55, 1.77);
bollard(5.68, 1.72);
beam(
scene,
[-2.0, 1.51, 3.49],
[-1.55, 1.82, 1.77],
0.055,
0x9d8053
);
beam(
scene,
[6.18, 1.52, 3.65],
[5.68, 1.82, 1.72],
0.055,
0x9d8053
);
// ------------------------------------------------------------
// A smaller distant skiff for canal activity
// ------------------------------------------------------------
const skiff = new THREE.Group();
skiff.position.set(-9.2, 0, 6.2);
skiff.rotation.y = 0.24;
scene.add(skiff);
for (let i = 0; i < 8; i++) {
const x = -2.0 + i * 0.56;
const taper = Math.abs(x) / 2.6;
const width = 1.10 - taper * 0.42;
box(skiff, x, 0.33, 0, 0.52, 0.55, width, 0x64452f);
box(skiff, x, 0.72, -width * 0.5 + 0.11, 0.53, 0.48, 0.19, 0x755037);
box(skiff, x, 0.72, width * 0.5 - 0.11, 0.53, 0.48, 0.19, 0x755037);
box(skiff, x, 0.57, 0, 0.50, 0.13, width * 0.78, 0xa07a50);
}
box(skiff, 0.2, 2.08, 0, 0.10, 2.85, 0.10, 0x5f402d);
box(skiff, 0.2, 3.44, 0, 2.30, 0.10, 0.10, 0x61432e);
box(skiff, 0.75, 2.37, 0, 0.57, 1.57, 0.46, 0xb19a68);
crate(skiff, -1.2, 0.68, 0, 0.48);
// ------------------------------------------------------------
// Blocky tree and architectural details
// ------------------------------------------------------------
const tree = new THREE.Group();
tree.position.set(-10.6, 1.45, -1.65);
scene.add(tree);
box(tree, 0, 0.75, 0, 0.34, 1.5, 0.34, 0x705139);
box(tree, 0.38, 1.25, 0, 0.25, 0.72, 0.25, 0x705139, {
rotation: [0, 0, -0.55]
});
box(tree, -0.36, 1.48, 0.05, 0.24, 0.69, 0.24, 0x705139, {
rotation: [0, 0, 0.55]
});
const leafColors = [0x5f7450, 0x71845a, 0x4f6747, 0x819065];
for (let i = 0; i < 12; i++) {
box(
tree,
-0.85 + (i % 4) * 0.55,
1.95 + Math.floor(i / 4) * 0.38,
-0.45 + (i % 3) * 0.38,
0.85,
0.64,
0.78,
choose(leafColors)
);
}
// Small dock-side storage posts along the far warehouse edge.
for (const x of [-9.0, 7.0]) {
box(scene, x, 1.79, -5.72, 0.24, 0.77, 0.24, 0x68452f);
box(scene, x, 2.18, -5.72, 0.43, 0.13, 0.39, 0x795238);
}
// ------------------------------------------------------------
// Camera controls implemented directly, without addons
// ------------------------------------------------------------
const target = new THREE.Vector3(0.2, 1.45, -1.35);
const defaultCamera = {
theta: 0.52,
phi: 1.10,
radius: 26.5
};
let theta = defaultCamera.theta;
let phi = defaultCamera.phi;
let radius = defaultCamera.radius;
function updateCamera() {
phi = THREE.MathUtils.clamp(phi, 0.44, 1.42);
radius = THREE.MathUtils.clamp(radius, 11, 38);
const offset = new THREE.Vector3().setFromSpherical(
new THREE.Spherical(radius, phi, theta)
);
camera.position.copy(target).add(offset);
camera.lookAt(target);
camera.updateMatrixWorld();
}
function resetCamera() {
theta = defaultCamera.theta;
phi = defaultCamera.phi;
radius = defaultCamera.radius;
target.set(0.2, 1.45, -1.35);
updateCamera();
}
document.getElementById("reset").addEventListener("click", resetCamera);
const pointer = {
active: false,
id: null,
x: 0,
y: 0,
panning: false
};
const activePointers = new Map();
let pinchDistance = 0;
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener("pointerdown", (event) => {
activePointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (activePointers.size === 2) {
const points = [...activePointers.values()];
pinchDistance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
pointer.active = true;
pointer.id = event.pointerId;
pointer.x = event.clientX;
pointer.y = event.clientY;
pointer.panning = event.shiftKey || event.button === 2;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!activePointers.has(event.pointerId)) return;
activePointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (activePointers.size === 2) {
const points = [...activePointers.values()];
const distance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
if (pinchDistance > 0) {
radius *= pinchDistance / Math.max(distance, 1);
updateCamera();
}
pinchDistance = distance;
return;
}
if (!pointer.active || pointer.id !== event.pointerId) return;
const dx = event.clientX - pointer.x;
const dy = event.clientY - pointer.y;
pointer.x = event.clientX;
pointer.y = event.clientY;
if (pointer.panning || event.shiftKey) {
const right = new THREE.Vector3()
.setFromMatrixColumn(camera.matrix, 0)
.setY(0)
.normalize();
const panScale = radius * 0.00115;
target.addScaledVector(right, -dx * panScale);
target.y += dy * panScale * 0.72;
target.y = THREE.MathUtils.clamp(target.y, -0.5, 5.0);
} else {
theta -= dx * 0.006;
phi -= dy * 0.005;
}
updateCamera();
});
function endPointer(event) {
activePointers.delete(event.pointerId);
if (activePointers.size < 2) {
pinchDistance = 0;
}
if (event.pointerId === pointer.id) {
pointer.active = false;
pointer.id = null;
}
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
radius *= Math.exp(event.deltaY * 0.001);
updateCamera();
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
if (event.key === "r" || event.key === "R") {
resetCamera();
}
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
updateCamera();
// ------------------------------------------------------------
// Animation and projected route annotation
// ------------------------------------------------------------
const clock = new THREE.Clock();
const routeAnchor = new THREE.Vector3(7.0, 1.78, -4.15);
renderer.setAnimationLoop(() => {
const elapsed = clock.getElapsedTime();
const delta = Math.min(clock.getDelta(), 0.04);
for (const tile of waterTiles) {
tile.mesh.position.y =
tile.baseY +
Math.sin(elapsed * tile.speed + tile.phase) * 0.018;
}
for (const ripple of ripples) {
ripple.mesh.position.x += ripple.speed * delta;
if (ripple.mesh.position.x > 17) {
ripple.mesh.position.x = -17;
}
}
const projected = routeAnchor.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1;
if (visible) {
routeLabel.style.left =
`${(projected.x * 0.5 + 0.5) * window.innerWidth}px`;
routeLabel.style.top =
`${(-projected.y * 0.5 + 0.5) * window.innerHeight}px`;
}
routeLabel.style.opacity = visible ? "1" : "0";
renderer.render(scene, camera);
});
renderer.render(scene, camera);
requestAnimationFrame(() => loading.classList.add("hidden"));
</script>
</body>
</html>
```