Prompt specification
Build or customize the Three.js 3D scene "Cooperative orchard harvest morning" 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: Cooperative orchard harvest morning
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/cooperative-orchard-harvest-morning-x1075
Scene Description Prompt:
Build a bounded orchard with pickers, carts, full-crate staging, and shaded sorting table; paths separate stationary work areas from the moving collection route. Build this with Three.js from cdnjs as a voxel scene in one self-contained HTML file.
Working Three.js Starter (cooperative-orchard-harvest-morning-x1075):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sunrise Orchard — Voxel Logistics</title>
<style>
:root {
color-scheme: dark;
--panel: rgba(24, 35, 29, 0.88);
--panel-border: rgba(255, 255, 255, 0.14);
--cream: #f3e7c7;
--muted: #bdc8ba;
--yellow: #f4c84b;
--sand: #c9a96e;
--route: #536b70;
--green: #76a957;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #cbdcc2;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.panel {
position: fixed;
z-index: 10;
color: var(--cream);
background: var(--panel);
border: 1px solid var(--panel-border);
box-shadow: 0 18px 50px rgba(25, 34, 27, 0.18);
backdrop-filter: blur(12px);
}
#info {
top: 18px;
left: 18px;
width: min(330px, calc(100vw - 36px));
padding: 17px 18px 16px;
border-radius: 14px;
pointer-events: none;
}
.eyebrow {
margin-bottom: 5px;
color: var(--yellow);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(22px, 3vw, 31px);
line-height: 1.05;
letter-spacing: -0.035em;
}
.subtitle {
margin: 7px 0 14px;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.legend {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px 12px;
padding-top: 12px;
border-top: 1px solid rgba(255, 255, 255, 0.12);
font-size: 11px;
}
.legend-item {
display: flex;
align-items: center;
gap: 7px;
white-space: nowrap;
}
.swatch {
width: 13px;
height: 13px;
flex: 0 0 auto;
border: 1px solid rgba(255, 255, 255, 0.2);
box-shadow: inset 0 -3px rgba(0, 0, 0, 0.14);
}
.swatch.route { background: var(--route); }
.swatch.work { background: var(--sand); }
.swatch.trees { background: var(--green); }
.swatch.crates { background: #9b643d; }
#controls {
right: 18px;
top: 18px;
display: flex;
gap: 8px;
padding: 8px;
border-radius: 12px;
}
button {
min-height: 36px;
padding: 0 13px;
border: 1px solid rgba(255, 255, 255, 0.14);
border-radius: 8px;
background: rgba(255, 255, 255, 0.09);
color: var(--cream);
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
transition: background 150ms ease, transform 150ms ease;
}
button:hover {
background: rgba(255, 255, 255, 0.17);
transform: translateY(-1px);
}
button:active {
transform: translateY(0);
}
#hint {
position: fixed;
z-index: 10;
left: 50%;
bottom: 17px;
transform: translateX(-50%);
padding: 9px 13px;
border-radius: 999px;
color: var(--cream);
background: rgba(24, 35, 29, 0.76);
border: 1px solid rgba(255, 255, 255, 0.12);
font-size: 11px;
white-space: nowrap;
pointer-events: none;
}
#loading {
position: fixed;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
color: #26352c;
background: #cbdcc2;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
@media (max-width: 650px) {
#info {
top: 10px;
left: 10px;
width: 255px;
padding: 13px;
}
.subtitle {
margin-bottom: 10px;
}
.legend {
gap: 6px;
font-size: 10px;
}
#controls {
top: auto;
right: 10px;
bottom: 48px;
}
#hint {
bottom: 10px;
max-width: calc(100vw - 20px);
overflow: hidden;
text-overflow: ellipsis;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive voxel orchard"></canvas>
<section id="info" class="panel">
<div class="eyebrow">Voxel Logistics</div>
<h1>Sunrise Orchard</h1>
<p class="subtitle">
Pick, stage, sort, and collect within a bounded working block.
</p>
<div class="legend">
<div class="legend-item">
<span class="swatch route"></span>
Moving collection loop
</div>
<div class="legend-item">
<span class="swatch work"></span>
Stationary work areas
</div>
<div class="legend-item">
<span class="swatch trees"></span>
Orchard rows
</div>
<div class="legend-item">
<span class="swatch crates"></span>
Full-crate staging
</div>
</div>
</section>
<nav id="controls" class="panel" aria-label="Scene controls">
<button id="pause" type="button">Pause motion</button>
<button id="reset" type="button">Reset view</button>
</nav>
<div id="hint">
Drag to orbit · Shift-drag to pan · Scroll to zoom · R resets
</div>
<div id="loading">Building orchard…</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 canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xcbdcc2);
scene.fog = new THREE.Fog(0xcbdcc2, 62, 118);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
180
);
const hemi = new THREE.HemisphereLight(0xe9f4df, 0x53603f, 2.0);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff0c4, 3.2);
sun.position.set(-18, 30, 19);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -34;
sun.shadow.camera.right = 34;
sun.shadow.camera.top = 30;
sun.shadow.camera.bottom = -30;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 80;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb9d9ed, 0.55);
fill.position.set(20, 15, -24);
scene.add(fill);
// -------------------------------------------------------------------------
// Shared voxel geometry and materials
// -------------------------------------------------------------------------
const cubeGeometry = new THREE.BoxGeometry(1, 1, 1);
function material(color, extra = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0,
flatShading: true,
...extra
});
}
const M = {
outside: material(0xa7b985),
grass: material(0x739e50),
grassLight: material(0x85ad5d),
grassDark: material(0x587d43),
soil: material(0x76513a),
soilDark: material(0x4e382c),
route: material(0x52676b),
routeEdge: material(0x829293),
sand: material(0xc5a66e),
sandDark: material(0xa88758),
wood: material(0x95613b),
woodLight: material(0xb97d48),
woodDark: material(0x603f2d),
post: material(0x78513a),
cream: material(0xf2e4c2),
yellow: material(0xf2c84a),
yellowDark: material(0xd6a52d),
orange: material(0xe89335),
red: material(0xd94b3d),
redDark: material(0xa82f2b),
green: material(0x4f8745),
greenLight: material(0x69a14d),
greenDark: material(0x35643a),
leafLight: material(0x78a84f),
leafMid: material(0x5d9146),
leafDark: material(0x47763d),
blue: material(0x3e7183),
blueDark: material(0x284e5c),
teal: material(0x4b8177),
rust: material(0xa95e3d),
black: material(0x252a27),
steel: material(0x9ca9a6, { metalness: 0.35, roughness: 0.62 }),
skin: material(0xc98f68),
skinLight: material(0xe0ad7c),
shadow: material(0x314b39)
};
function block(
parent,
mat,
width,
height,
depth,
x,
y,
z,
castShadow = true
) {
const mesh = new THREE.Mesh(cubeGeometry, mat);
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeLabel(text, x, y, z, width = 5, withPost = true) {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 1024;
labelCanvas.height = 128;
const ctx = labelCanvas.getContext("2d");
ctx.clearRect(0, 0, 1024, 128);
ctx.fillStyle = "rgba(31, 45, 36, 0.94)";
ctx.fillRect(0, 0, 1024, 128);
ctx.fillStyle = "#f5e7bf";
ctx.fillRect(12, 12, 1000, 4);
ctx.fillRect(12, 112, 1000, 4);
ctx.font = "800 46px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text.toUpperCase(), 512, 66);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false
})
);
sprite.position.set(x, y, z);
sprite.scale.set(width, width * 0.125, 1);
scene.add(sprite);
if (withPost) {
const postHeight = Math.max(0.5, y - 0.45);
block(scene, M.post, 0.16, postHeight, 0.16, x, postHeight / 2, z);
}
return sprite;
}
// -------------------------------------------------------------------------
// Terrain, orchard boundary, and circulation
// -------------------------------------------------------------------------
block(scene, M.outside, 130, 0.22, 110, 0, -1.06, 0, false);
block(scene, M.soilDark, 48, 1.0, 36, 0, -0.5, 0);
block(scene, M.grass, 47.4, 0.18, 35.4, 0, -0.06, 0, false);
// Light voxel grass patches.
const grassPatches = [
[-19, -7, 3.5, 2.4], [-18, 3, 2.4, 3.4], [-12, -8, 4, 1.5],
[-8, 7.8, 3.5, 1.4], [-3, -8.1, 3, 1.2], [1, 8, 4.2, 1.5],
[7, -8, 3.8, 1.4], [16, -7.5, 3.7, 2.3], [19, 2, 2, 4],
[-5, 8.1, 2.6, 1.2], [11, 7.8, 3.1, 1.4]
];
for (const [x, z, w, d] of grassPatches) {
block(scene, M.grassLight, w, 0.035, d, x, 0.045, z, false);
}
// Dark slate one-way collection loop.
const routeX = 18.7;
const routeZ = 10.7;
const routeWidth = 2.45;
block(scene, M.route, routeX * 2 + routeWidth, 0.12, routeWidth,
0, 0.07, routeZ, false);
block(scene, M.route, routeX * 2 + routeWidth, 0.12, routeWidth,
0, 0.07, -routeZ, false);
block(scene, M.route, routeWidth, 0.12, routeZ * 2,
routeX, 0.07, 0, false);
block(scene, M.route, routeWidth, 0.12, routeZ * 2,
-routeX, 0.07, 0, false);
// Pale curbs visually separate the vehicle loop from foot work areas.
for (const z of [-routeZ + 1.28, routeZ - 1.28]) {
for (let x = -17; x <= 17; x += 3.2) {
block(scene, M.routeEdge, 2.1, 0.07, 0.12, x, 0.155, z, false);
}
}
for (const x of [-routeX + 1.28, routeX - 1.28]) {
for (let z = -8.6; z <= 8.6; z += 3.1) {
block(scene, M.routeEdge, 0.12, 0.07, 2.0, x, 0.155, z, false);
}
}
// Sand-colored pedestrian paths stay inside the row area and never cross
// the moving collection loop.
const pedestrianXs = [-13, -7, -1, 5, 11];
for (const x of pedestrianXs) {
block(scene, M.sand, 1.35, 0.07, 17.2, x, 0.05, 0, false);
}
function groundArrow(x, z, dx, dz) {
const group = new THREE.Group();
group.position.set(x, 0.15, z);
group.rotation.y = -Math.atan2(dz, dx);
block(group, M.yellow, 0.85, 0.035, 0.18, -0.25, 0, 0, false);
block(group, M.yellow, 0.22, 0.035, 0.22, 0.45, 0, 0, false);
block(group, M.yellow, 0.22, 0.035, 0.22, 0.45, 0, 0.22, false);
block(group, M.yellow, 0.22, 0.035, 0.22, 0.45, 0, -0.22, false);
block(group, M.yellow, 0.22, 0.035, 0.22, 0.67, 0, 0, false);
scene.add(group);
}
for (const x of [-13, -5, 3, 11]) {
groundArrow(x, routeZ, 1, 0);
groundArrow(x, -routeZ, -1, 0);
}
for (const z of [-6, 1, 7]) {
groundArrow(routeX, z, 0, -1);
groundArrow(-routeX, z, 0, 1);
}
// -------------------------------------------------------------------------
// Trees and stationary picking pads
// -------------------------------------------------------------------------
const treeXs = [-16, -10, -4, 2, 8, 14];
const treeZs = [-6, 0, 6];
const pickers = [];
function makeTree(x, z, index) {
const group = new THREE.Group();
group.position.set(x, 0, z);
const scale = 0.92 + ((index * 17) % 7) * 0.025;
group.scale.setScalar(scale);
block(group, M.soilDark, 1.8, 0.11, 1.8, 0, 0.06, 0, false);
block(group, M.woodDark, 0.48, 2.8, 0.48, 0, 1.4, 0);
block(group, M.wood, 1.45, 0.28, 0.32, 0.25, 2.25, 0);
block(group, M.wood, 0.32, 0.28, 1.25, 0, 2.55, 0.15);
const leafA = index % 3 === 0 ? M.leafLight : M.leafMid;
const leafB = index % 2 === 0 ? M.leafMid : M.leafDark;
block(group, leafB, 3.5, 1.65, 3.25, 0, 3.35, 0);
block(group, leafA, 2.65, 1.45, 2.55, -0.15, 4.55, 0.05);
block(group, leafA, 2.1, 1.1, 2.15, 0.18, 5.45, -0.05);
block(group, leafB, 1.25, 1.05, 2.6, -1.45, 3.7, 0.15);
block(group, leafB, 1.35, 1.0, 1.8, 1.45, 3.65, -0.15);
block(group, leafA, 1.4, 1.1, 1.5, -0.95, 4.15, 1.0);
const fruitPoints = [
[-1.78, 3.45, 0.35], [-1.45, 4.2, 1.0], [0.2, 5.95, 0.15],
[1.7, 3.65, -0.45], [0.85, 4.4, 1.35], [-0.75, 3.45, -1.7],
[1.15, 3.3, 0.95], [-0.15, 5.2, -1.25]
];
fruitPoints.forEach((p, i) => {
block(
group,
i % 3 === 0 ? M.orange : M.red,
0.25,
0.25,
0.25,
p[0],
p[1],
p[2]
);
});
scene.add(group);
// Each tree has its own stationary picking bay.
block(
scene,
M.sand,
3.15,
0.065,
2.55,
x + 1.05,
0.05,
z + 1.15,
false
);
block(scene, M.sandDark, 3.15, 0.08, 0.1, x + 1.05, 0.075, z + 2.36, false);
block(scene, M.sandDark, 0.1, 0.08, 2.55, x + 2.55, 0.075, z + 1.15, false);
}
let treeIndex = 0;
for (const z of treeZs) {
for (const x of treeXs) {
makeTree(x, z, treeIndex++);
}
}
// -------------------------------------------------------------------------
// Voxel people
// -------------------------------------------------------------------------
function makePerson(shirtMaterial, overallMaterial = M.blue) {
const group = new THREE.Group();
block(group, M.black, 0.28, 0.18, 0.42, -0.18, 0.13, 0.07);
block(group, M.black, 0.28, 0.18, 0.42, 0.18, 0.13, 0.07);
block(group, M.blueDark, 0.24, 0.57, 0.27, -0.18, 0.51, 0);
block(group, M.blueDark, 0.24, 0.57, 0.27, 0.18, 0.51, 0);
block(group, overallMaterial, 0.72, 0.77, 0.44, 0, 1.16, 0);
block(group, shirtMaterial, 0.83, 0.24, 0.49, 0, 1.61, 0);
block(group, M.skin, 0.49, 0.46, 0.44, 0, 1.98, 0.02);
block(group, M.cream, 0.57, 0.14, 0.49, 0, 2.26, 0.02);
block(group, M.cream, 0.7, 0.08, 0.25, 0, 2.2, 0.22);
block(group, M.black, 0.055, 0.055, 0.025, -0.11, 2.0, 0.246);
block(group, M.black, 0.055, 0.055, 0.025, 0.11, 2.0, 0.246);
const armLeft = new THREE.Group();
const armRight = new THREE.Group();
armLeft.position.set(-0.45, 1.48, 0);
armRight.position.set(0.45, 1.48, 0);
group.add(armLeft, armRight);
block(armLeft, shirtMaterial, 0.2, 0.6, 0.24, 0, -0.26, 0);
block(armRight, shirtMaterial, 0.2, 0.6, 0.24, 0, -0.26, 0);
block(armLeft, M.skinLight, 0.21, 0.2, 0.23, 0, -0.63, 0);
block(armRight, M.skinLight, 0.21, 0.2, 0.23, 0, -0.63, 0);
scene.add(group);
return { group, armLeft, armRight };
}
const pickerLocations = [
[-16, -6], [-10, 0], [-4, -6], [2, 0],
[8, -6], [14, 0], [-16, 6], [-4, 6], [8, 6]
];
const shirtColors = [M.blue, M.rust, M.teal, M.blueDark, M.yellowDark];
pickerLocations.forEach(([x, z], i) => {
const person = makePerson(shirtColors[i % shirtColors.length], i % 2 ? M.teal : M.blue);
const px = x + 1.65;
const pz = z + 1.35;
person.group.position.set(px, 0.08, pz);
person.group.rotation.y = Math.atan2(x - px, z - pz);
person.group.scale.setScalar(0.88);
// Picking sack.
block(person.group, M.yellow, 0.37, 0.45, 0.26, 0.43, 0.8, 0.18);
pickers.push({
...person,
phase: i * 0.77
});
});
// -------------------------------------------------------------------------
// Crates and pallets
// -------------------------------------------------------------------------
function makeCrate(parent, x, y, z, scale = 1, full = true) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
block(group, M.wood, 1.55, 0.14, 1.2, 0, 0.07, 0);
block(group, M.woodDark, 1.42, 0.09, 1.08, 0, 0.16, 0);
for (const sx of [-0.715, 0.715]) {
for (const sz of [-0.545, 0.545]) {
block(group, M.woodDark, 0.12, 0.82, 0.12, sx, 0.45, sz);
}
}
for (const yLevel of [0.34, 0.67]) {
block(group, M.woodLight, 1.52, 0.12, 0.1, 0, yLevel, -0.55);
block(group, M.woodLight, 1.52, 0.12, 0.1, 0, yLevel, 0.55);
block(group, M.woodLight, 0.1, 0.12, 1.08, -0.72, yLevel, 0);
block(group, M.woodLight, 0.1, 0.12, 1.08, 0.72, yLevel, 0);
}
if (full) {
const fruit = [
[-0.42, 0.63, -0.27], [0, 0.63, -0.28], [0.42, 0.63, -0.25],
[-0.4, 0.64, 0.18], [0.02, 0.65, 0.2], [0.42, 0.64, 0.18],
[-0.18, 0.88, -0.02], [0.2, 0.89, 0.02]
];
fruit.forEach((p, i) => {
block(
group,
i % 3 === 0 ? M.orange : M.red,
0.26,
0.26,
0.26,
p[0],
p[1],
p[2]
);
});
}
parent.add(group);
return group;
}
function makePallet(x, z, width = 8.8, depth = 3.1) {
block(scene, M.woodDark, width, 0.12, depth, x, 0.12, z);
for (let i = 0; i < 7; i++) {
block(
scene,
M.woodLight,
0.22,
0.09,
depth,
x - width / 2 + 0.35 + i * ((width - 0.7) / 6),
0.225,
z
);
}
}
// -------------------------------------------------------------------------
// Full-crate staging area
// -------------------------------------------------------------------------
block(scene, M.sand, 9.3, 0.1, 3.9, 4.5, 0.055, 14.35, false);
block(scene, M.sandDark, 9.3, 0.12, 0.1, 4.5, 0.08, 16.22, false);
makePallet(4.5, 14.35, 8.8, 3.1);
for (let row = 0; row < 2; row++) {
for (let col = 0; col < 4; col++) {
const x = 1.45 + col * 2.02;
const z = 13.55 + row * 1.48;
makeCrate(scene, x, 0.29, z, 1, true);
if ((row === 0 && (col === 0 || col === 2)) ||
(row === 1 && col === 1)) {
makeCrate(scene, x, 1.22, z, 1, true);
}
}
}
makeLabel("Full-crate staging", 4.5, 3.65, 16.4, 6.4, true);
// A short vehicle transfer bay touches the collection route, while the
// staging pad itself remains a separate stationary work area.
block(scene, M.route, 3.4, 0.12, 1.45, 14.5, 0.07, 12.2, false);
function makeCone(x, z) {
block(scene, M.black, 0.52, 0.1, 0.52, x, 0.19, z);
block(scene, M.orange, 0.35, 0.18, 0.35, x, 0.33, z);
block(scene, M.orange, 0.24, 0.28, 0.24, x, 0.56, z);
block(scene, M.cream, 0.27, 0.08, 0.27, x, 0.5, z);
}
makeCone(12.55, 12.4);
makeCone(16.45, 12.4);
// -------------------------------------------------------------------------
// Shaded sorting table
// -------------------------------------------------------------------------
block(scene, M.sand, 8.9, 0.1, 4.45, 14.55, 0.055, 14.35, false);
// Table.
block(scene, M.woodLight, 6.6, 0.18, 1.75, 14.5, 1.38, 14.15);
for (const x of [11.8, 17.2]) {
for (const z of [13.55, 14.75]) {
block(scene, M.woodDark, 0.22, 1.3, 0.22, x, 0.65, z);
}
}
block(scene, M.wood, 6.1, 0.15, 0.14, 14.5, 0.55, 14.15);
// Three sorting bins with fruit.
makeCrate(scene, 12.15, 1.48, 14.15, 0.64, true);
makeCrate(scene, 14.15, 1.48, 14.15, 0.64, true);
makeCrate(scene, 16.15, 1.48, 14.15, 0.64, true);
// A compact scale and sorting blocks.
block(scene, M.steel, 0.85, 0.18, 0.7, 17.7, 1.56, 14.15);
block(scene, M.black, 0.45, 0.3, 0.45, 17.7, 1.78, 14.15);
block(scene, M.cream, 0.55, 0.08, 0.12, 17.7, 1.98, 14.15);
// Pergola-style voxel canopy: closely spaced slats cast striped shade.
const canopyX = 14.55;
const canopyZ = 14.35;
for (const x of [10.55, 18.55]) {
for (const z of [12.35, 16.35]) {
block(scene, M.woodDark, 0.2, 4.05, 0.2, x, 2.025, z);
}
}
block(scene, M.woodDark, 0.22, 0.24, 4.45, 10.55, 3.98, canopyZ);
block(scene, M.woodDark, 0.22, 0.24, 4.45, 18.55, 3.98, canopyZ);
for (let i = 0; i < 10; i++) {
block(
scene,
i % 3 === 0 ? M.cream : M.sand,
8.45,
0.16,
0.27,
canopyX,
4.17,
12.42 + i * 0.43
);
}
// A wider rear shade panel emphasizes the covered workbench.
block(scene, M.cream, 8.45, 0.13, 0.72, canopyX, 4.24, 16.08);
const sorter = makePerson(M.yellowDark, M.teal);
sorter.group.position.set(13.4, 0.1, 15.65);
sorter.group.rotation.y = Math.PI;
sorter.group.scale.setScalar(0.9);
const tagger = makePerson(M.rust, M.blueDark);
tagger.group.position.set(17.25, 0.1, 13.05);
tagger.group.rotation.y = Math.PI;
tagger.group.scale.setScalar(0.86);
makeLabel("Sort + pack", 14.55, 4.85, 12.15, 5.4, false);
// -------------------------------------------------------------------------
// Voxel carts
// -------------------------------------------------------------------------
function makeCart(bodyMaterial, loaded = true) {
const group = new THREE.Group();
block(group, M.black, 2.8, 0.18, 1.5, 0, 0.72, 0);
block(group, bodyMaterial, 2.85, 0.3, 0.13, 0, 0.93, 0.68);
block(group, bodyMaterial, 2.85, 0.3, 0.13, 0, 0.93, -0.68);
block(group, bodyMaterial, 0.13, 0.3, 1.45, 1.35, 0.93, 0);
block(group, bodyMaterial, 0.13, 0.3, 1.45, -1.35, 0.93, 0);
for (const x of [-0.9, 0.9]) {
for (const z of [-0.82, 0.82]) {
block(group, M.black, 0.48, 0.48, 0.25, x, 0.39, z);
block(group, M.steel, 0.18, 0.18, 0.27, x, 0.39, z);
}
}
// Rear pull handle.
for (const z of [-0.55, 0.55]) {
block(group, M.steel, 0.12, 1.05, 0.12, -1.48, 1.05, z);
}
block(group, M.steel, 0.12, 0.12, 1.22, -1.48, 1.58, 0);
if (loaded) {
makeCrate(group, -0.55, 0.82, 0, 0.78, true);
makeCrate(group, 0.58, 0.82, 0, 0.78, true);
}
scene.add(group);
return group;
}
const movingCarts = [
{ mesh: makeCart(M.blue), phase: 0.02 },
{ mesh: makeCart(M.rust), phase: 0.36 },
{ mesh: makeCart(M.teal), phase: 0.70 }
];
// A parked cart sits within the full-crate work area, not in the loop.
const parkedCart = makeCart(M.blueDark);
parkedCart.position.set(8.65, 0.08, 14.25);
parkedCart.rotation.y = Math.PI / 2;
parkedCart.scale.setScalar(0.82);
// -------------------------------------------------------------------------
// Orchard fence, signs, and background blocks
// -------------------------------------------------------------------------
function fenceX(z, from, to) {
const length = to - from;
block(scene, M.wood, length, 0.12, 0.12, (from + to) / 2, 0.55, z);
block(scene, M.wood, length, 0.12, 0.12, (from + to) / 2, 1.05, z);
for (let x = from; x <= to + 0.01; x += 3.15) {
block(scene, M.post, 0.28, 1.55, 0.28, x, 0.775, z);
block(scene, M.woodLight, 0.34, 0.13, 0.34, x, 1.58, z);
}
}
function fenceZ(x, from, to) {
const length = to - from;
block(scene, M.wood, 0.12, 0.12, length, x, 0.55, (from + to) / 2);
block(scene, M.wood, 0.12, 0.12, length, x, 1.05, (from + to) / 2);
for (let z = from; z <= to + 0.01; z += 3.15) {
block(scene, M.post, 0.28, 1.55, 0.28, x, 0.775, z);
block(scene, M.woodLight, 0.34, 0.13, 0.34, x, 1.58, z);
}
}
fenceX(-17.5, -23.5, 23.5);
fenceX(17.5, -23.5, 23.5);
fenceZ(-23.5, -17.5, 17.5);
fenceZ(23.5, -17.5, 17.5);
makeLabel("Orchard block 07", -10.5, 2.45, 17.45, 5.7, true);
makeLabel("Collection loop", -17.6, 2.5, -9.1, 5.2, true);
// Small distant voxel hills give the bounded plot a larger setting.
block(scene, M.grassDark, 11, 3.4, 7, -14, 0.7, -27);
block(scene, M.grassDark, 15, 4.2, 8, 1, 1.1, -29);
block(scene, M.grassDark, 9, 2.8, 6, 15, 0.4, -27);
block(scene, M.grass, 5, 1.5, 4, -17, 2.3, -28);
block(scene, M.grass, 6, 1.7, 4, 2, 3.0, -30);
// Sparse voxel grass tufts inside the orchard.
const tuftLocations = [
[-20, -4], [-19, 6], [-14, 4], [-13, -3], [-9, -7],
[-7, 3], [-2, -4], [-2, 7], [3, 4], [4, -7],
[8, 3], [10, -3], [16, -6], [18, 5], [19, -1],
[-18, 8], [-11, 8], [0, -8], [6, 8], [17, 8]
];
tuftLocations.forEach(([x, z], i) => {
block(scene, M.grassDark, 0.14, 0.3 + (i % 3) * 0.08, 0.14, x - 0.16, 0.19, z);
block(scene, M.grassLight, 0.14, 0.38, 0.14, x, 0.23, z);
block(scene, M.grassDark, 0.14, 0.25, 0.14, x + 0.17, 0.17, z);
});
// -------------------------------------------------------------------------
// Collection-route animation
// -------------------------------------------------------------------------
const routeLength = (routeX * 2) + (routeZ * 2);
function routeState(fraction) {
let distance = ((fraction % 1) + 1) % 1 * routeLength;
const southLength = routeX * 2;
const sideLength = routeZ * 2;
if (distance < southLength) {
const u = distance / southLength;
return {
x: -routeX + u * southLength,
z: routeZ,
dx: 1,
dz: 0
};
}
distance -= southLength;
if (distance < sideLength) {
const u = distance / sideLength;
return {
x: routeX,
z: routeZ - u * sideLength,
dx: 0,
dz: -1
};
}
distance -= sideLength;
if (distance < southLength) {
const u = distance / southLength;
return {
x: routeX - u * southLength,
z: -routeZ,
dx: -1,
dz: 0
};
}
distance -= southLength;
const u = distance / sideLength;
return {
x: -routeX,
z: -routeZ + u * sideLength,
dx: 0,
dz: 1
};
}
// -------------------------------------------------------------------------
// Custom camera controls — no addons or OrbitControls
// -------------------------------------------------------------------------
const target = new THREE.Vector3(0.6, 0.4, 0.2);
let radius = 57;
let theta = 0.72;
let phi = 0.93;
const defaultView = {
target: target.clone(),
radius,
theta,
phi
};
function applyCamera() {
const sinPhi = Math.sin(phi);
camera.position.set(
target.x + radius * sinPhi * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * sinPhi * Math.cos(theta)
);
camera.lookAt(target);
}
function resetView() {
target.copy(defaultView.target);
radius = defaultView.radius;
theta = defaultView.theta;
phi = defaultView.phi;
applyCamera();
}
const pointers = new Map();
let gesture = null;
function pointerDistance() {
const points = [...pointers.values()];
return Math.hypot(points[0].x - points[1].x, points[0].y - points[1].y);
}
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
gesture = {
type: event.shiftKey || event.button === 2 ? "pan" : "orbit",
lastX: event.clientX,
lastY: event.clientY
};
} else if (pointers.size === 2) {
gesture = {
type: "pinch",
startDistance: pointerDistance(),
startRadius: radius
};
}
});
canvas.addEventListener("pointermove", event => {
if (!pointers.has(event.pointerId)) return;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1 && gesture) {
const dx = event.clientX - gesture.lastX;
const dy = event.clientY - gesture.lastY;
gesture.lastX = event.clientX;
gesture.lastY = event.clientY;
if (gesture.type === "orbit") {
theta -= dx * 0.006;
phi = THREE.MathUtils.clamp(phi - dy * 0.005, 0.32, 1.28);
} else if (gesture.type === "pan") {
const scale = radius * 0.0014;
const rightX = Math.cos(theta);
const rightZ = -Math.sin(theta);
const forwardX = -Math.sin(theta);
const forwardZ = -Math.cos(theta);
target.x -= rightX * dx * scale;
target.z -= rightZ * dx * scale;
target.x += forwardX * dy * scale;
target.z += forwardZ * dy * scale;
}
} else if (pointers.size === 2 && gesture?.type === "pinch") {
const distance = pointerDistance();
radius = THREE.MathUtils.clamp(
gesture.startRadius * gesture.startDistance / Math.max(distance, 1),
28,
90
);
}
applyCamera();
});
function releasePointer(event) {
pointers.delete(event.pointerId);
if (pointers.size === 1) {
const point = [...pointers.values()][0];
gesture = {
type: "orbit",
lastX: point.x,
lastY: point.y
};
} else {
gesture = null;
}
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener("wheel", event => {
event.preventDefault();
radius = THREE.MathUtils.clamp(
radius * Math.exp(event.deltaY * 0.001),
28,
90
);
applyCamera();
}, { passive: false });
window.addEventListener("keydown", event => {
if (event.key === "ArrowLeft") theta += 0.08;
if (event.key === "ArrowRight") theta -= 0.08;
if (event.key === "ArrowUp") phi = Math.max(0.32, phi - 0.06);
if (event.key === "ArrowDown") phi = Math.min(1.28, phi + 0.06);
if (event.key === "+" || event.key === "=") radius = Math.max(28, radius - 2);
if (event.key === "-") radius = Math.min(90, radius + 2);
if (event.key.toLowerCase() === "r") resetView();
applyCamera();
});
document.querySelector("#reset").addEventListener("click", resetView);
let motionPaused = false;
const pauseButton = document.querySelector("#pause");
pauseButton.addEventListener("click", () => {
motionPaused = !motionPaused;
pauseButton.textContent = motionPaused ? "Resume motion" : "Pause motion";
});
// -------------------------------------------------------------------------
// Resize and animation
// -------------------------------------------------------------------------
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();
let elapsed = 0;
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
if (!motionPaused) {
elapsed += dt;
for (const cart of movingCarts) {
const state = routeState(cart.phase + elapsed / 38);
cart.mesh.position.set(state.x, 0.11, state.z);
cart.mesh.rotation.y = -Math.atan2(state.dz, state.dx);
}
for (const picker of pickers) {
const motion = Math.sin(elapsed * 2.2 + picker.phase);
picker.armRight.rotation.x = -0.62 + motion * 0.26;
picker.armLeft.rotation.x = -0.28 - motion * 0.12;
picker.group.position.y = 0.08 + Math.abs(motion) * 0.025;
}
sorter.armRight.rotation.x = -0.95 + Math.sin(elapsed * 2.5) * 0.18;
tagger.armRight.rotation.x = -0.75 + Math.sin(elapsed * 2.1 + 1.2) * 0.15;
}
applyCamera();
renderer.render(scene, camera);
}
applyCamera();
renderer.setAnimationLoop(animate);
requestAnimationFrame(() => {
document.querySelector("#loading").style.display = "none";
});
</script>
</body>
</html>
```