Prompt specification
Build or customize the Three.js 3D scene "Oasis caravan rest and redistribution" 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: Oasis caravan rest and redistribution
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/oasis-caravan-rest-and-redistribution-x2634
Scene Description Prompt:
A voxel trans-Saharan caravan redistributes loads at an oasis with pack animals, shade, storage, and accessible water. Three.js from cdnjs, one HTML file.
Working Three.js Starter (oasis-caravan-rest-and-redistribution-x2634):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ochre Crossing — Voxel Caravan Oasis</title>
<style>
:root {
--ink: #342a24;
--cream: #fff2cf;
--terra: #b9573e;
--teal: #287675;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 77% 14%, #fff5c9 0 5%, #f8df9e 5.3%, transparent 12%),
linear-gradient(180deg, #8fb9b7 0%, #d8c18b 48%, #c58f58 100%);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#app, canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
}
canvas {
display: block;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background: radial-gradient(circle at center, transparent 46%, rgba(70, 43, 24, .18) 115%);
}
.ui {
position: fixed;
inset: 0;
pointer-events: none;
}
.brand {
position: absolute;
top: 28px;
left: 30px;
max-width: 390px;
padding: 18px 20px 17px;
border: 1px solid rgba(255, 244, 210, .52);
border-radius: 16px;
background: rgba(255, 239, 199, .82);
box-shadow: 0 16px 45px rgba(78, 47, 24, .13);
backdrop-filter: blur(12px);
}
.eyebrow {
margin-bottom: 7px;
color: var(--terra);
font-size: 10px;
font-weight: 800;
letter-spacing: .2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 4vw, 42px);
font-weight: 500;
letter-spacing: -.035em;
line-height: .98;
}
.brand p {
margin: 10px 0 0;
color: rgba(52, 42, 36, .72);
font-size: 12px;
line-height: 1.5;
}
.chips {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 13px;
}
.chip {
padding: 5px 8px;
border-radius: 999px;
background: rgba(52, 42, 36, .08);
color: rgba(52, 42, 36, .78);
font-size: 9px;
font-weight: 800;
letter-spacing: .08em;
text-transform: uppercase;
}
.reset {
position: absolute;
top: 29px;
right: 30px;
pointer-events: auto;
border: 1px solid rgba(255, 244, 210, .58);
border-radius: 12px;
padding: 11px 14px;
background: rgba(52, 42, 36, .76);
color: var(--cream);
font: inherit;
font-size: 10px;
font-weight: 800;
letter-spacing: .12em;
text-transform: uppercase;
cursor: pointer;
box-shadow: 0 10px 28px rgba(64, 40, 24, .15);
backdrop-filter: blur(10px);
}
.reset:hover { background: rgba(52, 42, 36, .92); }
.controls {
position: absolute;
right: 30px;
bottom: 27px;
padding: 10px 13px;
border-radius: 10px;
background: rgba(255, 239, 199, .72);
color: rgba(52, 42, 36, .72);
font-size: 10px;
font-weight: 700;
letter-spacing: .05em;
backdrop-filter: blur(10px);
}
.scene-note {
position: absolute;
left: 30px;
bottom: 27px;
display: flex;
align-items: center;
gap: 9px;
color: rgba(255, 244, 210, .92);
font-size: 10px;
font-weight: 800;
letter-spacing: .13em;
text-transform: uppercase;
text-shadow: 0 2px 8px rgba(50, 32, 20, .45);
}
.scene-note::before {
content: "";
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--terra);
box-shadow: 0 0 0 4px rgba(185, 87, 62, .2);
}
@media (max-width: 650px) {
.brand {
top: 15px;
left: 15px;
right: 15px;
max-width: none;
padding: 14px 16px;
}
.brand p, .chips { display: none; }
.reset {
top: 112px;
right: 16px;
}
.controls { right: 15px; bottom: 15px; }
.scene-note { left: 15px; bottom: 16px; }
}
</style>
</head>
<body>
<div id="app"></div>
<div class="vignette"></div>
<div class="ui">
<section class="brand">
<div class="eyebrow">Voxel field note · S07</div>
<h1>Ochre Crossing</h1>
<p>A trans-Saharan caravan pauses at a shaded oasis exchange, dividing bundles between storage, pack animals, and fresh water.</p>
<div class="chips">
<span class="chip">Caravan</span>
<span class="chip">Caravanserel</span>
<span class="chip">Oasis water</span>
</div>
</section>
<button class="reset" id="reset">Reset view</button>
<div class="scene-note">Oasis exchange · dusk light</div>
<div class="controls">Drag to orbit · Scroll to zoom · R to reset</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const app = document.getElementById("app");
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0xddc18d, 43, 86);
const camera = new THREE.PerspectiveCamera(36, innerWidth / innerHeight, 0.1, 140);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.18;
renderer.setClearColor(0x000000, 0);
app.appendChild(renderer.domElement);
const GROUND = 0.12;
const palette = {
sand: 0xd9ae69,
sandLight: 0xe8c584,
sandDark: 0xb77d43,
adobe: 0xc98d58,
adobeLight: 0xdda56d,
adobeDark: 0xaa7047,
wood: 0x68452e,
woodLight: 0x94643f,
rust: 0xb9573e,
teal: 0x2e7775,
cream: 0xf0d39a,
charcoal: 0x362d28,
camel: 0xc89455,
camelLight: 0xd9aa6d,
camelDark: 0x9f6838,
leaf: 0x4c7244,
leafLight: 0x73904c,
leafDark: 0x36583d,
water: 0x318f99,
waterLight: 0x67c4bd
};
const materialCache = new Map();
function material(color, options = {}) {
if (color && color.isMaterial) return color;
const key = `${color}-${JSON.stringify(options)}`;
if (!materialCache.has(key)) {
materialCache.set(key, new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0,
...options
}));
}
return materialCache.get(key);
}
function block(parent, size, position, color, rotation = [0, 0, 0]) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
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;
}
// Lighting
scene.add(new THREE.HemisphereLight(0xb9e1df, 0x9c6339, 2.1));
const sun = new THREE.DirectionalLight(0xffe0a3, 3.5);
sun.position.set(-16, 27, 15);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -24;
sun.shadow.camera.right = 24;
sun.shadow.camera.top = 24;
sun.shadow.camera.bottom = -24;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 70;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const warmFill = new THREE.DirectionalLight(0xf0a55d, 0.7);
warmFill.position.set(15, 10, -16);
scene.add(warmFill);
// A soft shadow beneath the floating diorama.
const shadowFloor = new THREE.Mesh(
new THREE.PlaneGeometry(90, 90),
new THREE.ShadowMaterial({ opacity: 0.18 })
);
shadowFloor.rotation.x = -Math.PI / 2;
shadowFloor.position.y = -1.43;
shadowFloor.receiveShadow = true;
scene.add(shadowFloor);
// Stepped voxel terrain.
block(scene, [30, 1.2, 23], [0, -0.76, 0], palette.sandDark);
block(scene, [29.5, 0.3, 22.5], [0, -0.11, 0], palette.sand);
const isPoolCell = (x, z) =>
Math.pow((x - 7) / 4.35, 2) + Math.pow((z - 1) / 3.15, 2) < 1;
const cells = [];
for (let x = -14; x <= 14; x++) {
for (let z = -10; z <= 10; z++) {
if (!isPoolCell(x, z)) cells.push({ x, z });
}
}
const tileGeometry = new THREE.BoxGeometry(1, 1, 1);
const tileMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 1,
vertexColors: true
});
const tileMesh = new THREE.InstancedMesh(tileGeometry, tileMaterial, cells.length);
tileMesh.receiveShadow = true;
const dummy = new THREE.Object3D();
const tileColor = new THREE.Color();
cells.forEach((cell, index) => {
const road =
(cell.z >= 4 && cell.z <= 6 && cell.x <= 4) ||
(cell.x >= 1 && cell.x <= 3 && cell.z >= -4 && cell.z <= 4);
dummy.position.set(cell.x, 0.08, cell.z);
dummy.scale.set(0.97, 0.08, 0.97);
dummy.updateMatrix();
tileMesh.setMatrixAt(index, dummy.matrix);
tileColor.set(road ? 0xe6c17f : palette.sand);
tileColor.offsetHSL(0, 0, (Math.random() - 0.5) * 0.075);
tileMesh.setColorAt(index, tileColor);
});
tileMesh.instanceMatrix.needsUpdate = true;
if (tileMesh.instanceColor) tileMesh.instanceColor.needsUpdate = true;
scene.add(tileMesh);
// Pool: stepped blue voxel tiles with a darker wet bed.
const waterMeshes = [];
const poolGroup = new THREE.Group();
scene.add(poolGroup);
for (let x = 3; x <= 11; x++) {
for (let z = -3; z <= 5; z++) {
if (!isPoolCell(x, z)) continue;
block(poolGroup, [0.99, 0.14, 0.99], [x, -0.045, z], 0x8b7955);
const water = block(
poolGroup,
[0.93, 0.055, 0.93],
[x, 0.045 + Math.random() * 0.006, z],
Math.random() > 0.78 ? palette.waterLight : palette.water,
[0, 0, 0]
);
water.castShadow = false;
water.userData.baseY = water.position.y;
water.userData.phase = Math.random() * Math.PI * 2;
waterMeshes.push(water);
}
}
// Wet shoreline blocks.
for (let x = 2; x <= 12; x++) {
for (let z = -4; z <= 6; z++) {
if (isPoolCell(x, z)) continue;
const nearPool = [
[x + 1, z], [x - 1, z], [x, z + 1], [x, z - 1]
].some(([nx, nz]) => isPoolCell(nx, nz));
if (nearPool) {
block(scene, [0.96, 0.045, 0.96], [x, 0.115, z], 0xb9a56f);
}
}
}
// A clear stepping-stone route from the shade to the water.
for (let i = 0; i < 7; i++) {
const x = 1.8 + i * 0.72;
const z = 2.9 + Math.sin(i * 0.7) * 0.35;
block(scene, [0.68, 0.16, 0.58], [x, 0.11, z], i % 2 ? 0xc8b681 : 0xbda36e);
}
// Helpers for props.
function createCrate(parent, x, y, z, size = 0.72, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
parent.add(group);
block(group, [size, size * 0.88, size], [0, size * 0.44, 0], palette.woodLight);
block(group, [size * 1.03, 0.09, size * 1.04], [0, size * 0.22, 0], palette.wood);
block(group, [0.09, size * 0.9, size * 1.04], [-size * 0.24, size * 0.44, 0], palette.wood);
block(group, [0.09, size * 0.9, size * 1.04], [size * 0.24, size * 0.44, 0], palette.wood);
return group;
}
function createSack(parent, x, y, z, scale = 1, color = palette.cream) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = Math.random() * Math.PI;
parent.add(group);
block(group, [0.64 * scale, 0.48 * scale, 0.55 * scale], [0, 0.25 * scale, 0], color);
block(group, [0.52 * scale, 0.22 * scale, 0.45 * scale], [0.02, 0.57 * scale, 0], 0xe2bd83);
block(group, [0.19 * scale, 0.12 * scale, 0.19 * scale], [0, 0.72 * scale, 0], palette.wood);
return group;
}
function createJar(parent, x, y, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
parent.add(group);
block(group, [0.42 * scale, 0.18 * scale, 0.42 * scale], [0, 0.09 * scale, 0], 0x895039);
block(group, [0.58 * scale, 0.42 * scale, 0.58 * scale], [0, 0.38 * scale, 0], 0xb96842);
block(group, [0.45 * scale, 0.25 * scale, 0.45 * scale], [0, 0.7 * scale, 0], 0xc8794d);
block(group, [0.28 * scale, 0.15 * scale, 0.28 * scale], [0, 0.88 * scale, 0], 0x724335);
return group;
}
function createPerson(parent, x, y, z, robeColor, rotation = 0, carrying = false) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
parent.add(group);
block(group, [0.48, 0.72, 0.38], [0, 0.52, 0], robeColor);
block(group, [0.44, 0.48, 0.34], [0, 1.02, 0], robeColor);
block(group, [0.33, 0.33, 0.33], [0, 1.43, 0], 0x9a6747);
block(group, [0.43, 0.16, 0.43], [0, 1.64, 0], palette.cream);
block(group, [0.15, 0.55, 0.15], [-0.29, 0.95, 0], robeColor, [0, 0, -0.12]);
block(group, [0.15, 0.55, 0.15], [0.29, 0.95, 0], robeColor, [0, 0, 0.12]);
block(group, [0.16, 0.16, 0.28], [-0.14, 0.08, 0.03], palette.charcoal);
block(group, [0.16, 0.16, 0.28], [0.14, 0.08, 0.03], palette.charcoal);
if (carrying) {
createSack(group, 0, 1.2, 0, 0.62, palette.cream);
}
return group;
}
function createCamel(parent, x, z, rotation = 0, loaded = true, scale = 1) {
const group = new THREE.Group();
group.position.set(x, GROUND, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
parent.add(group);
block(group, [2.0, 0.82, 0.82], [-0.1, 1.66, 0], palette.camel);
block(group, [0.72, 0.78, 0.7], [-0.22, 2.42, 0], palette.camelLight);
block(group, [0.55, 0.5, 0.62], [0.28, 2.33, 0], palette.camel);
block(group, [0.5, 1.58, 0.48], [0.86, 2.63, 0], palette.camel, [0, 0, -0.09]);
block(group, [0.76, 0.4, 0.42], [1.16, 3.42, 0], palette.camelLight);
block(group, [0.36, 0.27, 0.34], [1.58, 3.37, 0], palette.camel);
block(group, [0.12, 0.24, 0.12], [1.02, 3.72, -0.14], palette.camelDark);
block(group, [0.12, 0.24, 0.12], [1.02, 3.72, 0.14], palette.camelDark);
const legXs = [-0.7, 0.55];
const legZs = [-0.28, 0.28];
for (const lx of legXs) {
for (const lz of legZs) {
block(group, [0.25, 1.4, 0.24], [lx, 0.73, lz], palette.camelDark);
block(group, [0.32, 0.16, 0.3], [lx + 0.03, 0.08, lz], palette.charcoal);
}
}
block(group, [0.14, 0.75, 0.14], [-1.14, 1.46, 0], palette.camelDark, [0, 0, 0.15]);
block(group, [0.28, 0.55, 0.25], [-1.13, 1.02, 0], palette.camelDark);
block(group, [1.43, 0.12, 1.01], [-0.1, 2.12, 0], palette.rust);
block(group, [1.03, 0.07, 0.72], [-0.1, 2.21, 0], palette.teal);
if (loaded) {
block(group, [0.95, 0.64, 0.5], [-0.22, 2.53, -0.63], palette.cream);
block(group, [0.84, 0.56, 0.46], [0.25, 2.48, 0.62], 0xd5b779);
block(group, [0.11, 0.7, 0.54], [-0.22, 2.55, -0.66], palette.wood);
block(group, [0.1, 0.64, 0.5], [0.25, 2.49, 0.65], palette.wood);
} else {
block(group, [0.54, 0.44, 0.46], [-0.18, 2.5, -0.61], 0x8c5d3d);
}
// Rope and tiny hanging tassels.
block(group, [0.06, 0.66, 0.06], [0.45, 1.72, 0.45], palette.woodLight, [0, 0, -0.12]);
block(group, [0.06, 0.55, 0.06], [0.45, 1.64, -0.45], palette.woodLight, [0, 0, -0.1]);
block(group, [0.15, 0.25, 0.12], [0.38, 1.28, 0.45], palette.rust);
return group;
}
function createDonkey(parent, x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, GROUND, z);
group.rotation.y = rotation;
group.scale.setScalar(0.76);
parent.add(group);
block(group, [1.55, 0.65, 0.65], [0, 1.2, 0], 0x77716b);
block(group, [0.44, 1.1, 0.42], [0.72, 1.8, 0], 0x77716b, [0, 0, -0.12]);
block(group, [0.68, 0.36, 0.36], [0.98, 2.38, 0], 0x858078);
block(group, [0.13, 0.3, 0.12], [0.85, 2.68, -0.14], 0x59544f);
block(group, [0.13, 0.3, 0.12], [0.85, 2.68, 0.14], 0x59544f);
for (const lx of [-0.5, 0.48]) {
for (const lz of [-0.22, 0.22]) {
block(group, [0.2, 1.05, 0.2], [lx, 0.53, lz], 0x65605b);
block(group, [0.24, 0.12, 0.24], [lx, 0.06, lz], 0x3d3936);
}
}
block(group, [0.65, 0.1, 0.82], [-0.05, 1.57, 0], palette.teal);
block(group, [0.48, 0.5, 0.42], [-0.22, 1.83, -0.48], palette.cream);
return group;
}
// Adobe caravanserel / storage building.
const building = new THREE.Group();
building.position.set(-8, GROUND, -6.6);
scene.add(building);
block(building, [7.9, 3.6, 0.5], [0, 1.8, -2.7], palette.adobe);
block(building, [0.5, 3.6, 5.4], [-3.7, 1.8, 0], palette.adobeDark);
block(building, [0.5, 3.6, 5.4], [3.7, 1.8, 0], palette.adobe);
block(building, [3.5, 3.6, 0.5], [-2.15, 1.8, 2.7], palette.adobeLight);
block(building, [2.3, 3.6, 0.5], [2.75, 1.8, 2.7], palette.adobe);
block(building, [2.0, 0.72, 0.5], [0.6, 3.24, 2.7], palette.adobeLight);
// Recessed doorway and stepped arch.
block(building, [1.88, 2.48, 0.08], [0.6, 1.25, 2.42], 0x332a25);
block(building, [0.28, 0.72, 0.58], [-0.48, 2.68, 2.72], palette.adobeLight);
block(building, [0.28, 0.72, 0.58], [1.68, 2.68, 2.72], palette.adobeLight);
block(building, [0.55, 0.25, 0.58], [0.08, 2.99, 2.72], palette.adobeLight);
block(building, [0.55, 0.25, 0.58], [1.1, 2.99, 2.72], palette.adobeLight);
// Flat roof and parapets.
block(building, [8.5, 0.35, 5.9], [0, 3.78, 0], 0xb77749);
block(building, [8.25, 0.48, 0.28], [0, 4.05, 2.78], palette.adobeLight);
block(building, [8.25, 0.48, 0.28], [0, 4.05, -2.78], palette.adobeLight);
block(building, [0.28, 0.48, 5.55], [-4.0, 4.05, 0], palette.adobeLight);
block(building, [0.28, 0.48, 5.55], [4.0, 4.05, 0], palette.adobeLight);
// Small shaded window with a wooden lattice.
block(building, [0.85, 0.84, 0.06], [2.72, 2.3, 2.98], 0x4b3429);
block(building, [0.08, 0.82, 0.09], [2.72, 2.3, 3.03], palette.woodLight);
block(building, [0.82, 0.08, 0.09], [2.72, 2.3, 3.03], palette.woodLight);
// Horizontal adobe seams.
for (let y = 0.55; y < 3.4; y += 0.68) {
block(building, [3.45, 0.055, 0.08], [-2.15, y, 2.97], palette.adobeDark);
block(building, [2.25, 0.055, 0.08], [2.75, y, 2.97], palette.adobeDark);
block(building, [0.08, 0.055, 5.25], [-3.97, y, 0], palette.adobeDark);
}
// Interior shelving, visible through the doorway.
block(building, [2.2, 0.12, 0.55], [0.6, 1.4, 0.7], palette.wood);
block(building, [2.2, 0.12, 0.55], [0.6, 2.2, 0.7], palette.wood);
createCrate(building, 0.05, 1.46, 0.75, 0.48);
createCrate(building, 0.85, 1.46, 0.75, 0.48);
createSack(building, 0.45, 2.27, 0.72, 0.62);
// Shade canopy.
const canopy = new THREE.Group();
canopy.position.set(-2.35, GROUND, 0.15);
scene.add(canopy);
for (const x of [-3.05, 3.05]) {
for (const z of [-1.62, 1.62]) {
block(canopy, [0.17, 3.65, 0.17], [x, 1.82, z], palette.wood);
}
}
block(canopy, [6.35, 0.16, 0.18], [0, 3.55, -1.62], palette.woodLight);
block(canopy, [6.35, 0.16, 0.18], [0, 3.55, 1.62], palette.woodLight);
for (let i = 0; i < 8; i++) {
const x = -2.72 + i * 0.78;
const stripeColor = i % 3 === 0 ? palette.rust : i % 3 === 1 ? palette.cream : palette.teal;
block(canopy, [0.76, 0.12, 3.7], [x, 3.68, 0], stripeColor);
block(canopy, [0.16, 0.2, 0.16], [x, 3.48, 1.78], stripeColor);
}
// Woven rugs beneath the loading area.
block(canopy, [2.4, 0.035, 1.6], [-0.8, 0.035, 0.15], palette.rust);
block(canopy, [0.34, 0.04, 1.58], [-0.8, 0.052, 0.15], palette.cream);
block(canopy, [0.22, 0.04, 1.58], [-0.1, 0.052, 0.15], palette.teal);
// Storage goods around the canopy.
createCrate(scene, -5.25, GROUND, -2.15, 0.82, 0.08);
createCrate(scene, -4.25, GROUND, -2.55, 0.68, -0.1);
createCrate(scene, -0.05, GROUND, -1.8, 0.76, 0.04);
createCrate(scene, 0.45, GROUND, -2.1, 0.58, 0.12);
createSack(scene, -5.55, GROUND, 1.95, 0.95);
createSack(scene, -4.85, GROUND, 2.18, 0.82, 0xd7b778);
createSack(scene, -0.55, GROUND, 2.35, 0.9, palette.cream);
createJar(scene, 1.1, GROUND, -2.6, 0.9);
createJar(scene, 1.5, GROUND, -3.25, 0.72);
// Caravanserel frontage storage.
createCrate(scene, -5.3, GROUND, -3.25, 0.9, -0.05);
createCrate(scene, -4.25, GROUND, -3.55, 0.66, 0.04);
createSack(scene, -6.0, GROUND, -3.6, 0.88);
createJar(scene, -3.5, GROUND, -3.75, 1.05);
// Caravan and pack animals.
createCamel(scene, -8.5, 5.55, 0.04, true, 1.0);
createCamel(scene, -5.1, 5.25, -0.08, true, 0.96);
createCamel(scene, 2.65, 0.8, -Math.PI / 2, false, 0.92);
createDonkey(scene, -10.1, 2.8, 0.18);
createDonkey(scene, -11.65, 2.4, 0.03);
// Handlers actively redistribute bundles.
createPerson(scene, -6.25, GROUND, 3.95, palette.teal, -0.3, true);
createPerson(scene, -3.85, GROUND, 2.9, palette.rust, 0.35, false);
createPerson(scene, -4.35, GROUND, -3.1, palette.cream, 0.1, true);
createPerson(scene, 4.8, GROUND, -1.65, palette.teal, -0.5, false);
// Stone well with a tiny roof.
const well = new THREE.Group();
well.position.set(1.05, GROUND, -6.45);
scene.add(well);
block(well, [1.9, 0.65, 1.9], [0, 0.325, 0], 0x9f9275);
block(well, [1.4, 0.08, 1.4], [0, 0.68, 0], 0x4d493c);
block(well, [0.16, 2.2, 0.16], [-0.72, 1.62, 0], palette.wood);
block(well, [0.16, 2.2, 0.16], [0.72, 1.62, 0], palette.wood);
block(well, [1.8, 0.16, 0.18], [0, 2.66, 0], palette.woodLight);
block(well, [0.17, 1.1, 0.17], [0, 2.08, 0], palette.woodLight, [0, 0, 0.1]);
block(well, [0.12, 0.8, 0.12], [0, 1.45, 0], 0x6f5538);
block(well, [0.42, 0.45, 0.42], [0, 0.98, 0], palette.woodLight);
block(well, [0.29, 0.06, 0.29], [0, 1.23, 0], 0x4a3529);
createPerson(scene, 2.15, GROUND, -6.05, palette.cream, -0.7, true);
// Drinking trough between the shade and pool.
const trough = new THREE.Group();
trough.position.set(2.55, GROUND, 2.5);
scene.add(trough);
block(trough, [1.85, 0.48, 0.76], [0, 0.24, 0], 0x8f8168);
block(trough, [1.56, 0.08, 0.48], [0, 0.5, 0], palette.waterLight);
block(trough, [1.85, 0.22, 0.14], [0, 0.54, -0.31], 0xb0a07b);
block(trough, [1.85, 0.22, 0.14], [0, 0.54, 0.31], 0xb0a07b);
block(trough, [0.14, 0.22, 0.62], [-0.85, 0.54, 0], 0xb0a07b);
block(trough, [0.14, 0.22, 0.62], [0.85, 0.54, 0], 0xb0a07b);
// Palms.
const palmCrowns = [];
function createPalm(x, z, height, scale = 1) {
const palm = new THREE.Group();
palm.position.set(x, GROUND, z);
palm.scale.setScalar(scale);
scene.add(palm);
const segments = 7;
for (let i = 0; i < segments; i++) {
block(
palm,
[0.44, 0.57, 0.44],
[Math.sin(i * 0.45) * 0.11, 0.29 + i * 0.52, Math.cos(i * 0.3) * 0.06],
i % 2 ? 0x8e603a : 0x795035,
[0, i * 0.06, Math.sin(i * 0.4) * 0.025]
);
}
const crown = new THREE.Group();
crown.position.set(Math.sin(segments * 0.45) * 0.11, segments * 0.52 + 0.15, 0);
palm.add(crown);
for (let i = 0; i < 8; i++) {
const angle = i * Math.PI / 4 + Math.random() * 0.12;
for (let j = 0; j < 4; j++) {
const length = 1.05 - j * 0.15;
const distance = 0.42 + j * 0.82;
block(
crown,
[length, 0.14, 0.35 - j * 0.045],
[Math.cos(angle) * distance, -j * 0.11, Math.sin(angle) * distance],
(i + j) % 2 ? palette.leaf : palette.leafLight,
[0, -angle, -0.11 - j * 0.035]
);
}
}
block(crown, [0.48, 0.42, 0.48], [0, 0.02, 0], 0x526b3b);
palmCrowns.push({ crown, phase: Math.random() * Math.PI * 2 });
}
createPalm(11.7, -4.7, 3.8, 1.08);
createPalm(13.1, 2.8, 3.45, 0.92);
createPalm(5.4, -6.1, 3.3, 0.88);
createPalm(11.3, 7.1, 3.5, 0.96);
createPalm(-13.1, -8.1, 3.2, 0.86);
createPalm(7.8, -9.1, 3.55, 0.95);
// A small flag above the well.
block(scene, [0.11, 2.8, 0.11], [-2.1, GROUND + 1.4, -7.8], palette.wood);
block(scene, [1.15, 0.62, 0.08], [-1.53, GROUND + 2.55, -7.8], palette.teal);
// Voxel square ripples on the pool.
const ripples = [];
for (let i = 0; i < 2; i++) {
const ring = new THREE.Group();
const ringMaterial = new THREE.MeshBasicMaterial({
color: 0xb4e0cf,
transparent: true,
opacity: 0.45,
depthWrite: false
});
const side = new THREE.Mesh(new THREE.BoxGeometry(1, 0.012, 0.035), ringMaterial);
side.position.z = 0.5;
const side2 = side.clone();
side2.position.z = -0.5;
const side3 = new THREE.Mesh(new THREE.BoxGeometry(0.035, 0.012, 1), ringMaterial);
side3.position.x = 0.5;
const side4 = side3.clone();
side4.position.x = -0.5;
ring.add(side, side2, side3, side4);
ring.position.set(6.9 + i * 0.7, 0.09, 1.1 - i * 0.8);
ring.userData.phase = i * 0.55;
ring.userData.material = ringMaterial;
scene.add(ring);
ripples.push(ring);
}
// Camera controls, implemented without external addons.
const target = new THREE.Vector3(0, 1.05, 0);
const initialView = { yaw: 0.72, pitch: 0.69, radius: 37 };
let yaw = initialView.yaw;
let pitch = initialView.pitch;
let radius = initialView.radius;
function updateCamera() {
const horizontal = Math.cos(pitch) * radius;
camera.position.set(
target.x + Math.sin(yaw) * horizontal,
target.y + Math.sin(pitch) * radius,
target.z + Math.cos(yaw) * horizontal
);
camera.lookAt(target);
}
function resetView() {
yaw = initialView.yaw;
pitch = initialView.pitch;
radius = initialView.radius;
updateCamera();
}
updateCamera();
const pointers = new Map();
let lastPinchDistance = 0;
renderer.domElement.addEventListener("pointerdown", event => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
lastPinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
renderer.domElement.addEventListener("pointermove", event => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
if (pointers.size === 1) {
yaw -= (event.clientX - previous.x) * 0.006;
pitch += (event.clientY - previous.y) * 0.0045;
pitch = THREE.MathUtils.clamp(pitch, 0.28, 1.23);
}
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
if (lastPinchDistance > 0) {
radius *= lastPinchDistance / Math.max(distance, 1);
radius = THREE.MathUtils.clamp(radius, 20, 58);
}
lastPinchDistance = distance;
}
updateCamera();
});
function endPointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) lastPinchDistance = 0;
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("contextmenu", event => event.preventDefault());
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
radius *= Math.exp(event.deltaY * 0.001);
radius = THREE.MathUtils.clamp(radius, 20, 58);
updateCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", resetView);
document.getElementById("reset").addEventListener("click", resetView);
addEventListener("keydown", event => {
if (event.key.toLowerCase() === "r") resetView();
if (event.key === "ArrowLeft") yaw += 0.08;
if (event.key === "ArrowRight") yaw -= 0.08;
if (event.key === "ArrowUp") pitch = Math.min(1.23, pitch + 0.05);
if (event.key === "ArrowDown") pitch = Math.max(0.28, pitch - 0.05);
updateCamera();
});
addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
renderer.setAnimationLoop(time => {
const t = time * 0.001;
waterMeshes.forEach(water => {
water.position.y = water.userData.baseY + Math.sin(t * 1.35 + water.userData.phase) * 0.009;
});
palmCrowns.forEach(palm => {
palm.crown.rotation.z = Math.sin(t * 0.8 + palm.phase) * 0.018;
palm.crown.rotation.x = Math.cos(t * 0.63 + palm.phase) * 0.012;
});
ripples.forEach(ripple => {
const cycle = (t * 0.22 + ripple.userData.phase) % 1;
const scale = 0.45 + cycle * 2.25;
ripple.scale.set(scale, 1, scale);
ripple.userData.material.opacity = (1 - cycle) * 0.42;
});
renderer.render(scene, camera);
});
</script>
</body>
</html>
```