Prompt specification
Build or customize the Three.js 3D scene "Chinampa harvest loading point" 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: Chinampa harvest loading point
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/chinampa-harvest-loading-point-x2294
Scene Description Prompt:
Create a referenced chinampa-inspired planting strip with produce baskets and a canoe loading edge. Animate a short transfer from field path to boat without blocking the canal. Build this with Three.js from cdnjs as a low-poly scene in one self-contained HTML file.
Working Three.js Starter (chinampa-harvest-loading-point-x2294):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chinampa Field-to-Canoe Transfer</title>
<style>
:root {
--ink: #173c39;
--muted: #53716a;
--paper: rgba(248, 244, 225, 0.92);
--line: rgba(23, 60, 57, 0.18);
--accent: #d97932;
--green: #34725b;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #bfd8d7;
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;
}
.panel {
position: fixed;
top: 22px;
left: 22px;
width: min(370px, calc(100vw - 44px));
padding: 19px 20px 17px;
border: 1px solid var(--line);
border-radius: 17px;
background: var(--paper);
box-shadow: 0 18px 50px rgba(24, 55, 52, 0.18);
backdrop-filter: blur(10px);
z-index: 10;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
color: var(--green);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 4px rgba(217, 121, 50, 0.15);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 4vw, 40px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.description {
margin: 12px 0 14px;
color: var(--muted);
font-size: 13px;
line-height: 1.5;
}
.reference {
margin: 0 0 14px;
padding: 10px 11px;
border-left: 3px solid var(--green);
background: rgba(52, 114, 91, 0.08);
color: #46655e;
font-size: 11px;
line-height: 1.45;
}
.status-row {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
margin-bottom: 8px;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#phase {
color: var(--accent);
}
.track {
height: 4px;
overflow: hidden;
border-radius: 999px;
background: rgba(23, 60, 57, 0.12);
}
#progress {
width: 0%;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, var(--green), #8bb36d, var(--accent));
transition: width 80ms linear;
}
.controls {
display: flex;
gap: 9px;
margin-top: 15px;
}
button {
appearance: none;
border: 0;
border-radius: 10px;
padding: 10px 13px;
background: var(--ink);
color: #fffaf0;
font: inherit;
font-size: 12px;
font-weight: 750;
cursor: pointer;
transition:
transform 150ms ease,
background 150ms ease;
}
button:hover {
background: var(--green);
transform: translateY(-1px);
}
button.secondary {
background: rgba(23, 60, 57, 0.09);
color: var(--ink);
}
.hint {
margin-left: auto;
align-self: center;
color: var(--muted);
font-size: 10px;
line-height: 1.25;
text-align: right;
}
.legend {
position: fixed;
right: 20px;
bottom: 20px;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px;
max-width: min(490px, calc(100vw - 40px));
z-index: 10;
}
.chip {
display: inline-flex;
align-items: center;
gap: 7px;
padding: 8px 10px;
border: 1px solid rgba(23, 60, 57, 0.12);
border-radius: 999px;
background: rgba(248, 244, 225, 0.86);
box-shadow: 0 8px 24px rgba(24, 55, 52, 0.1);
color: #3f5d57;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.035em;
backdrop-filter: blur(7px);
}
.dot {
width: 8px;
height: 8px;
border-radius: 50%;
}
.dot.path {
background: #c89e5c;
}
.dot.edge {
background: #805a36;
}
.dot.water {
background: #3d9ca0;
}
@media (max-width: 680px) {
.panel {
top: 12px;
left: 12px;
width: min(340px, calc(100vw - 24px));
padding: 15px;
}
.description,
.reference {
display: none;
}
h1 {
font-size: 27px;
}
.legend {
right: 12px;
bottom: 12px;
}
.hint {
display: none;
}
}
</style>
</head>
<body>
<section class="panel">
<div class="eyebrow">Low-poly waterside study</div>
<h1>Field to canoe</h1>
<p class="description">
A chinampa-inspired raised planting strip borders an open canal.
A produce basket travels from the field path along a narrow timber
loading edge and is handed into a waiting canoe.
</p>
<p class="reference">
Interpretive reference: chinampa-style rectangular wetland beds,
timber retaining frames, intensive crop rows, and canalside exchange.
This is a design study, not an archaeological reconstruction.
</p>
<div class="status-row">
<span id="phase">Field path</span>
<span id="clock">0.0 s</span>
</div>
<div class="track">
<div id="progress"></div>
</div>
<div class="controls">
<button id="replay" type="button">Replay transfer</button>
<button id="resetCamera" class="secondary" type="button">Reset view</button>
<span class="hint">Drag to orbit<br>Scroll to zoom</span>
</div>
</section>
<div class="legend" aria-hidden="true">
<span class="chip"><i class="dot path"></i>Field path</span>
<span class="chip"><i class="dot edge"></i>Bank-side loading edge</span>
<span class="chip"><i class="dot water"></i>Canal remains open</span>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, scene, lighting, and camera
// -------------------------------------------------------------------------
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.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute("aria-label", "Interactive chinampa planting scene");
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xc4dcdb);
scene.fog = new THREE.Fog(0xc4dcdb, 27, 58);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraHome = {
target: new THREE.Vector3(-0.4, 0.1, -2.3),
radius: 25,
theta: 0.56,
phi: 1.02
};
const cameraView = {
target: cameraHome.target.clone(),
radius: cameraHome.radius,
theta: cameraHome.theta,
phi: cameraHome.phi
};
const desiredView = {
radius: cameraHome.radius,
theta: cameraHome.theta,
phi: cameraHome.phi
};
scene.add(new THREE.HemisphereLight(0xd9eff0, 0x536044, 2.05));
const sun = new THREE.DirectionalLight(0xfff0c9, 3.1);
sun.position.set(-10, 17, 11);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 16;
sun.shadow.camera.bottom = -16;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 48;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x91c6d0, 0.7);
fill.position.set(12, 7, -11);
scene.add(fill);
const standard = (color, roughness = 0.86, metalness = 0) =>
new THREE.MeshStandardMaterial({
color,
roughness,
metalness,
flatShading: true
});
const materials = {
ground: standard(0x71805d),
bank: standard(0xa69a6b),
soil: standard(0x4c3827),
path: standard(0xc5a06a),
timber: standard(0x805a37),
timberLight: standard(0xa9794d),
timberDark: standard(0x593a28),
leaf: standard(0x3f7a42),
leafLight: standard(0x65994e),
leafDark: standard(0x28563b),
corn: standard(0x88a94d),
pumpkin: standard(0xd8792d),
tomato: standard(0xc84a34),
basket: standard(0xa87945),
basketDark: standard(0x69452d),
rope: standard(0xb8a071),
skin: standard(0xb87950),
shirt: standard(0x356c65),
pants: standard(0x2e4950),
hat: standard(0xd2b56e),
shoe: standard(0x45372d)
};
const Y_AXIS = new THREE.Vector3(0, 1, 0);
function addMesh(geometry, material, parent = scene) {
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addBox(size, position, material, parent = scene) {
const mesh = addMesh(new THREE.BoxGeometry(...size), material, parent);
mesh.position.set(...position);
return mesh;
}
function beamBetween(a, b, radius, material, parent = scene, sides = 6) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const midpoint = start.clone().add(end).multiplyScalar(0.5);
const mesh = addMesh(
new THREE.CylinderGeometry(radius, radius, direction.length(), sides),
material,
parent
);
mesh.position.copy(midpoint);
mesh.quaternion.setFromUnitVectors(Y_AXIS, direction.normalize());
return mesh;
}
let randomSeed = 83127;
function random() {
randomSeed = (randomSeed * 16807) % 2147483647;
return (randomSeed - 1) / 2147483646;
}
// -------------------------------------------------------------------------
// Canal, banks, and chinampa-inspired raised bed
// -------------------------------------------------------------------------
addBox([44, 0.5, 44], [0, -0.96, 0], materials.ground);
addBox([34, 0.5, 9.5], [0, -0.32, -5.05], materials.bank);
addBox([34, 0.5, 6], [0, -0.32, 10.15], materials.bank);
addBox([5, 0.5, 7.4], [-16.2, -0.32, 3.45], materials.bank);
addBox([5, 0.5, 7.4], [16.2, -0.32, 3.45], materials.bank);
const waterGeometry = new THREE.PlaneGeometry(34, 7.4, 34, 9);
waterGeometry.rotateX(-Math.PI / 2);
const waterMaterial = new THREE.MeshStandardMaterial({
color: 0x4a9ea0,
roughness: 0.28,
metalness: 0.08,
transparent: true,
opacity: 0.88,
flatShading: true
});
const water = new THREE.Mesh(waterGeometry, waterMaterial);
water.position.set(0, -0.43, 3.45);
water.receiveShadow = true;
scene.add(water);
const waterPositions = waterGeometry.attributes.position;
const waterBase = [];
for (let i = 0; i < waterPositions.count; i++) {
waterBase.push({
x: waterPositions.getX(i),
z: waterPositions.getZ(i)
});
}
// Main rectangular raised planting bed.
addBox([16.2, 0.65, 5.6], [-1, -0.15, -4.35], materials.soil);
// Timber retaining frame.
addBox([16.55, 0.31, 0.2], [-1, 0.13, -1.58], materials.timberDark);
addBox([16.55, 0.31, 0.2], [-1, 0.13, -7.12], materials.timberDark);
addBox([0.2, 0.31, 5.72], [-9.05, 0.13, -4.35], materials.timberDark);
addBox([0.2, 0.31, 5.72], [7.05, 0.13, -4.35], materials.timberDark);
for (let x = -8.8; x <= 7.1; x += 2.1) {
addBox([0.18, 0.92, 0.18], [x, 0.3, -1.6], materials.timber);
addBox([0.18, 0.78, 0.18], [x, 0.23, -7.12], materials.timber);
}
// Field path from the rear of the plot to the loading edge.
addBox([1.35, 0.12, 5.95], [-4.6, 0.22, -4.18], materials.path);
// Narrow bank-side timber edge; it stops before the open water.
addBox([13.4, 0.15, 0.72], [0.35, 0.17, -1.1], materials.timber);
for (let x = -6.2; x <= 6.7; x += 0.52) {
addBox([0.45, 0.11, 0.72], [x, 0.28, -1.1], materials.timberLight);
}
// Small landing at the end of the edge, still entirely on the bank.
addBox([1.45, 0.16, 0.88], [0.85, 0.18, -0.8], materials.timberDark);
for (let x = 0.3; x <= 1.4; x += 0.36) {
addBox([0.3, 0.1, 0.86], [x, 0.28, -0.8], materials.timberLight);
}
// Subtle route inlays identify the short transfer lane.
const routeInlayMaterial = standard(0xd5b875);
for (let x = -3.8; x <= 2.1; x += 0.9) {
addBox([0.42, 0.018, 0.055], [x, 0.345, -1.08], routeInlayMaterial);
}
// Short irrigation channels within the bed.
const irrigationMaterial = standard(0x477f7a, 0.48, 0.03);
addBox([3.7, 0.025, 0.17], [-7.05, 0.19, -5.35], irrigationMaterial);
addBox([9.4, 0.025, 0.17], [1.3, 0.19, -5.35], irrigationMaterial);
addBox([3.7, 0.025, 0.17], [-7.05, 0.19, -3.55], irrigationMaterial);
addBox([9.4, 0.025, 0.17], [1.3, 0.19, -3.55], irrigationMaterial);
// -------------------------------------------------------------------------
// Crops
// -------------------------------------------------------------------------
function addMaize(x, z) {
const group = new THREE.Group();
group.position.set(x, 0.2, z);
scene.add(group);
const stalk = addMesh(
new THREE.CylinderGeometry(0.035, 0.055, 0.78, 5),
materials.corn,
group
);
stalk.position.y = 0.39;
for (let i = 0; i < 4; i++) {
const leaf = addMesh(
new THREE.ConeGeometry(0.16, 0.54, 3),
i % 2 ? materials.leaf : materials.leafLight,
group
);
leaf.position.set(0, 0.23 + i * 0.13, 0);
leaf.rotation.z = (i % 2 ? 1 : -1) * 0.72;
leaf.rotation.y = i * 1.6;
}
const cob = addMesh(
new THREE.CylinderGeometry(0.065, 0.045, 0.2, 6),
materials.pumpkin,
group
);
cob.position.set(0.07, 0.57, 0.04);
cob.rotation.z = -0.35;
}
function addSquash(x, z) {
const group = new THREE.Group();
group.position.set(x, 0.2, z);
scene.add(group);
for (let i = 0; i < 5; i++) {
const leaf = addMesh(
new THREE.IcosahedronGeometry(0.29, 0),
i % 2 ? materials.leaf : materials.leafLight,
group
);
leaf.scale.set(1.25, 0.32, 0.9);
leaf.position.set(
Math.cos(i * 1.25) * 0.22,
0.1 + (i % 2) * 0.045,
Math.sin(i * 1.25) * 0.22
);
leaf.rotation.y = i;
}
const fruit = addMesh(
new THREE.IcosahedronGeometry(0.24, 1),
materials.pumpkin,
group
);
fruit.scale.set(1.2, 0.83, 1);
fruit.position.y = 0.15;
}
function addTomato(x, z) {
const group = new THREE.Group();
group.position.set(x, 0.2, z);
scene.add(group);
const stem = addMesh(
new THREE.CylinderGeometry(0.035, 0.05, 0.64, 5),
materials.leafDark,
group
);
stem.position.y = 0.32;
const crown = addMesh(
new THREE.IcosahedronGeometry(0.36, 0),
materials.leaf,
group
);
crown.scale.set(1, 0.9, 1);
crown.position.y = 0.67;
for (let i = 0; i < 4; i++) {
const tomato = addMesh(
new THREE.IcosahedronGeometry(0.09, 0),
materials.tomato,
group
);
tomato.position.set(
Math.cos(i * 1.7) * 0.25,
0.42 + (i % 2) * 0.18,
Math.sin(i * 1.7) * 0.24
);
}
}
function addCabbage(x, z) {
const group = new THREE.Group();
group.position.set(x, 0.2, z);
scene.add(group);
for (let i = 0; i < 6; i++) {
const leaf = addMesh(
new THREE.IcosahedronGeometry(0.2, 0),
i % 2 ? materials.leafLight : materials.leaf,
group
);
leaf.scale.set(0.7, 0.55, 1.2);
leaf.position.set(
Math.cos(i * 1.05) * 0.15,
0.1 + (i % 2) * 0.035,
Math.sin(i * 1.05) * 0.15
);
leaf.rotation.y = i * 1.05;
}
}
const cropRows = [-6.35, -4.75, -2.95, -2.05];
const cropColumns = [-8.0, -6.9, -3.1, -1.7, -0.3, 1.1, 2.5, 3.9, 5.3, 6.5];
cropRows.forEach((z, rowIndex) => {
cropColumns.forEach((x, columnIndex) => {
const offset = (rowIndex % 2) * 0.18;
const px = x + offset;
const kind = (rowIndex + columnIndex) % 4;
if (kind === 0) addMaize(px, z);
else if (kind === 1) addSquash(px, z);
else if (kind === 2) addTomato(px, z);
else addCabbage(px, z);
});
});
// -------------------------------------------------------------------------
// Woven produce baskets
// -------------------------------------------------------------------------
function createBasket(fill = true) {
const group = new THREE.Group();
const body = addMesh(
new THREE.CylinderGeometry(0.44, 0.33, 0.43, 10, 1, true),
materials.basket,
group
);
body.material.side = THREE.DoubleSide;
body.position.y = 0.215;
for (const y of [0.045, 0.22, 0.405]) {
const ring = addMesh(
new THREE.TorusGeometry(0.4, 0.032, 4, 10),
materials.basketDark,
group
);
ring.rotation.x = Math.PI / 2;
ring.position.y = y;
ring.scale.setScalar(y < 0.1 ? 0.84 : y < 0.3 ? 0.94 : 1.02);
}
for (let i = 0; i < 10; i++) {
const angle = (i / 10) * Math.PI * 2;
const slat = addBox(
[0.045, 0.42, 0.055],
[Math.cos(angle) * 0.385, 0.215, Math.sin(angle) * 0.385],
materials.basketDark,
group
);
slat.rotation.y = -angle;
slat.rotation.z = Math.cos(angle) * 0.08;
}
if (fill) {
const produceColors = [0xd96536, 0xddb142, 0x6f963e, 0xc84835];
for (let i = 0; i < 9; i++) {
const angle = i * 2.25;
const radius = i < 5 ? 0.12 : 0.24;
const vegetable = addMesh(
new THREE.IcosahedronGeometry(i % 3 === 0 ? 0.115 : 0.09, 0),
standard(produceColors[i % produceColors.length]),
group
);
vegetable.position.set(
Math.cos(angle) * radius,
0.38 + random() * 0.045,
Math.sin(angle) * radius
);
vegetable.scale.y = 0.8 + random() * 0.35;
}
}
return group;
}
const basketA = createBasket(true);
basketA.position.set(-6.1, 0.22, -3.05);
basketA.rotation.y = 0.18;
scene.add(basketA);
const basketB = createBasket(false);
basketB.position.set(-3.05, 0.22, -5.8);
basketB.rotation.y = -0.2;
scene.add(basketB);
// -------------------------------------------------------------------------
// Low-poly canoe
// -------------------------------------------------------------------------
function createCanoe() {
const group = new THREE.Group();
group.position.set(3.2, 0, 0.15);
const sections = [
{ x: -3.2, w: 0.035 },
{ x: -2.55, w: 0.48 },
{ x: -1.25, w: 0.69 },
{ x: 0.9, w: 0.7 },
{ x: 2.35, w: 0.46 },
{ x: 3.2, w: 0.035 }
];
const vertices = [];
const indices = [];
for (const section of sections) {
const w = section.w;
vertices.push(
section.x, 0.1, -w, // port gunwale
section.x, 0.1, w, // starboard gunwale
section.x, -0.43, -w * 0.38,
section.x, -0.43, w * 0.38
);
}
for (let i = 0; i < sections.length - 1; i++) {
const a = i * 4;
const b = (i + 1) * 4;
// Port side.
indices.push(a, a + 2, b, a, b, b + 2);
// Starboard side.
indices.push(a + 1, b + 1, a + 3, a + 3, b + 1, b + 3);
// Bottom.
indices.push(a + 2, a + 3, b + 2, a + 3, b + 3, b + 2);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(vertices, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
const hull = addMesh(geometry, materials.timberDark, group);
hull.material.side = THREE.DoubleSide;
// Gunwale rails.
for (const side of [-1, 1]) {
for (let i = 0; i < sections.length - 1; i++) {
const a = sections[i];
const b = sections[i + 1];
beamBetween(
[a.x, 0.12, side * a.w],
[b.x, 0.12, side * b.w],
0.045,
materials.timberLight,
group,
6
);
}
}
// Cross-canoe seats.
addBox([0.32, 0.12, 1.04], [-1.25, 0.02, 0], materials.timberLight, group);
addBox([0.32, 0.12, 1.05], [1.05, 0.02, 0], materials.timberLight, group);
// A paddle resting across the canoe.
const paddle = new THREE.Group();
group.add(paddle);
beamBetween(
[-0.9, 0.13, -0.36],
[2.65, 0.13, -0.36],
0.035,
materials.timberLight,
paddle,
6
);
const blade = addBox(
[0.78, 0.055, 0.27],
[2.86, 0.13, -0.36],
materials.timber,
paddle
);
blade.rotation.y = -0.08;
const cargoBasket = createBasket(true);
cargoBasket.position.set(0.85, -0.28, 0);
cargoBasket.scale.setScalar(0.8);
group.add(cargoBasket);
scene.add(group);
return group;
}
const canoe = createCanoe();
// Rope from the canoe to a bank bollard, kept along the bank.
const ropeCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(6.2, 0.12, 0.16),
new THREE.Vector3(6.55, 0.02, -0.25),
new THREE.Vector3(6.75, 0.42, -0.64)
]);
const rope = addMesh(
new THREE.TubeGeometry(ropeCurve, 16, 0.018, 5, false),
materials.rope
);
function addBollard(x, z) {
addBox([0.22, 0.11, 0.22], [x, 0.28, z], materials.timberDark);
const post = addMesh(
new THREE.CylinderGeometry(0.085, 0.11, 0.48, 7),
materials.timber,
scene
);
post.position.set(x, 0.48, z);
const cap = addMesh(
new THREE.CylinderGeometry(0.12, 0.09, 0.08, 7),
materials.timberLight,
scene
);
cap.position.set(x, 0.73, z);
}
[-5.5, -2.4, 2.4, 6.75].forEach((x) => addBollard(x, -0.67));
// -------------------------------------------------------------------------
// Bank vegetation, trees, and small canal details
// -------------------------------------------------------------------------
function addTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.scale.setScalar(scale);
scene.add(group);
const trunk = addMesh(
new THREE.CylinderGeometry(0.16, 0.25, 2.25, 6),
materials.timberDark,
group
);
trunk.position.y = 1.05;
const crown = addMesh(
new THREE.IcosahedronGeometry(1.18, 0),
materials.leafDark,
group
);
crown.position.y = 2.45;
crown.scale.set(1.1, 1.15, 0.95);
const crownLight = addMesh(
new THREE.IcosahedronGeometry(0.72, 0),
materials.leaf,
group
);
crownLight.position.set(0.48, 2.85, 0.18);
}
addTree(-10.5, -8.7, 1.15);
addTree(-5.7, -9.4, 0.85);
addTree(6.7, -9.2, 1.05);
addTree(11.2, -8.1, 0.85);
function addReed(x, z) {
const height = 0.45 + random() * 0.4;
const reed = addMesh(
new THREE.CylinderGeometry(0.018, 0.025, height, 4),
materials.leafDark
);
reed.position.set(x, -0.05 + height / 2, z);
reed.rotation.z = (random() - 0.5) * 0.2;
}
for (let i = 0; i < 38; i++) {
addReed(
-14 + random() * 28,
-0.31 + random() * 0.12
);
}
// A few floating leaves emphasize that the center of the canal is open.
const lilyMaterial = standard(0x4f8050);
for (const [x, z] of [
[-8.7, 3.9],
[-5.9, 5.8],
[8.8, 4.9],
[10.7, 2.2]
]) {
const leaf = addMesh(
new THREE.CylinderGeometry(0.16, 0.16, 0.018, 7),
lilyMaterial
);
leaf.position.set(x, -0.395, z);
leaf.scale.z = 0.72;
}
// -------------------------------------------------------------------------
// Field sign made from a canvas texture; no external image assets
// -------------------------------------------------------------------------
function makeSign(text) {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 160;
const context = canvas.getContext("2d");
context.fillStyle = "#805a37";
context.fillRect(0, 0, canvas.width, canvas.height);
context.strokeStyle = "#ba8a56";
context.lineWidth = 8;
context.strokeRect(10, 10, canvas.width - 20, canvas.height - 20);
context.fillStyle = "#fff4d4";
context.font = "bold 54px Georgia";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, canvas.width / 2, canvas.height / 2 + 3);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const label = new THREE.Mesh(
new THREE.PlaneGeometry(3.25, 0.81),
new THREE.MeshBasicMaterial({ map: texture })
);
label.position.set(-7.15, 1.08, -1.42);
scene.add(label);
addBox([0.12, 1.05, 0.12], [-8.3, 0.45, -1.45], materials.timberDark);
addBox([0.12, 1.05, 0.12], [-6.0, 0.45, -1.45], materials.timberDark);
}
makeSign("CHINAMPA PLOT");
// -------------------------------------------------------------------------
// Worker and carried produce basket
// -------------------------------------------------------------------------
function createWorker() {
const group = new THREE.Group();
const torso = addBox(
[0.34, 0.62, 0.5],
[0, 0.94, 0],
materials.shirt,
group
);
torso.rotation.z = -0.03;
addBox([0.31, 0.18, 0.48], [0.01, 0.59, 0], materials.pants, group);
const head = addMesh(
new THREE.IcosahedronGeometry(0.23, 1),
materials.skin,
group
);
head.position.set(0.015, 1.46, 0);
head.scale.set(0.88, 1.05, 0.92);
const hatBrim = addMesh(
new THREE.CylinderGeometry(0.34, 0.34, 0.055, 10),
materials.hat,
group
);
hatBrim.position.set(0.01, 1.64, 0);
const hatTop = addMesh(
new THREE.CylinderGeometry(0.2, 0.24, 0.2, 9),
materials.hat,
group
);
hatTop.position.set(0.01, 1.75, 0);
const leftLeg = new THREE.Group();
const rightLeg = new THREE.Group();
leftLeg.position.set(0, 0.52, 0.14);
rightLeg.position.set(0, 0.52, -0.14);
group.add(leftLeg, rightLeg);
for (const leg of [leftLeg, rightLeg]) {
addBox([0.16, 0.45, 0.17], [0, -0.22, 0], materials.pants, leg);
addBox(
[0.25, 0.11, 0.18],
[0.055, -0.46, 0],
materials.shoe,
leg
);
}
// Arms reach toward local +X, the worker's forward direction.
beamBetween(
[0.02, 1.15, 0.27],
[0.43, 0.88, 0.27],
0.075,
materials.shirt,
group,
6
);
beamBetween(
[0.02, 1.15, -0.27],
[0.43, 0.88, -0.27],
0.075,
materials.shirt,
group,
6
);
const handA = addMesh(
new THREE.IcosahedronGeometry(0.085, 0),
materials.skin,
group
);
handA.position.set(0.45, 0.87, 0.27);
const handB = addMesh(
new THREE.IcosahedronGeometry(0.085, 0),
materials.skin,
group
);
handB.position.set(0.45, 0.87, -0.27);
scene.add(group);
return { group, leftLeg, rightLeg };
}
const worker = createWorker();
const carriedBasket = createBasket(true);
scene.add(carriedBasket);
// -------------------------------------------------------------------------
// Transfer animation
// -------------------------------------------------------------------------
const route = [
new THREE.Vector3(-4.6, 0.28, -3.05),
new THREE.Vector3(-4.6, 0.28, -1.1),
new THREE.Vector3(0.25, 0.28, -1.1),
new THREE.Vector3(0.85, 0.28, -0.55)
];
const durations = {
field: 2.2,
edge: 4.5,
turn: 0.9,
handoff: 1.65
};
const animationDuration =
durations.field + durations.edge + durations.turn + durations.handoff;
const handoffStart = new THREE.Vector3();
const carryPosition = new THREE.Vector3();
const basketTarget = new THREE.Vector3();
const temp = new THREE.Vector3();
let animationStart = 0;
let handoffCaptured = false;
let basketAttached = false;
let elapsed = 0;
function smoothstep(value) {
const t = THREE.MathUtils.clamp(value, 0, 1);
return t * t * (3 - 2 * t);
}
function updateTransfer(time) {
const t = time - animationStart;
const progress = THREE.MathUtils.clamp(t / animationDuration, 0, 1);
document.getElementById("progress").style.width = `${progress * 100}%`;
document.getElementById("clock").textContent = `${t.toFixed(1)} s`;
let walking = false;
let phaseText = "Field path";
if (t < durations.field) {
const u = smoothstep(t / durations.field);
worker.group.position.lerpVectors(route[0], route[1], u);
worker.group.rotation.y = -Math.PI / 2;
walking = true;
} else if (t < durations.field + durations.edge) {
const u = smoothstep(
(t - durations.field) / durations.edge
);
worker.group.position.lerpVectors(route[1], route[2], u);
worker.group.rotation.y = 0;
walking = true;
phaseText = "Loading edge";
} else if (t < durations.field + durations.edge + durations.turn) {
const u = smoothstep(
(t - durations.field - durations.edge) / durations.turn
);
worker.group.position.lerpVectors(route[2], route[3], u);
worker.group.rotation.y = THREE.MathUtils.lerp(0, -Math.PI / 2, u);
walking = true;
phaseText = "Loading edge";
} else if (t < animationDuration) {
const u = smoothstep(
(t - durations.field - durations.edge - durations.turn) /
durations.handoff
);
worker.group.position.copy(route[3]);
worker.group.rotation.y = -Math.PI / 2;
phaseText = u < 0.18 ? "Handoff" : "Securing basket";
if (!handoffCaptured) {
handoffStart.copy(carriedBasket.position);
handoffCaptured = true;
}
basketTarget.set(-2.35, -0.16, 0);
canoe.localToWorld(basketTarget);
carriedBasket.position.lerpVectors(handoffStart, basketTarget, u);
carriedBasket.position.y += Math.sin(u * Math.PI) * 0.48;
carriedBasket.rotation.y = THREE.MathUtils.lerp(
-Math.PI / 2,
0,
u
);
if (u >= 0.999 && !basketAttached) {
carriedBasket.position.copy(basketTarget);
canoe.attach(carriedBasket);
basketAttached = true;
phaseText = "Basket secured";
}
} else {
worker.group.position.copy(route[3]);
worker.group.rotation.y = -Math.PI / 2;
phaseText = "Basket secured";
}
if (!basketAttached) {
const forward = new THREE.Vector3(1, 0, 0)
.applyAxisAngle(Y_AXIS, worker.group.rotation.y);
carryPosition
.copy(worker.group.position)
.addScaledVector(forward, 0.49);
carryPosition.y += 0.55;
if (t < durations.field + durations.edge + durations.turn) {
carriedBasket.position.copy(carryPosition);
carriedBasket.rotation.y = worker.group.rotation.y;
}
}
const swing = walking ? Math.sin((time - animationStart) * 10) * 0.48 : 0;
worker.leftLeg.rotation.x = swing;
worker.rightLeg.rotation.x = -swing;
if (phaseText !== document.getElementById("phase").textContent) {
document.getElementById("phase").textContent = phaseText;
}
}
// -------------------------------------------------------------------------
// Direct camera controls: no OrbitControls or 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.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
desiredView.theta -= deltaX * 0.006;
desiredView.phi = THREE.MathUtils.clamp(
desiredView.phi - deltaY * 0.005,
0.38,
1.36
);
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredView.radius = THREE.MathUtils.clamp(
desiredView.radius + event.deltaY * 0.012,
12,
39
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
desiredView.radius = cameraHome.radius;
desiredView.theta = cameraHome.theta;
desiredView.phi = cameraHome.phi;
cameraView.target.copy(cameraHome.target);
});
function resetCamera() {
desiredView.radius = cameraHome.radius;
desiredView.theta = cameraHome.theta;
desiredView.phi = cameraHome.phi;
cameraView.target.copy(cameraHome.target);
}
document.getElementById("resetCamera").addEventListener(
"click",
resetCamera
);
function replayTransfer() {
if (carriedBasket.parent !== scene) {
scene.attach(carriedBasket);
}
carriedBasket.visible = true;
carriedBasket.position.copy(route[0]);
carriedBasket.position.x += 0.49;
carriedBasket.position.y += 0.55;
carriedBasket.rotation.set(0, -Math.PI / 2, 0);
worker.group.position.copy(route[0]);
worker.group.rotation.y = -Math.PI / 2;
worker.leftLeg.rotation.x = 0;
worker.rightLeg.rotation.x = 0;
animationStart = elapsed;
handoffCaptured = false;
basketAttached = false;
}
document.getElementById("replay").addEventListener(
"click",
replayTransfer
);
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
elapsed = clock.getElapsedTime();
// Gentle low-poly water motion.
for (let i = 0; i < waterPositions.count; i++) {
const base = waterBase[i];
const wave =
Math.sin(base.x * 0.72 + elapsed * 0.85) * 0.022 +
Math.sin(base.z * 1.18 - elapsed * 0.58) * 0.012;
waterPositions.setY(i, wave);
}
waterPositions.needsUpdate = true;
waterGeometry.computeVertexNormals();
// The canoe rocks subtly while the basket rides inside it.
canoe.position.y = Math.sin(elapsed * 0.82) * 0.025;
canoe.rotation.z = Math.sin(elapsed * 0.63) * 0.008;
updateTransfer(elapsed);
// Smooth camera orbit.
cameraView.radius +=
(desiredView.radius - cameraView.radius) * 0.08;
cameraView.theta +=
(desiredView.theta - cameraView.theta) * 0.08;
cameraView.phi +=
(desiredView.phi - cameraView.phi) * 0.08;
const sinPhi = Math.sin(cameraView.phi);
camera.position.set(
cameraView.target.x +
cameraView.radius * sinPhi * Math.sin(cameraView.theta),
cameraView.target.y + cameraView.radius * Math.cos(cameraView.phi),
cameraView.target.z +
cameraView.radius * sinPhi * Math.cos(cameraView.theta)
);
camera.lookAt(cameraView.target);
renderer.render(scene, camera);
}
replayTransfer();
animate();
</script>
</body>
</html>
```