Prompt specification
Build or customize the Three.js 3D scene "Camp packing before a seasonal move" 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: Camp packing before a seasonal move
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/camp-packing-before-a-seasonal-move-x2626
Scene Description Prompt:
Please use Three.js from cdnjs for a voxel scene based on this idea: Camp packing before a seasonal move. Create a historically informed pastoral camp vignette with household packing, herd gathering, and a clear departure route. Keep people and animals represented respectfully as coordinated participants. Return one self-contained HTML file.
Working Three.js Starter (camp-packing-before-a-seasonal-move-x2626):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Camp Before the Seasonal Move</title>
<style>
:root {
--ink: #263129;
--paper: #efe6d1;
--paper-soft: rgba(239, 230, 209, 0.92);
--ochre: #b66f3d;
--moss: #59664a;
--line: rgba(38, 49, 41, 0.22);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b9c5b8;
color: var(--ink);
font-family: Georgia, "Times New Roman", serif;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene canvas:active { cursor: grabbing; }
.panel {
position: fixed;
z-index: 5;
background: var(--paper-soft);
border: 1px solid var(--line);
box-shadow: 0 12px 36px rgba(37, 43, 34, 0.12);
backdrop-filter: blur(8px);
}
header {
top: 22px;
left: 22px;
width: min(440px, calc(100vw - 44px));
padding: 18px 20px 17px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
font: 700 10px/1.2 Arial, sans-serif;
letter-spacing: 0.18em;
text-transform: uppercase;
color: var(--ochre);
}
.eyebrow::before {
content: "";
width: 24px;
height: 2px;
background: var(--ochre);
}
h1 {
margin: 0;
max-width: 390px;
font-size: clamp(25px, 3vw, 39px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
margin: 11px 0 0;
max-width: 370px;
font: 12px/1.55 Arial, sans-serif;
color: rgba(38, 49, 41, 0.72);
}
.route-badge {
top: 22px;
right: 22px;
padding: 12px 15px;
display: flex;
align-items: center;
gap: 10px;
font: 700 10px/1 Arial, sans-serif;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.route-badge .arrow {
color: var(--ochre);
font-size: 18px;
line-height: 0;
}
.story {
left: 22px;
bottom: 22px;
width: min(610px, calc(100vw - 44px));
padding: 16px 18px;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0;
}
.story-item {
min-width: 0;
padding: 0 16px;
border-left: 1px solid var(--line);
}
.story-item:first-child {
padding-left: 0;
border-left: 0;
}
.story-item:last-child { padding-right: 0; }
.story-index {
display: block;
margin-bottom: 6px;
color: var(--ochre);
font: 700 9px/1 Arial, sans-serif;
letter-spacing: 0.18em;
}
.story strong {
display: block;
margin-bottom: 4px;
font: 700 11px/1.2 Arial, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.story p {
margin: 0;
font-size: 12px;
line-height: 1.38;
color: rgba(38, 49, 41, 0.7);
}
.controls-panel {
right: 22px;
bottom: 22px;
width: 260px;
padding: 14px;
}
.controls {
display: flex;
gap: 7px;
margin-bottom: 12px;
}
button {
flex: 1;
padding: 9px 10px;
border: 1px solid rgba(38, 49, 41, 0.35);
background: transparent;
color: var(--ink);
font: 700 9px/1 Arial, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
}
button:hover {
background: var(--ink);
color: var(--paper);
}
.note {
margin: 0;
padding-top: 11px;
border-top: 1px solid var(--line);
font: 10px/1.48 Arial, sans-serif;
color: rgba(38, 49, 41, 0.68);
}
.note strong {
color: var(--ink);
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #b9c5b8;
color: var(--ink);
font: 700 11px/1 Arial, sans-serif;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 400ms ease;
}
#loading.hidden { opacity: 0; pointer-events: none; }
@media (max-width: 900px) {
.controls-panel {
width: 225px;
bottom: 150px;
}
.note { display: none; }
}
@media (max-width: 650px) {
header {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 14px 15px;
}
h1 { max-width: 280px; font-size: 27px; }
.subtitle { display: none; }
.route-badge {
top: 128px;
right: 12px;
padding: 9px 11px;
}
.story {
left: 12px;
bottom: 12px;
width: calc(100vw - 24px);
padding: 13px;
grid-template-columns: 1fr;
gap: 9px;
}
.story-item,
.story-item:first-child,
.story-item:last-child {
padding: 0 0 8px;
border: 0;
border-bottom: 1px solid var(--line);
}
.story-item:last-child {
border-bottom: 0;
padding-bottom: 0;
}
.story p { display: none; }
.controls-panel {
right: 12px;
bottom: 196px;
width: 205px;
padding: 9px;
}
.controls { margin: 0; }
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive voxel pastoral camp with household packing, a gathering flock, and a marked route to high pasture"></div>
<div id="loading">Preparing the camp…</div>
<header class="panel">
<div class="eyebrow">Voxel field study · Seasonal move</div>
<h1>Camp before the turning season</h1>
<p class="subtitle">
A historically informed pastoral camp: bedding is rolled, possessions are secured,
the flock gathers, and an ochre trail leads toward the upper pasture.
</p>
</header>
<div class="route-badge panel">
<span class="arrow">→</span>
<span>Departure route · Upper pasture</span>
</div>
<section class="story panel" aria-label="Scene key">
<div class="story-item">
<span class="story-index">01</span>
<strong>Household</strong>
<p>Trunks, bedrolls, cookware, and a loaded handcart are packed together.</p>
</div>
<div class="story-item">
<span class="story-index">02</span>
<strong>Herd</strong>
<p>The sheep regroup at the route mouth while the herder guides their pace.</p>
</div>
<div class="story-item">
<span class="story-index">03</span>
<strong>Departure</strong>
<p>Stones, painted waymarks, and cairns make the seasonal trail legible.</p>
</div>
</section>
<aside class="controls-panel panel">
<div class="controls">
<button id="reset-view" type="button">Reset view</button>
<button id="route-view" type="button">Follow route</button>
</div>
<p class="note">
<strong>Historical note:</strong> This is an informed vignette, not a reconstruction
of one named community. Tents, clothing, carts, and herding methods evoke
late-19th-century upland pastoral life but varied widely by region and household.
Drag to orbit; scroll to zoom.
</p>
</aside>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const container = document.getElementById("scene");
const loading = document.getElementById("loading");
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
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;
renderer.domElement.setAttribute("aria-label", "Voxel pastoral camp scene");
container.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xb8c6b9);
scene.fog = new THREE.Fog(0xb8c6b9, 27, 68);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
120
);
const hemi = new THREE.HemisphereLight(0xf6edd3, 0x61705b, 2.05);
scene.add(hemi);
const sunLight = new THREE.DirectionalLight(0xffe5ad, 3.25);
sunLight.position.set(11, 19, 12);
sunLight.castShadow = true;
sunLight.shadow.mapSize.set(2048, 2048);
sunLight.shadow.camera.left = -22;
sunLight.shadow.camera.right = 22;
sunLight.shadow.camera.top = 20;
sunLight.shadow.camera.bottom = -20;
sunLight.shadow.camera.near = 1;
sunLight.shadow.camera.far = 55;
sunLight.shadow.bias = -0.00035;
sunLight.shadow.normalBias = 0.025;
scene.add(sunLight);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function material(color) {
if (color && color.isMaterial) return color;
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.96,
metalness: 0
})
);
}
return materialCache.get(color);
}
function box(parent, size, position, color, rotation = [0, 0, 0], castShadow = true) {
const mesh = new THREE.Mesh(unitBox, material(color));
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.rotation.set(rotation[0], rotation[1], rotation[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(parent, top, bottom, height, position, color, sides = 8, rotation = [0, 0, 0]) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(top, bottom, height, sides),
material(color)
);
mesh.position.set(position[0], position[1], position[2]);
mesh.rotation.set(rotation[0], rotation[1], rotation[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function beam(parent, a, b, radius, color, sides = 6) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, sides),
material(color)
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function groupAt(x, y, z, rotationY = 0) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotationY;
scene.add(group);
return group;
}
let seed = 89127;
function random() {
seed |= 0;
seed = seed + 0x6D2B79F5 | 0;
let t = Math.imul(seed ^ seed >>> 15, 1 | seed);
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
return ((t ^ t >>> 14) >>> 0) / 4294967296;
}
function smoothstep(min, max, value) {
const t = THREE.MathUtils.clamp((value - min) / (max - min), 0, 1);
return t * t * (3 - 2 * t);
}
const route = new THREE.CatmullRomCurve3([
new THREE.Vector3(0.7, 0, 4.5),
new THREE.Vector3(3.0, 0, 3.3),
new THREE.Vector3(4.7, 0, 1.5),
new THREE.Vector3(4.6, 0, -0.9),
new THREE.Vector3(6.4, 0, -2.6),
new THREE.Vector3(8.2, 0, -3.5),
new THREE.Vector3(10.6, 0, -5.5),
new THREE.Vector3(11.6, 0, -7.8)
], false, "catmullrom", 0.45);
const routeSamples = route.getSpacedPoints(160);
function pathHeight(t) {
return 2.65 * smoothstep(0, 1, t);
}
routeSamples.forEach((point, index) => {
point.y = pathHeight(index / (routeSamples.length - 1));
});
function routePoint(t) {
const point = route.getPointAt(THREE.MathUtils.clamp(t, 0, 1));
point.y = pathHeight(t);
return point;
}
function closestRoute(x, z) {
let bestDistance = Infinity;
let bestY = 0;
let bestT = 0;
for (let i = 0; i < routeSamples.length; i++) {
const p = routeSamples[i];
const dx = p.x - x;
const dz = p.z - z;
const distance = dx * dx + dz * dz;
if (distance < bestDistance) {
bestDistance = distance;
bestY = p.y;
bestT = i / (routeSamples.length - 1);
}
}
return { distance: Math.sqrt(bestDistance), y: bestY, t: bestT };
}
function terrainLevel(x, z) {
const inCamp = x > -10.5 && x < 0.15 && z > -5.8 && z < 4.8;
if (inCamp) return 0;
const nearest = closestRoute(x, z);
const noise = Math.max(
0,
(Math.sin(x * 0.73) + Math.cos(z * 0.91) + Math.sin((x + z) * 0.37)) * 0.055
);
const pathWeight = 1 - smoothstep(0.65, 3.0, nearest.distance);
return Math.max(0, nearest.y * pathWeight + noise * (1 - pathWeight));
}
// Voxel ground and a continuous ochre route.
box(scene, [30.6, 0.32, 23.6], [0, -1.06, 0], 0x665845, [0, 0, 0], false);
const tileCount = 29 * 21;
const terrain = new THREE.InstancedMesh(
unitBox,
new THREE.MeshStandardMaterial({ color: 0xffffff, roughness: 1 }),
tileCount
);
terrain.receiveShadow = true;
const dummy = new THREE.Object3D();
const terrainColor = new THREE.Color();
let tileIndex = 0;
for (let gx = -14; gx <= 14; gx++) {
for (let gz = -10; gz <= 10; gz++) {
const level = terrainLevel(gx + 0.5, gz + 0.5);
const nearest = closestRoute(gx + 0.5, gz + 0.5);
dummy.position.set(gx + 0.5, (level - 0.9) / 2, gz + 0.5);
dummy.scale.set(0.985, level + 0.9, 0.985);
dummy.updateMatrix();
terrain.setMatrixAt(tileIndex, dummy.matrix);
if (nearest.distance < 0.78) {
terrainColor.set(0xb8895b);
} else if (nearest.distance < 1.35) {
terrainColor.set(0x8d8b5f);
} else {
const greens = [0x74805b, 0x7f895f, 0x697653, 0x899064, 0x707d57];
terrainColor.set(greens[Math.floor(random() * greens.length)]);
terrainColor.offsetHSL(0, 0, (random() - 0.5) * 0.035);
}
terrain.setColorAt(tileIndex, terrainColor);
tileIndex++;
}
}
terrain.instanceMatrix.needsUpdate = true;
terrain.instanceColor.needsUpdate = true;
scene.add(terrain);
// Sparse voxel grass.
const tuftCount = 115;
const tufts = new THREE.InstancedMesh(
unitBox,
new THREE.MeshStandardMaterial({ color: 0x536646, roughness: 1 }),
tuftCount
);
tufts.receiveShadow = true;
let tuftIndex = 0;
let attempts = 0;
while (tuftIndex < tuftCount && attempts < 2000) {
attempts++;
const x = -14 + random() * 28;
const z = -10 + random() * 20;
const nearest = closestRoute(x, z);
const inCamp = x > -10.5 && x < 0.3 && z > -5.8 && z < 4.8;
if (nearest.distance < 1.25 || inCamp) continue;
const y = terrainLevel(x, z);
dummy.position.set(x, y + 0.12, z);
dummy.scale.set(0.055, 0.22 + random() * 0.16, 0.055);
dummy.rotation.set(0, random() * Math.PI, 0);
dummy.updateMatrix();
tufts.setMatrixAt(tuftIndex++, dummy.matrix);
}
tufts.count = tuftIndex;
tufts.instanceMatrix.needsUpdate = true;
scene.add(tufts);
// Ridge tent.
const tent = groupAt(-7.25, 0, -0.65, -0.08);
box(tent, [5.4, 0.08, 5.65], [0, 0.05, 0], 0x786b50);
const canvasTones = [0xc7b991, 0xd0c29a, 0xbcae87, 0xd5c7a2];
for (let i = 0; i < 7; i++) {
const x = -2.7 + i * 0.9;
const height = Math.max(0.34, 3.15 - Math.abs(x) * 1.03);
box(
tent,
[0.92, height, 5.5],
[x, height / 2 + 0.08, 0],
canvasTones[i % canvasTones.length]
);
}
box(tent, [0.12, 0.12, 6.05], [0, 3.25, 0], 0x65503a);
box(tent, [1.62, 2.15, 0.07], [0, 1.12, 2.79], 0x30332c);
box(tent, [0.25, 2.18, 0.14], [-0.94, 1.14, 2.86], 0xd9cca8);
box(tent, [0.25, 2.18, 0.14], [0.94, 1.14, 2.86], 0xd9cca8);
box(tent, [2.15, 0.18, 0.16], [0, 2.25, 2.86], 0xd0c29a);
beam(tent, [-2.75, 0.25, 2.75], [-4.1, 0.03, 4.1], 0.025, 0x8c7959);
beam(tent, [2.75, 0.25, 2.75], [4.05, 0.03, 4.0], 0.025, 0x8c7959);
beam(tent, [-2.75, 0.25, -2.75], [-4.0, 0.03, -4.0], 0.025, 0x8c7959);
beam(tent, [2.75, 0.25, -2.75], [4.0, 0.03, -4.0], 0.025, 0x8c7959);
// A blanket hung beside the tent.
const hangingBlanket = groupAt(-8.9, 0, 2.25, 0.15);
box(hangingBlanket, [0.06, 1.5, 1.2], [0, 1.3, 0], 0x6e7d75);
box(hangingBlanket, [0.08, 0.09, 1.35], [0, 2.08, 0], 0x5d4938);
beam(hangingBlanket, [-0.1, 0.1, -0.8], [-0.1, 2.15, -0.8], 0.035, 0x5d4938);
beam(hangingBlanket, [-0.1, 0.1, 0.8], [-0.1, 2.15, 0.8], 0.035, 0x5d4938);
// Packing table.
const table = groupAt(-7.5, 0, -4.1, 0.08);
box(table, [2.65, 0.16, 1.15], [0, 1.05, 0], 0x8b6848);
for (const x of [-1.05, 1.05]) {
for (const z of [-0.4, 0.4]) {
box(table, [0.15, 1.0, 0.15], [x, 0.5, z], 0x65503a);
}
}
box(table, [0.82, 0.13, 0.72], [-0.55, 1.2, 0], 0x9d6e58);
box(table, [0.84, 0.11, 0.72], [-0.55, 1.33, 0.03], 0xb5836c);
box(table, [0.62, 0.11, 0.65], [0.36, 1.2, -0.12], 0x7c8b78);
box(table, [0.6, 0.10, 0.64], [0.36, 1.31, -0.12], 0x9aa58e);
cylinder(table, 0.25, 0.31, 0.48, [0.75, 1.36, 0.2], 0x796552, 8);
cylinder(table, 0.26, 0.19, 0.11, [0.75, 1.65, 0.2], 0x514a3d, 8);
box(table, [0.75, 0.36, 0.5], [0.05, 0.25, 0.72], 0xa68b61);
// Open trunks and rolled bedding.
const trunks = groupAt(-9.35, 0, -3.9, -0.12);
box(trunks, [1.7, 0.72, 1.05], [0, 0.36, 0], 0x78583e);
const lid = box(trunks, [1.76, 0.15, 1.12], [0, 1.08, -0.58], 0x5d4634);
lid.rotation.x = -0.72;
box(trunks, [1.45, 0.18, 0.74], [0, 0.7, 0], 0xb4a887);
box(trunks, [0.18, 0.78, 0.13], [-0.45, 0.4, 0.55], 0x4d4031);
box(trunks, [0.18, 0.78, 0.13], [0.45, 0.4, 0.55], 0x4d4031);
const bedding = groupAt(-9.3, 0, -1.95, 0.18);
for (let i = 0; i < 3; i++) {
cylinder(
bedding,
0.24,
0.24,
1.25,
[0, 0.25 + i * 0.43, 0],
[0x6e7b71, 0x8b765a, 0xa28c68][i],
8,
[0, 0, Math.PI / 2]
);
}
// Fire, cook pot, and stools.
const fire = groupAt(-4.8, 0, 3.35);
for (let i = 0; i < 11; i++) {
const angle = (i / 11) * Math.PI * 2;
const stone = box(
fire,
[0.28 + random() * 0.1, 0.22, 0.25],
[Math.cos(angle) * 0.78, 0.13, Math.sin(angle) * 0.78],
i % 2 ? 0x77796f : 0x62665d
);
stone.rotation.y = random() * Math.PI;
}
box(fire, [1.25, 0.17, 0.18], [0, 0.18, 0], 0x604536, [0, 0.28, 0]);
box(fire, [1.25, 0.17, 0.18], [0, 0.22, 0], 0x74513b, [0, -0.55, 0]);
box(fire, [0.28, 0.5, 0.28], [-0.12, 0.43, 0], 0xc76735);
box(fire, [0.18, 0.36, 0.18], [0.12, 0.38, 0.03], 0xe09a4d);
box(fire, [0.09, 0.24, 0.09], [0.02, 0.57, 0.02], 0xf0c66f);
beam(fire, [0.7, 0.1, 0.4], [0.7, 1.25, 0.4], 0.025, 0x50483c);
beam(fire, [0.7, 1.25, 0.4], [0.7, 0.65, 0.4], 0.015, 0x50483c);
cylinder(fire, 0.29, 0.22, 0.34, [0.7, 0.36, 0.4], 0x3f4540, 8);
cylinder(fire, 0.3, 0.3, 0.06, [0.7, 0.56, 0.4], 0x303531, 8);
for (const [x, z] of [[-6.0, 2.5], [-3.6, 2.8]]) {
const stool = groupAt(x, 0, z);
box(stool, [0.65, 0.12, 0.55], [0, 0.58, 0], 0x795d43);
for (const sx of [-0.22, 0.22]) {
box(stool, [0.11, 0.55, 0.11], [sx, 0.28, 0], 0x644c38);
}
}
// Two-wheeled household cart.
const cart = groupAt(-3.25, 0, 2.3);
box(cart, [2.5, 0.18, 1.42], [-0.05, 1.05, 0], 0x7e6045);
box(cart, [2.45, 0.48, 0.11], [-0.05, 1.35, -0.72], 0x927354);
box(cart, [2.45, 0.48, 0.11], [-0.05, 1.35, 0.72], 0x927354);
box(cart, [0.11, 0.48, 1.4], [-1.22, 1.35, 0], 0x927354);
box(cart, [0.95, 0.13, 0.9], [-0.48, 1.22, 0], 0x8f8266);
box(cart, [0.88, 0.12, 0.84], [-0.48, 1.35, 0], 0xb2a382);
box(cart, [0.62, 0.55, 0.7], [0.55, 1.42, 0], 0x7c8a77);
box(cart, [0.6, 0.45, 0.58], [0.55, 1.86, 0], 0xb8a784);
cylinder(cart, 0.22, 0.27, 0.36, [0.1, 1.35, -0.32], 0x8c7258, 8);
for (const side of [-1, 1]) {
const wheel = new THREE.Group();
wheel.position.set(0.32, 0.74, side * 0.94);
cart.add(wheel);
cylinder(wheel, 0.72, 0.72, 0.16, [0, 0, 0], 0x554331, 10, [Math.PI / 2, 0, 0]);
cylinder(wheel, 0.55, 0.55, 0.18, [0, 0, 0], 0x866a4d, 10, [Math.PI / 2, 0, 0]);
for (let i = 0; i < 4; i++) {
const spoke = box(wheel, [0.09, 1.16, 0.08], [0, 0, 0], 0xb19468);
spoke.rotation.x = i * Math.PI / 4;
}
cylinder(wheel, 0.13, 0.13, 0.24, [0, 0, 0], 0x4a3c2e, 8, [Math.PI / 2, 0, 0]);
}
box(cart, [2.0, 0.1, 0.11], [1.35, 0.83, -0.48], 0x6b5138, [0, 0, -0.04]);
box(cart, [2.0, 0.1, 0.11], [1.35, 0.83, 0.48], 0x6b5138, [0, 0, -0.04]);
// Harnessed mule, oriented toward the route.
const mule = groupAt(-0.75, 0, 2.3);
box(mule, [1.62, 0.9, 0.82], [0, 1.14, 0], 0x705746);
box(mule, [0.42, 0.9, 0.5], [0.73, 1.5, 0], 0x705746, [0, 0, -0.3]);
box(mule, [0.55, 0.42, 0.46], [1.02, 1.78, 0], 0x765b48);
box(mule, [0.28, 0.25, 0.45], [1.26, 1.73, 0], 0x3f3831);
box(mule, [0.14, 0.34, 0.13], [0.93, 2.12, -0.17], 0x4b3d32);
box(mule, [0.14, 0.34, 0.13], [0.93, 2.12, 0.17], 0x4b3d32);
for (const x of [-0.55, 0.55]) {
for (const z of [-0.29, 0.29]) {
box(mule, [0.16, 0.82, 0.16], [x, 0.45, z], 0x453b33);
box(mule, [0.19, 0.15, 0.2], [x + 0.05, 0.08, z], 0x2f2d29);
}
}
box(mule, [0.16, 1.0, 0.94], [0.35, 1.16, 0], 0x4c3c31);
box(mule, [0.12, 0.94, 0.18], [0.2, 1.16, 0], 0x3f342c);
box(mule, [0.55, 0.63, 0.24], [-0.05, 1.03, -0.58], 0x8a7759);
box(mule, [0.55, 0.63, 0.24], [-0.05, 1.03, 0.58], 0x8a7759);
const muleTail = groupAt(-0.88, 1.28, 0);
mule.add(muleTail);
box(muleTail, [0.16, 0.75, 0.16], [-0.07, -0.35, 0], 0x3c332d);
// A small stack of tools and a water vessel.
const supplies = groupAt(-9.5, 0, 1.15, -0.25);
cylinder(supplies, 0.34, 0.4, 0.8, [0, 0.4, 0], 0x8d7558, 8);
cylinder(supplies, 0.22, 0.3, 0.15, [0, 0.88, 0], 0x9b8465, 8);
box(supplies, [0.12, 1.55, 0.12], [0.6, 0.78, 0.1], 0x6d563c, [0.08, 0, -0.14]);
box(supplies, [0.75, 0.1, 0.14], [0.6, 0.08, 0.1], 0x4d4e42);
// Voxel people.
const animatedPeople = [];
function makePerson(options = {}) {
const {
x = 0,
y = 0,
z = 0,
rotation = 0,
scale = 1,
coat = 0x64716a,
trousers = 0x4c5148,
hat = 0x6e5c45,
skin = 0xb88668,
scarf = 0x9b5e48,
working = false,
guiding = false
} = options;
const person = groupAt(x, y, z, rotation);
person.scale.setScalar(scale);
box(person, [0.22, 0.62, 0.27], [-0.16, 0.42, 0], trousers);
box(person, [0.22, 0.62, 0.27], [0.16, 0.42, 0], trousers);
box(person, [0.24, 0.14, 0.38], [-0.16, 0.09, 0.04], 0x3b3932);
box(person, [0.24, 0.14, 0.38], [0.16, 0.09, 0.04], 0x3b3932);
box(person, [0.64, 0.5, 0.44], [0, 0.78, 0], coat);
box(person, [0.55, 0.68, 0.36], [0, 1.18, 0], coat);
box(person, [0.52, 0.12, 0.38], [0, 1.48, 0], scarf);
box(person, [0.34, 0.38, 0.34], [0, 1.78, 0], skin);
box(person, [0.68, 0.08, 0.52], [0, 2.0, 0], hat);
box(person, [0.4, 0.24, 0.35], [0, 2.12, -0.02], hat);
box(person, [0.1, 0.12, 0.08], [0, 1.82, 0.19], skin);
function arm(side) {
const pivot = new THREE.Group();
pivot.position.set(side * 0.37, 1.43, 0);
person.add(pivot);
box(pivot, [0.17, 0.58, 0.2], [0, -0.27, 0], coat);
box(pivot, [0.18, 0.16, 0.2], [0, -0.61, 0], skin);
return pivot;
}
const leftArm = arm(-1);
const rightArm = arm(1);
if (working) {
rightArm.rotation.x = -1.15;
leftArm.rotation.x = -0.75;
}
if (guiding) {
leftArm.rotation.x = -0.95;
leftArm.rotation.z = -0.18;
beam(person, [-0.57, 0.05, 0.12], [-0.57, 2.08, 0.12], 0.035, 0x6d543c);
}
animatedPeople.push({ leftArm, rightArm, phase: random() * Math.PI * 2, working });
return person;
}
makePerson({
x: -4.75, z: 2.25, rotation: Math.PI / 2,
coat: 0x69766c, trousers: 0x494d43, hat: 0x6b573f,
scarf: 0xa3664c, working: true
});
makePerson({
x: -6.25, z: -4.65, rotation: 0.08,
coat: 0x8b6e51, trousers: 0x4e5149, hat: 0x594b3a,
scarf: 0x73837b, working: true
});
makePerson({
x: -8.55, z: -4.5, rotation: -0.4, scale: 0.72,
coat: 0x9a765a, trousers: 0x56594e, hat: 0x715b43,
scarf: 0x8f5f4b
});
makePerson({
x: -9.25, z: 0.6, rotation: 1.6,
coat: 0x737f72, trousers: 0x4b5048, hat: 0x65523d,
scarf: 0x9b7057
});
const herderPoint = routePoint(0.13);
makePerson({
x: herderPoint.x, y: herderPoint.y, z: herderPoint.z,
rotation: Math.atan2(-1.0, -0.5),
coat: 0x59695f, trousers: 0x444a43, hat: 0x6f5b42,
scarf: 0xb07a55, guiding: true
});
// Voxel sheep.
const sheepRecords = [];
function makeSheep(x, y, z, rotation, wool = 0xe4dfcc, scale = 1) {
const sheep = groupAt(x, y, z, rotation);
sheep.scale.setScalar(scale);
box(sheep, [1.05, 0.64, 0.65], [0, 0.93, 0], wool);
box(sheep, [0.72, 0.35, 0.72], [-0.14, 1.28, 0], wool);
box(sheep, [0.55, 0.35, 0.72], [0.23, 1.25, 0], wool);
box(sheep, [0.58, 0.34, 0.52], [-0.28, 0.88, 0.18], wool);
box(sheep, [0.58, 0.34, 0.52], [-0.28, 0.88, -0.18], wool);
for (const lx of [-0.35, 0.38]) {
for (const lz of [-0.23, 0.23]) {
box(sheep, [0.13, 0.56, 0.14], [lx, 0.42, lz], 0x4b443b);
box(sheep, [0.16, 0.12, 0.17], [lx + 0.02, 0.12, lz], 0x393731);
}
}
const head = new THREE.Group();
head.position.set(0.62, 1.04, 0);
sheep.add(head);
box(head, [0.45, 0.39, 0.35], [0.16, 0, 0], 0x4f4940);
box(head, [0.25, 0.23, 0.32], [0.42, -0.04, 0], 0x6d6355);
box(head, [0.12, 0.22, 0.1], [0.25, -0.25, 0], 0x5f554a);
box(head, [0.12, 0.12, 0.23], [0.06, 0.13, -0.21], 0x5f554a);
box(head, [0.12, 0.12, 0.23], [0.06, 0.13, 0.21], 0x5f554a);
box(head, [0.055, 0.055, 0.055], [0.26, 0.08, 0.18], 0x272824);
box(head, [0.055, 0.055, 0.055], [0.26, 0.08, -0.18], 0x272824);
box(sheep, [0.23, 0.28, 0.25], [-0.68, 0.95, 0], wool);
sheepRecords.push({ head, phase: random() * Math.PI * 2 });
return sheep;
}
const herdData = [
[0.27, -0.58, 0.04], [0.31, -0.15, -0.06], [0.36, -0.92, -0.08],
[0.40, -0.44, 0.03], [0.46, -1.16, 0.02], [0.51, -0.72, -0.05],
[0.57, -1.45, 0.01], [0.62, -0.96, -0.04], [0.69, -1.67, 0.03]
];
herdData.forEach(([t, offset, angle], index) => {
const p = routePoint(t);
const tangent = route.getTangentAt(t);
const normalX = -tangent.z;
const normalZ = tangent.x;
const x = p.x + normalX * offset;
const z = p.z + normalZ * offset;
makeSheep(
x, terrainLevel(x, z), z,
angle + (index % 2 ? 0.08 : -0.06),
index % 4 === 0 ? 0xdcd6c2 : 0xe7e1cf,
0.9 + random() * 0.13
);
});
// Waymark arrows embedded in the route.
for (const t of [0.08, 0.22, 0.37, 0.52, 0.68, 0.84, 0.96]) {
const p = routePoint(t);
const tangent = route.getTangentAt(t);
const arrow = new THREE.Group();
arrow.position.set(p.x, p.y + 0.055, p.z);
arrow.rotation.y = Math.atan2(-tangent.z, tangent.x);
scene.add(arrow);
box(arrow, [0.48, 0.045, 0.12], [-0.08, 0, 0], 0xe0c99b, [0, 0, 0], false);
box(arrow, [0.4, 0.045, 0.11], [0.2, 0, 0.12], 0xe0c99b, [0, Math.PI / 4, 0], false);
box(arrow, [0.4, 0.045, 0.11], [0.2, 0, -0.12], 0xe0c99b, [0, -Math.PI / 4, 0], false);
}
// Cairns and cloth-topped route stakes.
const flags = [];
function makeCairn(x, y, z) {
const cairn = groupAt(x, y, z);
const tones = [0x74786d, 0x85877b, 0x666b62, 0x99998a];
for (let i = 0; i < 4; i++) {
const stone = box(
cairn,
[0.48 - i * 0.06, 0.25, 0.4 - i * 0.045],
[(random() - 0.5) * 0.08, 0.13 + i * 0.23, (random() - 0.5) * 0.08],
tones[i % tones.length]
);
stone.rotation.y = random() * 0.8;
}
}
[0.18, 0.39, 0.61, 0.82, 0.95].forEach((t, index) => {
const p = routePoint(t);
const tangent = route.getTangentAt(t);
const nx = -tangent.z;
const nz = tangent.x;
const side = index % 2 ? -1 : 1;
makeCairn(p.x + nx * 1.18 * side, p.y, p.z + nz * 1.18 * side);
});
[0.31, 0.71].forEach((t) => {
const p = routePoint(t);
const stake = groupAt(p.x + 0.95, p.y, p.z - 0.85);
box(stake, [0.07, 1.4, 0.07], [0, 0.7, 0], 0x67523c);
const pivot = new THREE.Group();
pivot.position.set(0, 1.25, 0);
stake.add(pivot);
box(pivot, [0.55, 0.34, 0.035], [0.24, 0, 0], 0xa5573f);
flags.push({ pivot, phase: random() * Math.PI * 2 });
});
// Direction sign.
function makeSignTexture() {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 180;
const context = canvas.getContext("2d");
context.fillStyle = "#d6c39a";
context.fillRect(0, 0, 512, 180);
context.strokeStyle = "#504331";
context.lineWidth = 9;
context.strokeRect(10, 10, 492, 160);
context.fillStyle = "#3d3b30";
context.font = "bold 44px Georgia";
context.textAlign = "center";
context.fillText("UPPER PASTURE", 245, 75);
context.font = "bold 27px Arial";
context.fillText("FOUR DAYS", 245, 116);
context.lineWidth = 11;
context.strokeStyle = "#9a5939";
context.beginPath();
context.moveTo(363, 88);
context.lineTo(445, 88);
context.moveTo(420, 57);
context.lineTo(450, 88);
context.lineTo(420, 119);
context.stroke();
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
const signPoint = routePoint(0.07);
const sign = groupAt(signPoint.x + 0.65, signPoint.y, signPoint.z + 0.65, 0.12);
box(sign, [0.12, 1.9, 0.12], [0, 0.95, 0], 0x624c35);
box(sign, [2.45, 0.9, 0.12], [0, 1.55, 0], 0x8d714f);
const signFace = new THREE.Mesh(
new THREE.PlaneGeometry(2.3, 0.76),
new THREE.MeshBasicMaterial({ map: makeSignTexture(), side: THREE.DoubleSide })
);
signFace.position.set(0, 1.55, 0.067);
sign.add(signFace);
// Trees around the camp and along the distant ridge.
function makeTree(x, z, scale = 1, type = "broadleaf") {
const y = terrainLevel(x, z);
const tree = groupAt(x, y, z, random() * Math.PI * 2);
tree.scale.setScalar(scale);
box(tree, [0.32, 1.8, 0.32], [0, 0.9, 0], 0x65503a);
if (type === "pine") {
box(tree, [1.35, 0.9, 1.25], [0, 1.75, 0], 0x405c48);
box(tree, [1.0, 0.9, 0.95], [0, 2.35, 0], 0x49664e);
box(tree, [0.68, 0.85, 0.68], [0, 2.9, 0], 0x526d52);
} else {
box(tree, [1.75, 1.3, 1.55], [0, 2.0, 0], 0x5f7652);
box(tree, [1.25, 0.95, 1.2], [0.2, 2.8, -0.1], 0x6d8058);
box(tree, [1.0, 0.8, 1.0], [-0.35, 2.6, 0.25], 0x667c55);
}
return tree;
}
[
[-12, -5, 1.1], [-11.5, 1, 0.9], [-12, 6, 1.0], [-9, 8.2, 0.9],
[-5.5, 8.5, 0.75], [-1.5, 8.6, 0.9], [7.8, 7.5, 0.85],
[12.5, 5.8, 1.1], [13.2, 1.3, 1.0], [12.8, -6.7, 0.9],
[8.8, -8.7, 0.85], [3.5, -8.8, 0.8], [-4.5, -8.7, 1.05],
[-10.5, -8.2, 1.2]
].forEach(([x, z, s], i) => makeTree(x, z, s, i % 3 === 0 ? "pine" : "broadleaf"));
// Field wall at the camp's edge.
for (let i = 0; i < 10; i++) {
const stone = box(
scene,
[0.52, 0.34 + random() * 0.14, 0.43],
[-11.2 + i * 0.48, 0.19, 5.3 + Math.sin(i * 0.8) * 0.08],
i % 2 ? 0x77786c : 0x686b62
);
stone.rotation.y = (random() - 0.5) * 0.12;
}
// Distant block mountains.
function makeMountain(x, z, scale, tones) {
const mountain = groupAt(x, -0.7, z);
mountain.scale.setScalar(scale);
box(mountain, [5.8, 2.8, 3.5], [0, 1.4, 0], tones[0]);
box(mountain, [4.1, 2.4, 3.0], [-0.7, 3.0, 0], tones[1]);
box(mountain, [2.6, 2.1, 2.6], [0.2, 4.55, -0.1], tones[2]);
box(mountain, [1.3, 1.3, 2.1], [0.35, 5.65, -0.1], tones[3]);
box(mountain, [3.2, 1.1, 2.4], [2.5, 1.55, 0.5], tones[1]);
}
makeMountain(-8.5, -15.5, 1.45, [0x707a6c, 0x788171, 0x838b79, 0x8d927f]);
makeMountain(1.2, -17.5, 1.8, [0x697365, 0x737d6d, 0x7f8775, 0x89907c]);
makeMountain(11.5, -16.5, 1.55, [0x71786a, 0x7a8171, 0x848a78, 0x909381]);
// Voxel clouds and a square sun.
const cloudMaterial = new THREE.MeshStandardMaterial({
color: 0xf0ead7,
roughness: 1,
transparent: true,
opacity: 0.78,
depthWrite: false
});
const clouds = [
[-8, 9.2, -11, 1.2], [2, 11.4, -15, 1.5], [10, 8.7, -10, 1.0],
[-13, 6.8, -7, 0.8]
];
clouds.forEach(([x, y, z, s]) => {
const cloud = groupAt(x, y, z);
cloud.scale.setScalar(s);
box(cloud, [2.6, 0.55, 0.8], [0, 0, 0], cloudMaterial, [0, 0, 0], false);
box(cloud, [1.45, 0.7, 0.75], [-0.7, 0.22, 0], cloudMaterial, [0, 0, 0], false);
box(cloud, [1.5, 0.85, 0.75], [0.75, 0.25, 0], cloudMaterial, [0, 0, 0], false);
});
const sunMaterial = new THREE.MeshBasicMaterial({ color: 0xf0d69a });
box(scene, [1.65, 1.65, 0.18], [-10.5, 10.3, -13.8], sunMaterial, [0, 0, 0], false);
// Small, block-like smoke drifting from the fire.
const smokeMaterial = new THREE.MeshStandardMaterial({
color: 0xb7b4aa,
roughness: 1,
transparent: true,
opacity: 0.28,
depthWrite: false
});
const smoke = [];
for (let i = 0; i < 6; i++) {
const puff = box(
fire,
[0.25, 0.25, 0.25],
[0, 0.9 + i * 0.42, 0],
smokeMaterial,
[0, 0, 0],
false
);
smoke.push(puff);
}
// Custom orbit and zoom controls, implemented without Three.js addons.
const defaultView = {
azimuth: 0.58,
polar: 1.00,
distance: window.innerWidth < 650 ? 31 : 27,
target: new THREE.Vector3(-1.0, 1.1, 0.0)
};
const view = {
azimuth: defaultView.azimuth,
polar: defaultView.polar,
distance: defaultView.distance,
target: defaultView.target.clone()
};
let goal = null;
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
function updateCamera() {
const sinPolar = Math.sin(view.polar);
camera.position.set(
view.target.x + view.distance * sinPolar * Math.sin(view.azimuth),
view.target.y + view.distance * Math.cos(view.polar),
view.target.z + view.distance * sinPolar * Math.cos(view.azimuth)
);
camera.lookAt(view.target);
}
function setCameraGoal(next) {
goal = {
azimuth: next.azimuth,
polar: next.polar,
distance: next.distance,
target: next.target.clone()
};
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
goal = null;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
view.azimuth -= dx * 0.005;
view.polar = THREE.MathUtils.clamp(view.polar - dy * 0.0045, 0.42, 1.36);
updateCamera();
});
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("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
goal = null;
view.distance = THREE.MathUtils.clamp(
view.distance * Math.exp(event.deltaY * 0.001),
10,
43
);
updateCamera();
}, { passive: false });
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") view.azimuth += 0.08;
else if (event.key === "ArrowRight") view.azimuth -= 0.08;
else if (event.key === "ArrowUp") view.polar = Math.max(0.42, view.polar - 0.06);
else if (event.key === "ArrowDown") view.polar = Math.min(1.36, view.polar + 0.06);
else if (event.key === "+" || event.key === "=") view.distance = Math.max(10, view.distance - 1);
else if (event.key === "-") view.distance = Math.min(43, view.distance + 1);
else if (event.key.toLowerCase() === "r") {
setCameraGoal(defaultView);
return;
} else return;
goal = null;
updateCamera();
});
document.getElementById("reset-view").addEventListener("click", () => {
setCameraGoal(defaultView);
});
document.getElementById("route-view").addEventListener("click", () => {
setCameraGoal({
azimuth: 0.34,
polar: 0.83,
distance: 18,
target: new THREE.Vector3(5.2, 1.2, -1.6)
});
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
updateCamera();
const clock = new THREE.Clock();
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
function animate() {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
if (goal) {
view.azimuth = THREE.MathUtils.lerp(view.azimuth, goal.azimuth, 0.075);
view.polar = THREE.MathUtils.lerp(view.polar, goal.polar, 0.075);
view.distance = THREE.MathUtils.lerp(view.distance, goal.distance, 0.075);
view.target.lerp(goal.target, 0.075);
updateCamera();
if (
Math.abs(view.azimuth - goal.azimuth) < 0.001 &&
Math.abs(view.polar - goal.polar) < 0.001 &&
Math.abs(view.distance - goal.distance) < 0.01 &&
view.target.distanceTo(goal.target) < 0.01
) {
goal = null;
}
}
if (!reducedMotion) {
sheepRecords.forEach(({ head, phase }, index) => {
head.rotation.z = Math.sin(time * 0.8 + phase) * 0.055 + (index % 3 === 0 ? 0.08 : 0);
});
animatedPeople.forEach(({ leftArm, rightArm, phase, working }) => {
if (working) {
rightArm.rotation.x = -1.15 + Math.sin(time * 1.45 + phase) * 0.1;
leftArm.rotation.x = -0.75 + Math.cos(time * 1.45 + phase) * 0.08;
}
});
muleTail.rotation.z = Math.sin(time * 1.7) * 0.14;
flags.forEach(({ pivot, phase }) => {
pivot.rotation.y = Math.sin(time * 1.5 + phase) * 0.09;
});
smoke.forEach((puff, index) => {
const progress = (time * 0.11 + index / smoke.length) % 1;
puff.position.y = 0.75 + progress * 2.7;
puff.position.x = Math.sin(progress * 5 + index) * 0.16 + progress * 0.24;
puff.position.z = Math.cos(progress * 4 + index) * 0.11;
const size = 0.17 + progress * 0.46;
puff.scale.set(size, size, size);
});
}
renderer.render(scene, camera);
}
animate();
requestAnimationFrame(() => loading.classList.add("hidden"));
</script>
</body>
</html>
```