Prompt specification
Build or customize the Three.js 3D scene "Forodhani food-stall setup beside the waterfront" 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: Forodhani food-stall setup beside the waterfront
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/forodhani-food-stall-setup-beside-the-waterfront-x2958
Scene Description Prompt:
Make a voxel Three.js scene in a self-contained HTML file using cdnjs: Forodhani food-stall setup beside the waterfront. Create a compact referenced vignette with original vendor, preparation table, and sea-facing path. Keep food handling, customers, and through-walking space visibly organized.
Working Three.js Starter (forodhani-food-stall-setup-beside-the-waterfront-x2958):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Forodhani — Waterfront Food Stall</title>
<style>
:root {
--ink: #173c44;
--paper: rgba(255, 248, 232, 0.92);
--coral: #e66f55;
--teal: #2b8e91;
--sand: #e9d7ad;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b9dfe1;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.panel {
position: fixed;
z-index: 5;
background: var(--paper);
border: 1px solid rgba(23, 60, 68, 0.15);
box-shadow: 0 12px 38px rgba(18, 61, 66, 0.15);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.intro {
top: 20px;
left: 20px;
width: min(390px, calc(100vw - 40px));
padding: 18px 20px 17px;
border-radius: 18px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 7px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 9px;
height: 9px;
border-radius: 2px;
background: var(--coral);
box-shadow: 4px 0 0 #f2b85c;
}
h1 {
margin: 0;
font-size: clamp(25px, 4vw, 38px);
line-height: 0.98;
letter-spacing: -0.055em;
}
.intro p {
margin: 10px 0 0;
max-width: 330px;
color: rgba(23, 60, 68, 0.72);
font-size: 12px;
line-height: 1.55;
}
.vendor {
display: flex;
align-items: center;
gap: 10px;
margin-top: 13px;
padding-top: 12px;
border-top: 1px solid rgba(23, 60, 68, 0.12);
}
.vendor-swatch {
width: 29px;
height: 29px;
display: grid;
place-items: center;
flex: 0 0 auto;
border-radius: 8px;
background: var(--teal);
color: white;
font-weight: 900;
font-size: 12px;
}
.vendor strong {
display: block;
font-size: 11px;
letter-spacing: 0.02em;
}
.vendor span {
display: block;
margin-top: 2px;
color: rgba(23, 60, 68, 0.58);
font-size: 10px;
}
.views {
left: 50%;
bottom: 20px;
transform: translateX(-50%);
display: flex;
gap: 5px;
padding: 6px;
border-radius: 15px;
}
button {
border: 0;
border-radius: 10px;
padding: 10px 13px;
background: transparent;
color: var(--ink);
font: inherit;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.04em;
cursor: pointer;
transition: background 160ms ease, color 160ms ease, transform 160ms ease;
white-space: nowrap;
}
button:hover { background: rgba(43, 142, 145, 0.1); }
button:active { transform: translateY(1px); }
button.active {
color: #fffaf0;
background: var(--ink);
}
.hint {
right: 20px;
bottom: 20px;
padding: 11px 14px;
border-radius: 13px;
color: rgba(23, 60, 68, 0.66);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
}
.hint b {
color: var(--ink);
margin-right: 5px;
}
.loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #b9dfe1;
transition: opacity 400ms ease, visibility 400ms ease;
}
.loading.hidden {
opacity: 0;
visibility: hidden;
}
.loading div {
padding: 14px 18px;
border-radius: 12px;
background: var(--paper);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
@media (max-width: 760px) {
.intro {
top: 12px;
left: 12px;
width: min(330px, calc(100vw - 24px));
padding: 14px 16px;
}
.intro p { display: none; }
.vendor { margin-top: 9px; padding-top: 9px; }
.views {
bottom: 12px;
width: calc(100vw - 24px);
overflow-x: auto;
justify-content: flex-start;
}
button { padding: 9px 11px; }
.hint { display: none; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive voxel waterfront food-stall scene"></canvas>
<section class="panel intro">
<div class="eyebrow">Friday market vignette</div>
<h1>Forodhani<br>Waterfront Bites</h1>
<p>
A compact island-market scene with protected preparation, an orderly service
counter, a marked queue, and an unobstructed path toward the water.
</p>
<div class="vendor">
<div class="vendor-swatch">A</div>
<div>
<strong>Aru’s Tides — original vendor</strong>
<span>Charcoal fish skewers · coconut buns · lime curry</span>
</div>
</div>
</section>
<nav class="panel views" aria-label="Camera views">
<button class="active" data-view="overview">Overview</button>
<button data-view="counter">Service counter</button>
<button data-view="prep">Food prep</button>
<button data-view="sea">Sea path</button>
</nav>
<div class="panel hint"><b>DRAG</b> orbit · <b>SCROLL</b> zoom</div>
<div class="loading" id="loading"><div>Building the waterfront</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 canvas = document.querySelector("#scene");
const loading = document.querySelector("#loading");
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.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xb9dfe1);
scene.fog = new THREE.Fog(0xb9dfe1, 30, 75);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
140
);
const clock = new THREE.Clock();
const waves = [];
const waveData = [];
// ------------------------------------------------------------------
// Materials and voxel helpers
// ------------------------------------------------------------------
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.84,
metalness: 0
})
);
}
return materialCache.get(color);
}
function box(parent, size, position, color, options = {}) {
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.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
if (options.rotation) mesh.rotation.set(...options.rotation);
parent.add(mesh);
return mesh;
}
function textTexture(lines, background = "#173c44") {
const c = document.createElement("canvas");
c.width = 1024;
c.height = 512;
const ctx = c.getContext("2d");
if (background) {
ctx.fillStyle = background;
ctx.fillRect(0, 0, c.width, c.height);
} else {
ctx.clearRect(0, 0, c.width, c.height);
}
ctx.textAlign = "center";
ctx.textBaseline = "middle";
for (const line of lines) {
ctx.fillStyle = line.color || "#fff8e7";
ctx.font = `${line.weight || 800} ${line.size || 90}px system-ui, sans-serif`;
ctx.fillText(line.text, c.width / 2, line.y || 256);
}
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
function textPanel(
parent,
lines,
size,
position,
rotation = [0, 0, 0],
options = {}
) {
const texture = textTexture(lines, options.background);
const mat = options.basic
? new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
side: THREE.DoubleSide
})
: new THREE.MeshStandardMaterial({
map: texture,
transparent: true,
roughness: 0.8,
side: THREE.DoubleSide
});
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(size[0], size[1]),
mat
);
mesh.position.set(position[0], position[1], position[2]);
mesh.rotation.set(...rotation);
mesh.receiveShadow = false;
parent.add(mesh);
return mesh;
}
function makeArrow(parent, x, z, color = "#287e83") {
const y = 0.115;
box(parent, [0.18, 0.025, 0.92], [x, y, z + 0.12], color, {
castShadow: false
});
box(parent, [0.68, 0.025, 0.18], [x, y, z - 0.27], color, {
castShadow: false
});
box(parent, [0.46, 0.025, 0.18], [x, y, z - 0.44], color, {
castShadow: false
});
box(parent, [0.24, 0.025, 0.18], [x, y, z - 0.61], color, {
castShadow: false
});
}
// ------------------------------------------------------------------
// Lighting
// ------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xdff5f2, 0x9b744f, 2.1));
const sun = new THREE.DirectionalLight(0xfff0cc, 3.2);
sun.position.set(-11, 18, 13);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 50;
sun.shadow.bias = -0.0008;
scene.add(sun);
const stallLight = new THREE.PointLight(0xffbd68, 18, 8, 2);
stallLight.position.set(-3.4, 2.7, 1.2);
scene.add(stallLight);
// ------------------------------------------------------------------
// Water and tiled island platform
// ------------------------------------------------------------------
const seaMaterial = new THREE.MeshStandardMaterial({
color: 0x3c9fa2,
roughness: 0.38,
metalness: 0.08
});
box(
scene,
[90, 0.12, 90],
[0, -0.62, -31],
seaMaterial,
{ castShadow: false }
);
// Main sandstone platform.
box(scene, [18, 1, 12.4], [0, -0.5, 3], 0xcdb88f);
box(scene, [18.4, 0.22, 12.7], [0, -0.18, 3], 0xb49872);
// Individual voxel pavers.
const tileGeometry = new THREE.BoxGeometry(0.96, 0.12, 0.96);
const tileMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.94
});
const tileCount = 18 * 13;
const tiles = new THREE.InstancedMesh(tileGeometry, tileMaterial, tileCount);
tiles.receiveShadow = true;
tiles.castShadow = false;
const matrix = new THREE.Matrix4();
const tileColor = new THREE.Color();
let tileIndex = 0;
for (let ix = 0; ix < 18; ix++) {
for (let iz = 0; iz < 13; iz++) {
const x = -8.5 + ix;
const z = -3 + iz;
matrix.makeTranslation(x, 0.025, z);
tiles.setMatrixAt(tileIndex, matrix);
let base = 0xe7d5ae;
// Clear aqua lane from the market entrance to the dock.
if (x > 2 && x < 5) base = 0xbad4cb;
// Warm customer queue area.
if (x > -4.9 && x < 0.7 && z > 2.2) base = 0xe7c59f;
// Protected preparation zone.
if (x < -4.4 && z < 1.2) base = 0xd9c4a0;
const jitter = (((ix * 17 + iz * 31) % 9) - 4) * 0.006;
tileColor.set(base);
tileColor.offsetHSL(0, 0, jitter);
tiles.setColorAt(tileIndex, tileColor);
tileIndex++;
}
}
tiles.instanceMatrix.needsUpdate = true;
tiles.instanceColor.needsUpdate = true;
scene.add(tiles);
// Animated blocky wave highlights.
const waveMaterial = new THREE.MeshBasicMaterial({
color: 0xbce9df,
transparent: true,
opacity: 0.46,
depthWrite: false
});
for (let i = 0; i < 64; i++) {
const geometry = new THREE.BoxGeometry(1, 0.025, 0.12);
const wave = new THREE.Mesh(geometry, waveMaterial);
const x = (Math.random() - 0.5) * 55;
const z = -5 - Math.random() * 29;
const length = 0.7 + Math.random() * 2.8;
wave.scale.x = length;
wave.position.set(x, -0.39, z);
wave.userData.phase = Math.random() * Math.PI * 2;
wave.userData.baseX = x;
waveData.push(wave);
waves.push(wave);
scene.add(wave);
}
// Seawall, leaving a clear dock entrance.
box(scene, [10.3, 0.6, 0.36], [-3.15, 0.22, -3.12], 0xb69770);
box(scene, [3.3, 0.6, 0.36], [6.85, 0.22, -3.12], 0xb69770);
// Platform railing.
function platformRailing(x1, x2) {
const count = Math.ceil((x2 - x1) / 1.2);
for (let i = 0; i <= count; i++) {
const x = x1 + ((x2 - x1) * i) / count;
box(scene, [0.13, 1.15, 0.13], [x, 0.64, -3.08], 0x36575a);
}
box(scene, [x2 - x1, 0.12, 0.12], [(x1 + x2) / 2, 1.15, -3.08], 0x36575a);
box(scene, [x2 - x1, 0.08, 0.08], [(x1 + x2) / 2, 0.73, -3.08], 0x36575a);
}
platformRailing(-8.25, 1.75);
platformRailing(5.1, 8.25);
// ------------------------------------------------------------------
// Sea-facing dock and path
// ------------------------------------------------------------------
const dock = new THREE.Group();
scene.add(dock);
for (let i = 0; i < 11; i++) {
box(
dock,
[3.25, 0.18, 0.5],
[3.4, 0.02, -3.42 - i * 0.52],
i % 2 ? 0xc49763 : 0xd1a36c
);
}
for (const x of [1.83, 4.97]) {
for (let i = 0; i < 6; i++) {
const z = -3.5 - i * 1.05;
box(dock, [0.12, 1.15, 0.12], [x, 0.58, z], 0x36575a);
box(dock, [0.15, 0.8, 0.15], [x, -0.42, z], 0x6e674f);
}
box(dock, [0.12, 0.12, 5.8], [x, 1.13, -5.8], 0x36575a);
box(dock, [0.09, 0.08, 5.8], [x, 0.72, -5.8], 0x36575a);
}
// Voxel arrows communicate direction without blocking the path.
makeArrow(scene, 3.4, 6.2);
makeArrow(scene, 3.4, 3.2);
makeArrow(scene, 3.4, 0.2);
textPanel(
scene,
[{ text: "SEA WALK", size: 96, y: 256, color: "#225f65" }],
[2.7, 1.35],
[3.4, 0.105, 7.65],
[-Math.PI / 2, 0, 0],
{ background: null, basic: true }
);
// ------------------------------------------------------------------
// Aru's market stall
// ------------------------------------------------------------------
const stall = new THREE.Group();
stall.position.set(-2.8, 0, 0.4);
scene.add(stall);
// Corner posts.
for (const x of [-3.75, 3.35]) {
for (const z of [-1.55, 1.92]) {
box(stall, [0.2, 3.15, 0.2], [x, 1.57, z], 0x7d573b);
}
}
// Low rear storage wall.
box(stall, [6.55, 1.5, 0.16], [0.05, 0.75, -1.55], 0xd7c095);
for (let i = 0; i < 10; i++) {
box(
stall,
[0.55, 1.35, 0.08],
[-3.0 + i * 0.66, 0.72, -1.44],
0xe1cda4
);
}
// Alternating voxel awning.
const stripeCount = 12;
const stripeWidth = 0.63;
for (let i = 0; i < stripeCount; i++) {
const x = -3.48 + i * stripeWidth;
const color = i % 2 ? 0xf4e6c8 : 0x2b8e91;
box(stall, [stripeWidth, 0.18, 4.08], [x, 3.17, 0.12], color);
box(stall, [stripeWidth, 0.42, 0.15], [x, 2.91, 2.14], color);
}
// Roof ridge.
box(stall, [7.65, 0.16, 0.18], [0, 3.34, -1.83], 0xf4e6c8);
// Main sign.
box(stall, [4.65, 0.76, 0.12], [0.3, 2.68, 2.22], 0x173c44);
textPanel(
stall,
[
{ text: "ARU'S TIDES", size: 112, y: 190, color: "#fff4d8" },
{
text: "FORODHANI · FISH & LITTLE BITES",
size: 39,
y: 330,
color: "#f1bc69"
}
],
[4.5, 0.68],
[0.3, 2.68, 2.29]
);
// Counter body and worktop.
box(stall, [4.85, 0.98, 1.04], [0.62, 0.52, 1.22], 0xc9624e);
box(stall, [5.08, 0.16, 1.24], [0.62, 1.09, 1.22], 0x714a36);
// Decorative front boards.
for (let i = 0; i < 12; i++) {
box(
stall,
[0.32, 0.75, 0.07],
[-1.55 + i * 0.38, 0.48, 1.77],
i % 2 ? 0xd96b53 : 0xbe5647
);
}
textPanel(
stall,
[{ text: "ORDER", size: 80, y: 256, color: "#fff2d5" }],
[1.35, 0.48],
[-0.55, 0.55, 1.815]
);
textPanel(
stall,
[{ text: "PICK UP", size: 70, y: 256, color: "#fff2d5" }],
[1.55, 0.48],
[1.78, 0.55, 1.815]
);
// Protected food display.
const glassMaterial = new THREE.MeshStandardMaterial({
color: 0xc7eee9,
transparent: true,
opacity: 0.22,
roughness: 0.18,
metalness: 0.02,
depthWrite: false
});
box(stall, [4.55, 0.86, 0.035], [0.62, 1.58, 1.76], glassMaterial, {
castShadow: false
});
box(stall, [4.65, 0.07, 0.08], [0.62, 2.02, 1.76], 0x6f8884);
box(stall, [0.07, 0.9, 0.08], [-1.65, 1.56, 1.76], 0x6f8884);
box(stall, [0.07, 0.9, 0.08], [2.9, 1.56, 1.76], 0x6f8884);
// Food trays.
box(stall, [1.45, 0.08, 0.65], [0.0, 1.22, 1.18], 0x364f52);
for (let i = 0; i < 4; i++) {
const x = -0.48 + i * 0.31;
box(stall, [0.23, 0.11, 0.16], [x, 1.31, 1.18], 0xd9a66f);
box(stall, [0.18, 0.03, 0.13], [x, 1.38, 1.18], 0x704a31);
}
// Coconut buns.
box(stall, [1.05, 0.07, 0.62], [1.33, 1.21, 1.18], 0x6b5550);
for (let i = 0; i < 3; i++) {
box(stall, [0.27, 0.2, 0.3], [1.02 + i * 0.31, 1.33, 1.18], 0xe7b875);
box(stall, [0.1, 0.035, 0.1], [1.02 + i * 0.31, 1.45, 1.18], 0xf5e2b7);
}
// Lime-curry tray.
box(stall, [0.95, 0.08, 0.62], [2.37, 1.21, 1.18], 0x746052);
for (let i = 0; i < 4; i++) {
box(
stall,
[0.18, 0.13, 0.18],
[2.08 + (i % 2) * 0.26, 1.31, 1.05 + Math.floor(i / 2) * 0.27],
i % 2 ? 0xe4ad42 : 0x6f9a48
);
}
// Condiment and serving station.
box(stall, [0.34, 0.35, 0.3], [2.82, 1.34, 0.72], 0x416f68);
box(stall, [0.25, 0.18, 0.23], [2.24, 1.29, 0.69], 0xe6c55f);
box(stall, [0.06, 0.42, 0.06], [2.82, 1.61, 0.72], 0xe9e4d4);
// ------------------------------------------------------------------
// Protected preparation area
// ------------------------------------------------------------------
const prep = new THREE.Group();
prep.position.set(-3.65, 0, -0.46);
stall.add(prep);
box(prep, [2.15, 0.14, 1.05], [0, 1.05, 0], 0xaab8b4);
box(prep, [0.12, 1.0, 0.12], [-0.9, 0.5, -0.36], 0x526968);
box(prep, [0.12, 1.0, 0.12], [0.9, 0.5, -0.36], 0x526968);
box(prep, [0.12, 1.0, 0.12], [-0.9, 0.5, 0.36], 0x526968);
box(prep, [0.12, 1.0, 0.12], [0.9, 0.5, 0.36], 0x526968);
// Cutting board, fish pieces, bowl, and knife.
box(prep, [1.05, 0.06, 0.56], [-0.32, 1.16, 0.02], 0xa76f45);
box(prep, [0.34, 0.12, 0.18], [-0.5, 1.25, 0.02], 0xe6c8a3);
box(prep, [0.27, 0.1, 0.16], [-0.08, 1.24, 0.07], 0xe6c8a3);
box(prep, [0.45, 0.16, 0.38], [0.55, 1.2, -0.03], 0xd2ddd2);
box(prep, [0.42, 0.04, 0.09], [0.52, 1.31, 0.18], 0xd7e0df);
box(prep, [0.15, 0.05, 0.08], [0.78, 1.31, 0.18], 0x5e4a37);
// Low rail separating prep from the public side.
for (const z of [-1.18, 0.55]) {
box(stall, [0.1, 1.18, 0.1], [-2.38, 0.59, z], 0x4a6d6d);
}
box(stall, [0.09, 0.09, 1.82], [-2.38, 1.14, -0.315], 0x4a6d6d);
textPanel(
stall,
[{ text: "STAFF / PREP", size: 66, y: 256, color: "#d8eee7" }],
[1.45, 0.36],
[-3.65, 1.6, -1.38]
);
// ------------------------------------------------------------------
// Original vendor and customers
// ------------------------------------------------------------------
function createPerson({
skin = 0x9b603f,
shirt = 0x4f8a91,
trousers = 0x354e59,
hair = 0x302b2a,
scarf = null,
apron = null,
carryCup = false,
carryBag = false,
scale = 1
} = {}) {
const g = new THREE.Group();
// Legs and shoes.
box(g, [0.25, 0.67, 0.29], [-0.19, 0.39, 0], trousers);
box(g, [0.25, 0.67, 0.29], [0.19, 0.39, 0], trousers);
box(g, [0.29, 0.14, 0.42], [-0.19, 0.08, 0.08], 0x29383c);
box(g, [0.29, 0.14, 0.42], [0.19, 0.08, 0.08], 0x29383c);
// Torso.
box(g, [0.72, 0.82, 0.43], [0, 1.15, 0], shirt);
box(g, [0.76, 0.12, 0.47], [0, 0.78, 0], trousers);
// Head, hair, and face.
box(g, [0.48, 0.5, 0.46], [0, 1.87, 0], skin);
box(g, [0.51, 0.17, 0.49], [0, 2.1, -0.015], hair);
box(g, [0.5, 0.36, 0.16], [0, 1.94, -0.19], hair);
box(g, [0.06, 0.07, 0.035], [-0.1, 1.91, 0.247], 0x202a2c);
box(g, [0.06, 0.07, 0.035], [0.1, 1.91, 0.247], 0x202a2c);
box(g, [0.07, 0.05, 0.045], [0, 1.81, 0.25], skin);
if (scarf) {
box(g, [0.57, 0.14, 0.56], [0, 2.12, 0], scarf);
box(g, [0.14, 0.42, 0.5], [-0.245, 1.94, -0.02], scarf);
box(g, [0.14, 0.42, 0.5], [0.245, 1.94, -0.02], scarf);
box(g, [0.43, 0.45, 0.12], [0, 1.96, -0.25], scarf);
}
// Arms.
box(g, [0.21, 0.58, 0.24], [-0.48, 1.22, 0.02], shirt);
box(g, [0.21, 0.58, 0.24], [0.48, 1.22, 0.02], shirt);
box(g, [0.2, 0.19, 0.47], [-0.48, 1.12, 0.26], skin);
box(g, [0.2, 0.19, 0.47], [0.48, 1.12, 0.26], skin);
if (apron) {
box(g, [0.58, 0.67, 0.11], [0, 1.06, 0.275], apron);
box(g, [0.32, 0.19, 0.05], [0, 1.02, 0.345], 0xe7ddbf);
box(g, [0.45, 0.09, 0.12], [0, 1.4, 0.265], apron);
}
if (carryCup) {
box(g, [0.22, 0.29, 0.22], [0.49, 1.29, 0.51], 0xf4e6c8);
box(g, [0.22, 0.035, 0.22], [0.49, 1.45, 0.51], 0xd46c52);
}
if (carryBag) {
box(g, [0.38, 0.42, 0.23], [0.51, 0.82, 0.26], 0xc58b5e);
box(g, [0.24, 0.07, 0.05], [0.51, 1.04, 0.26], 0x815a43);
}
g.scale.setScalar(scale);
return g;
}
const vendor = createPerson({
skin: 0x8d5138,
shirt: 0xf1c35d,
trousers: 0x314e57,
hair: 0x2b2526,
scarf: 0xe46c56,
apron: 0x277d82
});
vendor.position.set(-1.35, 0, -0.3);
stall.add(vendor);
// Small original name badge.
box(vendor, [0.22, 0.13, 0.035], [-0.15, 1.31, 0.34], 0xf6e8ca);
textPanel(
vendor,
[{ text: "ARU", size: 90, y: 256, color: "#173c44" }],
[0.18, 0.085],
[-0.15, 1.31, 0.363]
);
// Customer at the order point.
const orderingCustomer = createPerson({
skin: 0xc98962,
shirt: 0x397e89,
trousers: 0xe2d3b2,
hair: 0x3c2925,
carryCup: true
});
orderingCustomer.position.set(-2.1, 0, 2.9);
orderingCustomer.rotation.y = Math.PI;
scene.add(orderingCustomer);
// Customer waiting in the marked queue.
const waitingCustomer = createPerson({
skin: 0x6f4633,
shirt: 0xf0a95e,
trousers: 0x4a5d63,
hair: 0x1e2224,
carryBag: true
});
waitingCustomer.position.set(-2.1, 0, 4.45);
waitingCustomer.rotation.y = Math.PI;
scene.add(waitingCustomer);
// Passing customer uses the separate lane without blocking the queue.
const passingCustomer = createPerson({
skin: 0xb87851,
shirt: 0xd85f4d,
trousers: 0x2f4b55,
hair: 0x43312b,
carryBag: true,
scale: 0.98
});
passingCustomer.position.set(3.4, 0, 5.35);
passingCustomer.rotation.y = Math.PI;
scene.add(passingCustomer);
// ------------------------------------------------------------------
// Queue and floor organization
// ------------------------------------------------------------------
// Marked waiting pads.
for (const z of [2.9, 4.45]) {
box(scene, [1.45, 0.025, 1.0], [-2.1, 0.115, z], 0xf0a66f, {
castShadow: false
});
box(scene, [1.2, 0.03, 0.76], [-2.1, 0.135, z], 0xe9c99b, {
castShadow: false
});
}
// Queue stanchions keep waiting customers out of the path.
for (const x of [-4.85, 0.65]) {
for (const z of [2.6, 4.05, 5.5]) {
box(scene, [0.1, 1.2, 0.1], [x, 0.6, z], 0x36575a);
box(scene, [0.24, 0.1, 0.24], [x, 1.2, z], 0xf0b45e);
}
box(scene, [0.07, 0.07, 2.95], [x, 1.02, 4.05], 0xc85e4b);
}
textPanel(
scene,
[{ text: "WAIT HERE", size: 85, y: 256, color: "#8a4b3c" }],
[2.2, 1.1],
[-2.1, 0.16, 5.95],
[-Math.PI / 2, 0, 0],
{ background: null, basic: true }
);
// ------------------------------------------------------------------
// Side seating and useful market details
// ------------------------------------------------------------------
const seating = new THREE.Group();
seating.position.set(6.35, 0, 4.0);
scene.add(seating);
box(seating, [1.6, 0.14, 1.1], [0, 0.95, 0], 0xa97a4d);
box(seating, [0.12, 0.9, 0.12], [-0.6, 0.45, -0.35], 0x59675d);
box(seating, [0.12, 0.9, 0.12], [0.6, 0.45, -0.35], 0x59675d);
box(seating, [0.12, 0.9, 0.12], [-0.6, 0.45, 0.35], 0x59675d);
box(seating, [0.12, 0.9, 0.12], [0.6, 0.45, 0.35], 0x59675d);
for (const x of [-1.35, 1.35]) {
box(seating, [0.7, 0.18, 0.7], [x, 0.58, 0], 0x557d76);
box(seating, [0.45, 0.55, 0.45], [x, 0.28, 0], 0x3f625d);
}
// Small crate stack behind the seating.
function crate(parent, x, z) {
box(parent, [0.9, 0.12, 0.7], [x, 0.18, z], 0xa57448);
for (let i = 0; i < 4; i++) {
box(parent, [0.13, 0.55, 0.7], [x - 0.36 + i * 0.24, 0.48, z], 0xc08b57);
}
box(parent, [0.9, 0.12, 0.7], [x, 0.78, z], 0xa57448);
}
crate(scene, 7.3, 1.35);
crate(scene, 7.3, 0.5);
// ------------------------------------------------------------------
// Voxel palms
// ------------------------------------------------------------------
function makePalm(x, z, scale = 1) {
const g = new THREE.Group();
g.position.set(x, 0, z);
g.scale.setScalar(scale);
scene.add(g);
const trunkColors = [0x8f6843, 0x9d744b, 0xaa7e51];
for (let i = 0; i < 6; i++) {
box(
g,
[0.36 - i * 0.018, 0.64, 0.36 - i * 0.018],
[i * 0.045, 0.32 + i * 0.59, i * 0.02],
trunkColors[i % 3]
);
}
const topY = 3.85;
const leafColors = [0x407b55, 0x4d8c5e, 0x356b4d];
for (let i = 0; i < 7; i++) {
const angle = (i / 7) * Math.PI * 2;
const leaf = box(
g,
[2.15, 0.17, 0.36],
[Math.sin(angle) * 0.93, topY, Math.cos(angle) * 0.93],
leafColors[i % leafColors.length]
);
leaf.rotation.y = angle;
leaf.rotation.z = (i % 2 ? 1 : -1) * 0.08;
const tip = box(
g,
[1.05, 0.13, 0.25],
[Math.sin(angle) * 1.78, topY - 0.18, Math.cos(angle) * 1.78],
leafColors[(i + 1) % leafColors.length]
);
tip.rotation.y = angle;
tip.rotation.z = (i % 2 ? 1 : -1) * 0.17;
}
box(g, [0.34, 0.34, 0.34], [0.18, 3.62, 0.08], 0x75502f);
box(g, [0.31, 0.31, 0.31], [-0.15, 3.58, 0.18], 0x75502f);
}
makePalm(-7.2, -1.65, 0.92);
makePalm(7.05, -1.72, 0.82);
// ------------------------------------------------------------------
// Distant voxel boat and shoreline
// ------------------------------------------------------------------
const boat = new THREE.Group();
boat.position.set(8.2, -0.35, -15.5);
boat.rotation.y = -0.45;
scene.add(boat);
box(boat, [4.2, 0.42, 1.45], [0, 0, 0], 0x83513b);
box(boat, [3.35, 0.32, 1.15], [0, 0.32, 0], 0xb47745);
box(boat, [0.13, 4.8, 0.13], [-0.35, 2.35, 0], 0x5b4a39);
box(boat, [1.35, 2.4, 0.08], [0.35, 2.6, 0], 0xe9d9b5);
box(boat, [1.1, 1.6, 0.08], [0.3, 2.15, 0.03], 0xd96c50);
box(boat, [2.5, 0.16, 0.16], [0, 0.48, 0], 0x5b4a39);
// Distant low island blocks.
for (let i = 0; i < 16; i++) {
const x = -21 + i * 2.8;
const h = 0.7 + ((i * 7) % 5) * 0.3;
box(
scene,
[3.0 + (i % 3) * 0.5, h, 2.6],
[x, -0.45 + h / 2, -31 - (i % 3) * 1.2],
i % 2 ? 0x658775 : 0x78947e,
{ castShadow: false }
);
}
// A few buoys to give scale to the water.
for (const [x, z] of [[-7, -11], [11, -18], [-16, -20]]) {
box(scene, [0.32, 0.55, 0.32], [x, -0.04, z], 0xef7253);
box(scene, [0.42, 0.12, 0.42], [x, 0.27, z], 0xfff0cf);
}
// ------------------------------------------------------------------
// Direct camera controls: orbit, zoom, and view presets
// ------------------------------------------------------------------
class CameraRig {
constructor(camera, element) {
this.camera = camera;
this.element = element;
this.target = new THREE.Vector3(-0.2, 1.1, 1.2);
this.goalTarget = this.target.clone();
this.spherical = new THREE.Spherical(20.5, 1.02, 0.73);
this.goal = this.spherical.clone();
this.dragging = false;
this.pointerX = 0;
this.pointerY = 0;
this.apply(true);
element.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
this.dragging = true;
this.pointerX = event.clientX;
this.pointerY = event.clientY;
element.setPointerCapture(event.pointerId);
element.style.cursor = "grabbing";
});
element.addEventListener("pointermove", (event) => {
if (!this.dragging) return;
const dx = event.clientX - this.pointerX;
const dy = event.clientY - this.pointerY;
this.pointerX = event.clientX;
this.pointerY = event.clientY;
this.goal.theta -= dx * 0.006;
this.goal.phi = THREE.MathUtils.clamp(
this.goal.phi - dy * 0.005,
0.48,
1.36
);
});
const stopDrag = (event) => {
this.dragging = false;
if (element.hasPointerCapture(event.pointerId)) {
element.releasePointerCapture(event.pointerId);
}
element.style.cursor = "grab";
};
element.addEventListener("pointerup", stopDrag);
element.addEventListener("pointercancel", stopDrag);
element.addEventListener("pointerleave", (event) => {
if (this.dragging) stopDrag(event);
});
element.addEventListener(
"wheel",
(event) => {
event.preventDefault();
this.goal.radius = THREE.MathUtils.clamp(
this.goal.radius * Math.exp(event.deltaY * 0.001),
7,
32
);
},
{ passive: false }
);
element.style.cursor = "grab";
}
setView(name, instant = false) {
const views = {
overview: {
target: [-0.2, 1.1, 1.2],
radius: 20.5,
phi: 1.02,
theta: 0.73
},
counter: {
target: [-2.1, 1.2, 1.2],
radius: 10.3,
phi: 1.12,
theta: 0.36
},
prep: {
target: [-5.3, 1.0, 0.1],
radius: 8.2,
phi: 1.13,
theta: 0.78
},
sea: {
target: [3.4, 0.5, -2.3],
radius: 12.3,
phi: 1.06,
theta: 0.22
}
};
const view = views[name] || views.overview;
this.goalTarget.set(...view.target);
this.goal.radius = view.radius;
this.goal.phi = view.phi;
this.goal.theta = view.theta;
if (instant) {
this.target.copy(this.goalTarget);
this.spherical.copy(this.goal);
this.apply(true);
}
}
apply() {
const offset = new THREE.Vector3().setFromSpherical(this.spherical);
this.camera.position.copy(this.target).add(offset);
this.camera.lookAt(this.target);
}
update(dt) {
const easing = 1 - Math.exp(-dt * 8);
this.target.lerp(this.goalTarget, easing);
this.spherical.radius = THREE.MathUtils.lerp(
this.spherical.radius,
this.goal.radius,
easing
);
this.spherical.phi = THREE.MathUtils.lerp(
this.spherical.phi,
this.goal.phi,
easing
);
this.spherical.theta = THREE.MathUtils.lerp(
this.spherical.theta,
this.goal.theta,
easing
);
this.apply();
}
}
const rig = new CameraRig(camera, canvas);
document.querySelectorAll("[data-view]").forEach((button) => {
button.addEventListener("click", () => {
document.querySelectorAll("[data-view]").forEach((b) => b.classList.remove("active"));
button.classList.add("active");
rig.setView(button.dataset.view);
});
});
// ------------------------------------------------------------------
// Animation and resize
// ------------------------------------------------------------------
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
const time = clock.elapsedTime;
waveData.forEach((wave, i) => {
const phase = wave.userData.phase;
wave.position.x = wave.userData.baseX + Math.sin(time * 0.6 + phase) * 0.18;
wave.position.y = -0.39 + Math.sin(time * 0.9 + phase) * 0.025;
wave.rotation.y = Math.sin(time * 0.15 + i) * 0.04;
});
// Very subtle queue and passing motion.
orderingCustomer.position.y = 0.01 + Math.sin(time * 1.8) * 0.006;
waitingCustomer.position.y = 0.01 + Math.sin(time * 1.6 + 1) * 0.005;
passingCustomer.position.z = 5.35 - Math.sin(time * 0.42) * 0.28;
passingCustomer.position.y = 0.01 + Math.abs(Math.sin(time * 3.2)) * 0.025;
rig.update(dt);
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
// Let the first frame appear before dismissing the loading card.
requestAnimationFrame(() => {
requestAnimationFrame(() => loading.classList.add("hidden"));
});
</script>
</body>
</html>
```