Prompt specification
Build or customize the Three.js 3D scene "Canal boat passing a cultivation landing" 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: Canal boat passing a cultivation landing
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/canal-boat-passing-a-cultivation-landing-x2754
Scene Description Prompt:
Create a compact Xochimilco vignette with a small landing, crop beds, and boat passage. Show productive land use alongside navigation rather than only tourist decoration. Build this with Three.js from cdnjs as a voxel scene in one self-contained HTML file.
Working Three.js Starter (canal-boat-passing-a-cultivation-landing-x2754):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Xochimilco — A Working Canal</title>
<style>
:root {
--ink: #173f40;
--muted: #557373;
--paper: rgba(248, 244, 225, 0.9);
--line: rgba(23, 63, 64, 0.17);
--accent: #d76643;
--water: #3198a7;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #c9dfd9;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas.dragging { cursor: grabbing; }
.panel {
position: fixed;
z-index: 10;
border: 1px solid var(--line);
background: var(--paper);
box-shadow: 0 12px 40px rgba(28, 69, 65, 0.12);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
#intro {
top: 22px;
left: 22px;
width: min(370px, calc(100vw - 44px));
padding: 20px 22px 18px;
border-radius: 18px;
pointer-events: none;
}
.eyebrow {
margin-bottom: 8px;
color: var(--accent);
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(29px, 4vw, 43px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
#intro p {
max-width: 320px;
margin: 13px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
#legend {
top: 22px;
right: 22px;
width: 244px;
padding: 15px 16px 14px;
border-radius: 16px;
}
.legend-title {
margin-bottom: 11px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.legend-row {
display: grid;
grid-template-columns: 11px 1fr;
gap: 10px;
align-items: start;
margin: 9px 0;
font-size: 11px;
line-height: 1.4;
}
.swatch {
width: 9px;
height: 9px;
margin-top: 3px;
border-radius: 2px;
box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.legend-row strong {
display: block;
font-size: 11px;
font-weight: 750;
}
.legend-row span {
color: var(--muted);
}
#controls {
right: 22px;
bottom: 22px;
display: flex;
gap: 7px;
padding: 7px;
border-radius: 13px;
}
button {
appearance: none;
border: 0;
border-radius: 9px;
padding: 9px 12px;
background: transparent;
color: var(--ink);
font: inherit;
font-size: 11px;
font-weight: 750;
cursor: pointer;
}
button:hover { background: rgba(23, 63, 64, 0.08); }
button.active {
background: var(--ink);
color: #fff9e9;
}
#hint {
position: fixed;
z-index: 9;
left: 50%;
bottom: 25px;
transform: translateX(-50%);
padding: 9px 13px;
border: 1px solid rgba(23, 63, 64, 0.13);
border-radius: 999px;
background: rgba(248, 244, 225, 0.76);
color: rgba(23, 63, 64, 0.75);
font-size: 10px;
letter-spacing: 0.025em;
pointer-events: none;
white-space: nowrap;
backdrop-filter: blur(10px);
}
#labels {
position: fixed;
inset: 0;
z-index: 5;
pointer-events: none;
}
.scene-label {
position: absolute;
left: 0;
top: 0;
min-width: 120px;
padding: 8px 10px;
border: 1px solid rgba(23, 63, 64, 0.2);
border-radius: 9px;
background: rgba(251, 246, 226, 0.93);
box-shadow: 0 6px 22px rgba(20, 56, 53, 0.13);
transform: translate(-50%, calc(-100% - 13px));
transition: opacity .18s ease;
}
.scene-label::after {
content: "";
position: absolute;
width: 1px;
height: 13px;
left: 50%;
top: 100%;
background: rgba(23, 63, 64, 0.45);
}
.scene-label strong {
display: block;
font-size: 9px;
line-height: 1;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.scene-label small {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 9px;
}
.scene-label.hidden { opacity: 0; }
#loading {
position: fixed;
inset: 0;
z-index: 50;
display: grid;
place-items: center;
background: #c9dfd9;
color: var(--ink);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
transition: opacity .45s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
@media (max-width: 760px) {
#intro {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 15px 17px;
}
h1 { font-size: 29px; }
#intro p { display: none; }
#legend {
top: auto;
right: 12px;
bottom: 66px;
width: 205px;
padding: 12px;
}
.legend-title { display: none; }
.legend-row { margin: 7px 0; }
.legend-row span { display: none; }
#controls {
right: 12px;
bottom: 12px;
}
#hint { display: none; }
.scene-label {
min-width: 92px;
padding: 6px 7px;
}
.scene-label small { display: none; }
.scene-label strong { font-size: 8px; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive voxel landscape of productive chinampa gardens and a working canal in Xochimilco"></canvas>
<section id="intro" class="panel">
<div class="eyebrow">Xochimilco · Mexico City</div>
<h1>A working canal</h1>
<p>
Raised garden beds, nursery trays, irrigation channels, packing sheds,
and produce boats share the same waterscape.
</p>
</section>
<aside id="legend" class="panel">
<div class="legend-title">Landscape layers</div>
<div class="legend-row">
<div class="swatch" style="background:#5f913d"></div>
<div><strong>Chinampa plots</strong><span>Vegetables and maize in irrigated beds</span></div>
</div>
<div class="legend-row">
<div class="swatch" style="background:#c96749"></div>
<div><strong>Transfer landing</strong><span>Crates, scales, packing shed, and dock</span></div>
</div>
<div class="legend-row">
<div class="swatch" style="background:#3198a7"></div>
<div><strong>Boat passage</strong><span>An open freight route through the gardens</span></div>
</div>
</aside>
<div id="controls" class="panel">
<button id="reset" type="button" title="Reset camera">Reset view</button>
<button id="toggle-labels" class="active" type="button" aria-pressed="true">Labels</button>
</div>
<div id="hint">Drag to orbit · Shift-drag to pan · Scroll or pinch to zoom</div>
<div id="labels" aria-hidden="true">
<div class="scene-label" data-x="-8.2" data-y="1.6" data-z="-5.0">
<strong>Chinampa garden</strong>
<small>Rows of vegetables and maize</small>
</div>
<div class="scene-label" data-x="10.0" data-y="2.7" data-z="7.0">
<strong>Transfer landing</strong>
<small>Pack, weigh, and load produce</small>
</div>
<div class="scene-label" data-x="-0.45" data-y="1.6" data-z="3.2">
<strong>Boat passage</strong>
<small>Freight and navigation remain central</small>
</div>
</div>
<div id="loading">Building the canal…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xc9dfd9);
scene.fog = new THREE.Fog(0xc9dfd9, 48, 88);
const camera = new THREE.OrthographicCamera(-20, 20, 15, -15, 0.1, 120);
const hemi = new THREE.HemisphereLight(0xe8f7ed, 0x6a5945, 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff2cf, 3.1);
sun.position.set(-12, 24, 13);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -25;
sun.shadow.camera.right = 25;
sun.shadow.camera.top = 25;
sun.shadow.camera.bottom = -25;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 65;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x87c7cf, 0.65);
fill.position.set(14, 8, -18);
scene.add(fill);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(180, 180),
new THREE.MeshStandardMaterial({ color: 0xd6d3c0, roughness: 1 })
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -1.56;
ground.receiveShadow = true;
scene.add(ground);
const colors = {
base: "#49372d",
baseDark: "#332923",
earth: "#77533c",
earthLight: "#8b6548",
soil: "#493329",
soilLight: "#604332",
stone: "#c3b89e",
stoneLight: "#d7ceb8",
stoneDark: "#998e78",
path: "#b7aa8f",
wood: "#8b5737",
woodLight: "#c4874d",
woodDark: "#573b2e",
water: "#3198a7",
waterLight: "#68c0c1",
waterDark: "#237b8c",
foam: "#d8f2df",
leaf: "#4f873a",
leafLight: "#79aa43",
leafDark: "#356a36",
maize: "#a5ad42",
cob: "#dfbd43",
tomato: "#d9553f",
herb: "#69a75b",
flower: "#d985a2",
cream: "#e9dfc3",
sack: "#b8a37d",
teal: "#286e6c",
tealDark: "#174e50",
rust: "#c86e4b",
shirt: "#376f91",
skin: "#c88e62",
straw: "#d8b45f",
black: "#263c3d"
};
const batches = new Map();
const materialCache = new Map();
const dummy = new THREE.Object3D();
function material(color) {
if (!materialCache.has(color)) {
const isWater = color === colors.water ||
color === colors.waterLight ||
color === colors.waterDark;
materialCache.set(color, new THREE.MeshStandardMaterial({
color,
roughness: isWater ? 0.28 : 0.88,
metalness: isWater ? 0.08 : 0,
flatShading: true
}));
}
return materialCache.get(color);
}
function box(x, y, z, w, h, d, color, rotation = [0, 0, 0]) {
if (!batches.has(color)) batches.set(color, []);
dummy.position.set(x, y, z);
dummy.rotation.set(rotation[0], rotation[1], rotation[2]);
dummy.scale.set(w, h, d);
dummy.updateMatrix();
batches.get(color).push(dummy.matrix.clone());
}
function flushBoxes() {
const unitBox = new THREE.BoxGeometry(1, 1, 1);
for (const [color, matrices] of batches) {
const mesh = new THREE.InstancedMesh(unitBox, material(color), matrices.length);
matrices.forEach((matrix, i) => mesh.setMatrixAt(i, matrix));
mesh.instanceMatrix.needsUpdate = true;
mesh.castShadow = ![
colors.water, colors.waterLight, colors.waterDark
].includes(color);
mesh.receiveShadow = true;
mesh.frustumCulled = false;
scene.add(mesh);
}
}
let seed = 1937;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function range(a, b) {
return a + (b - a) * random();
}
function border(cx, cz, w, d, y, color, thickness = 0.13, height = 0.2) {
box(cx, y, cz - d / 2, w, height, thickness, color);
box(cx, y, cz + d / 2, w, height, thickness, color);
box(cx - w / 2, y, cz, thickness, height, d, color);
box(cx + w / 2, y, cz, thickness, height, d, color);
}
function lettuce(x, z, y = 0.45) {
box(x, y + 0.12, z, 0.12, 0.24, 0.12, colors.leafDark);
box(x, y + 0.24, z, 0.31, 0.22, 0.3, colors.leaf);
box(x - 0.13, y + 0.22, z + 0.05, 0.2, 0.16, 0.22, colors.leafLight);
box(x + 0.13, y + 0.23, z - 0.04, 0.2, 0.17, 0.23, colors.leafLight);
box(x + 0.02, y + 0.33, z + 0.04, 0.18, 0.15, 0.18, colors.leaf);
}
function tomatoPlant(x, z, y = 0.45) {
box(x, y + 0.23, z, 0.08, 0.46, 0.08, colors.leafDark);
box(x - 0.13, y + 0.29, z, 0.27, 0.12, 0.15, colors.leaf);
box(x + 0.13, y + 0.33, z + 0.04, 0.25, 0.12, 0.16, colors.leaf);
box(x - 0.13, y + 0.18, z + 0.1, 0.14, 0.14, 0.14, colors.tomato);
box(x + 0.12, y + 0.22, z - 0.08, 0.14, 0.14, 0.14, colors.tomato);
}
function herb(x, z, y = 0.45) {
box(x, y + 0.13, z, 0.08, 0.26, 0.08, colors.leafDark);
box(x - 0.1, y + 0.2, z, 0.2, 0.16, 0.2, colors.herb);
box(x + 0.1, y + 0.21, z + 0.03, 0.2, 0.17, 0.2, colors.leafLight);
}
function maize(x, z, y = 0.45) {
const h = range(1.1, 1.55);
box(x, y + h / 2, z, 0.09, h, 0.09, colors.maize);
box(x - 0.18, y + h * 0.53, z, 0.4, 0.08, 0.14, colors.leaf, [0, 0, -0.28]);
box(x + 0.18, y + h * 0.68, z, 0.4, 0.08, 0.14, colors.leaf, [0, 0, 0.28]);
box(x, y + h * 0.78, z + 0.1, 0.14, 0.28, 0.13, colors.cob);
}
function soilBed(cx, cz, w, d, crop) {
box(cx, 0.29, cz, w, 0.26, d, colors.soil);
border(cx, cz, w + 0.12, d + 0.12, 0.39, colors.woodDark, 0.13, 0.3);
const xStart = cx - w / 2 + 0.48;
const xEnd = cx + w / 2 - 0.48;
const zStart = cz - d / 2 + 0.48;
const zEnd = cz + d / 2 - 0.48;
const spacing = crop === "maize" ? 0.78 : 0.64;
const rowSpacing = crop === "maize" ? 0.94 : 0.7;
for (let x = xStart; x <= xEnd; x += spacing) {
for (let z = zStart; z <= zEnd; z += rowSpacing) {
const jitterX = range(-0.06, 0.06);
const jitterZ = range(-0.06, 0.06);
if (crop === "maize") maize(x + jitterX, z + jitterZ);
else if (crop === "tomato") tomatoPlant(x + jitterX, z + jitterZ);
else if (crop === "herbs") herb(x + jitterX, z + jitterZ);
else lettuce(x + jitterX, z + jitterZ);
}
}
}
function crate(x, baseY, z, scale = 1, produce = colors.leafLight) {
const s = scale;
box(x, baseY + 0.25 * s, z, 0.7 * s, 0.1 * s, 0.7 * s, colors.wood);
box(x, baseY + 0.45 * s, z - 0.31 * s, 0.7 * s, 0.38 * s, 0.08 * s, colors.woodLight);
box(x, baseY + 0.45 * s, z + 0.31 * s, 0.7 * s, 0.38 * s, 0.08 * s, colors.woodLight);
box(x - 0.31 * s, baseY + 0.45 * s, z, 0.08 * s, 0.38 * s, 0.62 * s, colors.woodLight);
box(x + 0.31 * s, baseY + 0.45 * s, z, 0.08 * s, 0.38 * s, 0.62 * s, colors.woodLight);
box(x - 0.12 * s, baseY + 0.37 * s, z, 0.25 * s, 0.16 * s, 0.25 * s, produce);
box(x + 0.14 * s, baseY + 0.38 * s, z + 0.08 * s, 0.24 * s, 0.17 * s, 0.23 * s, produce);
}
function person(x, z, groundY, shirt = colors.shirt, hat = true, carrying = false) {
box(x - 0.12, groundY + 0.31, z, 0.17, 0.62, 0.2, colors.black);
box(x + 0.12, groundY + 0.31, z, 0.17, 0.62, 0.2, colors.black);
box(x, groundY + 0.91, z, 0.55, 0.65, 0.32, shirt);
box(x, groundY + 1.39, z, 0.34, 0.36, 0.34, colors.skin);
box(x - 0.36, groundY + 0.9, z, 0.15, 0.52, 0.16, colors.skin, [0, 0, -0.12]);
box(x + 0.36, groundY + 0.9, z, 0.15, 0.52, 0.16, colors.skin, [0, 0, 0.12]);
if (hat) {
box(x, groundY + 1.61, z, 0.55, 0.09, 0.55, colors.straw);
box(x, groundY + 1.72, z, 0.34, 0.17, 0.34, colors.straw);
}
if (carrying) {
box(x, groundY + 0.85, z + 0.53, 0.58, 0.36, 0.48, colors.woodLight);
box(x, groundY + 0.93, z + 0.53, 0.32, 0.15, 0.28, colors.tomato);
}
}
function tree(x, z, scale = 1) {
const s = scale;
box(x, 0.85 * s, z, 0.35 * s, 1.7 * s, 0.35 * s, colors.woodDark);
box(x - 0.35 * s, 1.65 * s, z, 0.8 * s, 0.28 * s, 0.3 * s, colors.wood, [0, 0, 0.25]);
box(x + 0.35 * s, 1.9 * s, z, 0.8 * s, 0.28 * s, 0.3 * s, colors.wood, [0, 0, -0.25]);
box(x, 2.15 * s, z, 1.55 * s, 1.0 * s, 1.35 * s, colors.leafDark);
box(x - 0.55 * s, 2.45 * s, z + 0.08, 1.15 * s, 0.8 * s, 1.1 * s, colors.leaf);
box(x + 0.52 * s, 2.3 * s, z - 0.1, 1.05 * s, 0.75 * s, 1.0 * s, colors.leafLight);
}
// Diorama cutaway and canal.
box(0, -1.3, 0, 28.4, 0.38, 28.4, colors.baseDark);
box(0, -0.78, 0, 28, 0.92, 28, colors.base);
box(-8.2, -0.08, 0, 11.6, 0.5, 27.6, colors.earth);
box(8.2, -0.08, 0, 11.6, 0.5, 27.6, colors.earth);
box(0, -0.025, 0, 4.8, 0.27, 27.7, colors.water);
// Continuous canal-side paths and stone banks.
box(-2.92, 0.205, 0, 0.88, 0.1, 27.2, colors.path);
box(2.92, 0.205, 0, 0.88, 0.1, 27.2, colors.path);
for (let z = -12.9; z <= 12.9; z += 1.25) {
const shade = random() > 0.5 ? colors.stone : colors.stoneDark;
box(-2.43, 0.2, z, 0.24, 0.26, 0.85, shade);
box(2.43, 0.2, z, 0.24, 0.26, 0.85, shade);
}
// Water pixels and current marks.
for (let i = 0; i < 75; i++) {
const x = range(-2.05, 2.05);
const z = range(-13.3, 13.3);
const color = random() > 0.58 ? colors.waterLight : colors.waterDark;
box(x, 0.12, z, range(0.18, 0.75), 0.015, range(0.055, 0.16), color);
}
// Productive chinampa beds on the left.
soilBed(-11.3, -7.1, 3.8, 9.5, "maize");
soilBed(-6.55, -7.1, 3.35, 9.5, "lettuce");
soilBed(-11.3, 5.4, 3.8, 7.8, "tomato");
soilBed(-6.55, 5.4, 3.35, 7.8, "herbs");
// Narrow irrigation channels through the plots.
box(-8.86, 0.185, 0, 0.72, 0.12, 24.5, colors.water);
box(-8.75, 0.225, -0.55, 9.1, 0.1, 0.7, colors.water);
box(-8.86, 0.23, -0.55, 0.95, 0.13, 0.13, colors.woodLight);
box(-8.86, 0.23, 0.55, 0.95, 0.13, 0.13, colors.woodLight);
// Right-side market gardens.
soilBed(8.05, -9.05, 8.2, 4.05, "tomato");
soilBed(8.05, -4.0, 8.2, 3.1, "lettuce");
box(3.73, 0.185, -7.7, 0.46, 0.12, 9.2, colors.water);
box(8.0, 0.185, -6.45, 8.1, 0.12, 0.48, colors.water);
// Nursery with seedling trays under a slatted shade roof.
box(11.45, 0.73, -11.6, 3.6, 0.18, 2.15, colors.woodLight);
for (const x of [9.85, 13.05]) {
for (const z of [-12.45, -10.75]) {
box(x, 1.2, z, 0.13, 2.2, 0.13, colors.woodDark);
}
}
for (let i = 0; i < 7; i++) {
box(11.45, 2.28, -12.52 + i * 0.31, 3.9, 0.12, 0.18, colors.wood);
}
for (let row = 0; row < 3; row++) {
for (let col = 0; col < 5; col++) {
const x = 10.15 + col * 0.65;
const z = -12.2 + row * 0.58;
box(x, 0.88, z, 0.48, 0.16, 0.4, colors.soilLight);
box(x, 1.01, z, 0.18, 0.13, 0.18, colors.leafLight);
box(x + 0.14, 1.01, z + 0.08, 0.14, 0.12, 0.14, colors.leaf);
}
}
// Small irrigation pump and squared-off pipe.
box(3.25, 0.63, -11.7, 0.7, 0.9, 0.72, colors.tealDark);
box(3.25, 1.15, -11.7, 0.45, 0.22, 0.45, colors.waterDark);
box(3.65, 0.48, -11.7, 1.35, 0.16, 0.16, colors.waterDark);
box(4.22, 0.78, -11.7, 0.16, 0.75, 0.16, colors.waterDark);
// Transfer landing: paving, quay coping, and dock.
box(8.05, 0.255, 7.15, 10.9, 0.16, 11.7, colors.stoneDark);
for (let x = 3.05; x <= 13.2; x += 1.14) {
for (let z = 1.7; z <= 12.5; z += 1.12) {
const c = random() > 0.72 ? colors.stoneLight : colors.stone;
box(x, 0.35, z, 1.06, 0.1, 1.04, c);
}
}
for (let z = 1.5; z <= 12.8; z += 0.75) {
box(2.67, 0.35, z, 0.35, 0.32, 0.65, colors.stoneLight);
}
for (let i = 0; i < 12; i++) {
box(1.66, 0.49, 2.15 + i * 0.44, 1.42, 0.16, 0.38, colors.woodLight);
}
for (const z of [2.35, 4.7, 7.15]) {
box(1.0, 0.23, z, 0.2, 1.2, 0.2, colors.woodDark);
box(2.42, 0.23, z, 0.2, 1.2, 0.2, colors.woodDark);
box(1.0, 0.76, z, 1.55, 0.13, 0.13, colors.woodDark);
}
// Mooring posts.
for (const z of [1.55, 7.9, 10.4]) {
box(2.82, 0.72, z, 0.23, 1.35, 0.23, colors.woodDark);
box(2.82, 1.42, z, 0.3, 0.13, 0.3, colors.wood);
}
// Packing shed with an open front facing the landing.
box(10.2, 0.44, 7.45, 4.9, 0.18, 4.25, colors.stone);
box(10.2, 1.42, 5.45, 4.8, 2.0, 0.25, colors.rust);
box(7.95, 1.42, 7.45, 0.25, 2.0, 4.0, colors.rust);
box(12.45, 1.42, 7.45, 0.25, 2.0, 4.0, colors.rust);
box(10.2, 2.54, 7.45, 5.25, 0.28, 4.75, colors.teal);
box(10.2, 2.75, 7.45, 4.65, 0.16, 4.2, colors.tealDark);
box(10.2, 1.07, 5.66, 1.15, 1.85, 0.08, colors.woodDark);
box(10.2, 2.18, 7.45, 0.17, 0.75, 3.85, colors.tealDark);
// Scale, sacks, crates, and stacked produce.
box(6.2, 0.9, 10.0, 1.45, 0.16, 0.95, colors.woodLight);
box(6.2, 0.52, 10.0, 0.18, 0.78, 0.65, colors.woodDark);
box(6.2, 1.12, 10.0, 0.65, 0.12, 0.65, colors.stoneLight);
box(6.2, 1.37, 9.78, 0.08, 0.42, 0.08, colors.black);
box(6.2, 1.55, 9.78, 0.52, 0.08, 0.08, colors.black);
crate(8.55, 0.4, 9.8, 1.05, colors.tomato);
crate(9.4, 0.4, 9.8, 1.05, colors.leafLight);
crate(8.95, 1.05, 9.8, 1.0, colors.cob);
crate(10.0, 0.4, 6.0, 0.95, colors.herb);
crate(10.95, 0.4, 6.0, 0.95, colors.tomato);
box(6.9, 0.78, 5.9, 0.7, 0.85, 0.65, colors.sack);
box(7.45, 0.7, 6.35, 0.62, 0.75, 0.6, colors.sack);
// Main produce boat, aligned with the canal.
const boatX = -0.47;
const boatZ = 3.45;
box(boatX, 0.16, boatZ, 1.12, 0.26, 5.05, colors.woodDark);
box(boatX, 0.4, boatZ, 1.76, 0.34, 5.2, colors.tealDark);
box(boatX, 0.61, boatZ, 1.35, 0.1, 4.75, colors.wood);
box(boatX - 0.82, 0.77, boatZ, 0.17, 0.45, 4.9, colors.teal);
box(boatX + 0.82, 0.77, boatZ, 0.17, 0.45, 4.9, colors.teal);
box(boatX - 0.82, 1.01, boatZ, 0.19, 0.09, 4.9, colors.cob);
box(boatX + 0.82, 1.01, boatZ, 0.19, 0.09, 4.9, colors.cob);
box(boatX, 0.76, boatZ - 2.48, 1.65, 0.42, 0.18, colors.teal);
box(boatX, 0.56, boatZ + 2.63, 1.46, 0.34, 0.34, colors.teal);
box(boatX, 0.48, boatZ + 2.84, 1.02, 0.28, 0.24, colors.teal);
crate(boatX - 0.22, 0.67, boatZ - 0.85, 0.86, colors.tomato);
crate(boatX + 0.22, 0.67, boatZ + 0.08, 0.8, colors.leafLight);
box(boatX - 0.23, 0.88, boatZ + 0.95, 0.58, 0.45, 0.55, colors.sack);
// Boat operator and pole.
person(boatX, boatZ - 1.85, 0.68, colors.shirt, true, false);
box(boatX + 0.28, 1.38, boatZ - 1.47, 0.055, 2.8, 0.055, colors.woodLight, [-0.34, 0, 0]);
// Smaller hand-propelled skiff farther up the canal.
box(0.35, 0.17, -7.0, 0.85, 0.22, 2.8, colors.woodDark);
box(0.35, 0.38, -7.0, 1.15, 0.25, 2.75, colors.rust);
box(0.35, 0.55, -7.0, 0.78, 0.08, 2.35, colors.wood);
box(-0.17, 0.68, -7.0, 0.12, 0.32, 2.2, colors.woodDark);
box(0.87, 0.68, -7.0, 0.12, 0.32, 2.2, colors.woodDark);
person(0.35, -7.7, 0.6, colors.rust, false, false);
box(0.55, 1.3, -7.45, 0.05, 2.4, 0.05, colors.woodLight, [-0.3, 0, 0]);
// Workers indicate active cultivation and loading.
person(-8.15, 2.45, 0.18, colors.rust, true, true);
person(4.75, 4.05, 0.41, colors.shirt, true, true);
person(6.0, 8.7, 0.41, colors.tealDark, false, false);
// Floating water hyacinths and reeds.
for (let i = 0; i < 38; i++) {
const side = random() > 0.5 ? 1 : -1;
const x = side * range(1.35, 2.15);
const z = range(-12.8, 12.8);
box(x, 0.18, z, range(0.18, 0.35), 0.11, range(0.18, 0.34), colors.leaf);
box(x + 0.13, 0.23, z + 0.06, 0.16, 0.12, 0.17, colors.leafLight);
if (random() > 0.76) {
box(x, 0.34, z, 0.1, 0.12, 0.1, colors.flower);
}
}
for (const z of [-12.5, -11.6, 11.4, 12.3]) {
for (let i = 0; i < 4; i++) {
box(2.15 + i * 0.08, 0.58 + i * 0.05, z + i * 0.07,
0.08, 0.8 + i * 0.1, 0.08, colors.leafDark);
}
}
// Channel markers at the distant end.
box(-0.45, 0.29, -12.6, 0.24, 0.7, 0.24, colors.woodDark);
box(-0.45, 0.68, -12.6, 0.29, 0.25, 0.29, colors.tomato);
box(1.75, 0.29, -12.6, 0.24, 0.7, 0.24, colors.woodDark);
box(1.75, 0.68, -12.6, 0.29, 0.25, 0.29, colors.leafLight);
// A few trees frame the productive landscape.
tree(-13.15, -12.75, 0.82);
tree(-13.1, 11.8, 0.78);
tree(13.05, 12.55, 0.86);
// Physical landing sign.
const signAngle = 0.62;
box(4.22, 1.48, 1.85, 2.55, 0.72, 0.12, colors.woodDark, [0, signAngle, 0]);
box(4.05, 0.85, 1.65, 0.14, 1.35, 0.14, colors.wood);
box(4.45, 0.85, 2.02, 0.14, 1.35, 0.14, colors.wood);
const signCanvas = document.createElement("canvas");
signCanvas.width = 768;
signCanvas.height = 192;
const ctx = signCanvas.getContext("2d");
ctx.fillStyle = "#eadfbd";
ctx.fillRect(0, 0, 768, 192);
ctx.fillStyle = "#d76643";
ctx.fillRect(0, 0, 768, 25);
ctx.fillStyle = "#173f40";
ctx.font = "800 54px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText("PRODUCE LANDING", 384, 103);
ctx.font = "600 22px system-ui, sans-serif";
ctx.fillStyle = "#557373";
ctx.fillText("HUERTA · EMBARQUE · MERCADO", 384, 151);
const signTexture = new THREE.CanvasTexture(signCanvas);
signTexture.colorSpace = THREE.SRGBColorSpace;
signTexture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
const sign = new THREE.Mesh(
new THREE.PlaneGeometry(2.36, 0.59),
new THREE.MeshBasicMaterial({ map: signTexture, side: THREE.DoubleSide })
);
sign.position.set(
4.22 + Math.sin(signAngle) * 0.075,
1.48,
1.85 + Math.cos(signAngle) * 0.075
);
sign.rotation.y = signAngle;
scene.add(sign);
flushBoxes();
// Animated surface ripples emphasize current and movement.
const ripples = [];
const rippleGeometry = new THREE.BoxGeometry(1, 0.012, 0.09);
for (let i = 0; i < 24; i++) {
const material = new THREE.MeshBasicMaterial({
color: colors.foam,
transparent: true,
opacity: 0.2,
depthWrite: false
});
const ripple = new THREE.Mesh(rippleGeometry, material);
ripple.position.set(range(-1.9, 1.9), 0.145, range(-12.5, 12.5));
ripple.rotation.y = range(-0.18, 0.18);
ripple.userData.phase = random();
ripple.userData.speed = range(0.08, 0.18);
scene.add(ripple);
ripples.push(ripple);
}
// Camera controls implemented locally without addons.
const target = new THREE.Vector3(0, 0.25, 0);
let yaw = 0.69;
let pitch = 0.73;
let zoom = 1.02;
let yawGoal = yaw;
let pitchGoal = pitch;
let zoomGoal = zoom;
const defaultView = {
yaw: 0.69,
pitch: 0.73,
zoom: 1.02,
target: new THREE.Vector3(0, 0.25, 0)
};
function resetView() {
yawGoal = defaultView.yaw;
pitchGoal = defaultView.pitch;
zoomGoal = defaultView.zoom;
target.copy(defaultView.target);
}
function updateCamera(dt) {
const damping = 1 - Math.exp(-dt * 10);
yaw += (yawGoal - yaw) * damping;
pitch += (pitchGoal - pitch) * damping;
zoom += (zoomGoal - zoom) * damping;
const distance = 42;
const horizontal = Math.cos(pitch) * distance;
camera.position.set(
target.x + Math.sin(yaw) * horizontal,
target.y + Math.sin(pitch) * distance,
target.z + Math.cos(yaw) * horizontal
);
camera.lookAt(target);
const aspect = innerWidth / innerHeight;
const visibleHeight = Math.max(23, 34 / aspect);
camera.left = -visibleHeight * aspect / (2 * zoom);
camera.right = visibleHeight * aspect / (2 * zoom);
camera.top = visibleHeight / (2 * zoom);
camera.bottom = -visibleHeight / (2 * zoom);
camera.updateProjectionMatrix();
}
const pointers = new Map();
let pinchDistance = 0;
let activeButton = 0;
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
activeButton = event.button;
canvas.classList.add("dragging");
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
pinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
canvas.addEventListener("pointermove", event => {
const previous = pointers.get(event.pointerId);
if (!previous) return;
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
previous.x = event.clientX;
previous.y = event.clientY;
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
if (pinchDistance > 0 && distance > 0) {
zoomGoal = THREE.MathUtils.clamp(zoomGoal * distance / pinchDistance, 0.62, 1.9);
}
pinchDistance = distance;
return;
}
if (event.shiftKey || activeButton === 2) {
const right = new THREE.Vector3(Math.cos(yaw), 0, -Math.sin(yaw));
const forward = new THREE.Vector3(-Math.sin(yaw), 0, -Math.cos(yaw));
target.addScaledVector(right, -dx * 0.026);
target.addScaledVector(forward, -dy * 0.026);
} else {
yawGoal -= dx * 0.006;
pitchGoal = THREE.MathUtils.clamp(pitchGoal + dy * 0.005, 0.34, 1.25);
}
});
function endPointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) pinchDistance = 0;
if (!pointers.size) canvas.classList.remove("dragging");
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("wheel", event => {
event.preventDefault();
zoomGoal = THREE.MathUtils.clamp(
zoomGoal * Math.exp(-event.deltaY * 0.001),
0.62,
1.9
);
}, { passive: false });
window.addEventListener("keydown", event => {
const key = event.key.toLowerCase();
if (key === "arrowleft") yawGoal += 0.1;
else if (key === "arrowright") yawGoal -= 0.1;
else if (key === "arrowup") pitchGoal = Math.min(1.25, pitchGoal + 0.07);
else if (key === "arrowdown") pitchGoal = Math.max(0.34, pitchGoal - 0.07);
else if (key === "+" || key === "=") zoomGoal = Math.min(1.9, zoomGoal * 1.1);
else if (key === "-") zoomGoal = Math.max(0.62, zoomGoal / 1.1);
else if (key === "r") resetView();
else if (key === "l") toggleLabels();
});
document.querySelector("#reset").addEventListener("click", resetView);
const labelElements = [...document.querySelectorAll(".scene-label")];
let labelsVisible = true;
function toggleLabels() {
labelsVisible = !labelsVisible;
const button = document.querySelector("#toggle-labels");
button.classList.toggle("active", labelsVisible);
button.setAttribute("aria-pressed", String(labelsVisible));
labelElements.forEach(label => label.classList.toggle("hidden", !labelsVisible));
}
document.querySelector("#toggle-labels").addEventListener("click", toggleLabels);
const projected = new THREE.Vector3();
function updateLabels() {
if (!labelsVisible) return;
for (const label of labelElements) {
projected.set(
Number(label.dataset.x),
Number(label.dataset.y),
Number(label.dataset.z)
).project(camera);
const visible = projected.z > -1 && projected.z < 1;
label.style.opacity = visible ? "1" : "0";
label.style.left = `${(projected.x * 0.5 + 0.5) * innerWidth}px`;
label.style.top = `${(-projected.y * 0.5 + 0.5) * innerHeight}px`;
}
}
function resize() {
renderer.setSize(innerWidth, innerHeight, false);
}
window.addEventListener("resize", resize);
resize();
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const dt = Math.min(clock.getDelta(), 0.05);
const time = clock.elapsedTime;
updateCamera(dt);
for (const ripple of ripples) {
const phase = (time * ripple.userData.speed + ripple.userData.phase) % 1;
ripple.scale.x = 0.35 + phase * 1.35;
ripple.material.opacity = Math.sin(phase * Math.PI) * 0.3;
ripple.position.y = 0.145 + Math.sin(time * 1.4 + ripple.userData.phase * 8) * 0.004;
}
updateLabels();
renderer.render(scene, camera);
});
requestAnimationFrame(() => {
document.querySelector("#loading").classList.add("done");
});
</script>
</body>
</html>
```