Prompt specification
Build or customize the Three.js 3D scene "Supplier entering a London market service lane" 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: Supplier entering a London market service lane
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/supplier-entering-a-london-market-service-lane-x2842
Scene Description Prompt:
I'd like to see this as a voxel Three.js scene: Supplier entering a London market service lane. Create a compact Borough Market-inspired vignette with handcart, loading doorway, and shoppers. Keep the delivery route distinct from the main pedestrian aisle. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (supplier-entering-a-london-market-service-lane-x2842):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Borough Market — Voxel Service Lane</title>
<style>
:root {
color-scheme: light;
--ink: #172521;
--paper: #f5f0df;
--green: #245a45;
--yellow: #f3c84b;
--slate: #617b7d;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dbe5df;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid rgba(255,255,255,.55);
background: rgba(247,243,228,.9);
color: var(--ink);
box-shadow: 0 10px 30px rgba(30,45,38,.16);
backdrop-filter: blur(10px);
}
.title-card {
top: 18px;
left: 18px;
width: min(355px, calc(100vw - 36px));
padding: 16px 18px 14px;
border-radius: 14px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 5px;
color: var(--green);
font-size: 11px;
font-weight: 800;
letter-spacing: .16em;
text-transform: uppercase;
}
.live-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #e15b3d;
box-shadow: 0 0 0 4px rgba(225,91,61,.14);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(24px, 3vw, 34px);
font-weight: 700;
line-height: 1;
letter-spacing: -.025em;
}
.subtitle {
margin: 8px 0 13px;
color: #53645e;
font-size: 12px;
line-height: 1.45;
}
.legend {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
padding-top: 11px;
border-top: 1px solid rgba(23,37,33,.12);
}
.legend-item {
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
font-size: 11px;
font-weight: 700;
}
.swatch {
flex: 0 0 auto;
width: 17px;
height: 12px;
border-radius: 3px;
border: 1px solid rgba(0,0,0,.1);
}
.swatch.aisle { background: #c8b99b; }
.swatch.route { background: var(--slate); position: relative; }
.swatch.route::after {
content: "";
position: absolute;
left: 7px;
top: 2px;
width: 3px;
height: 8px;
background: var(--yellow);
}
.controls {
right: 18px;
bottom: 18px;
padding: 10px 12px;
border-radius: 12px;
color: #40534c;
font-size: 11px;
line-height: 1.55;
text-align: right;
}
.controls strong { color: var(--ink); }
#reset {
position: fixed;
z-index: 11;
top: 18px;
right: 18px;
padding: 9px 12px;
border: 1px solid rgba(255,255,255,.65);
border-radius: 10px;
background: rgba(247,243,228,.92);
color: var(--ink);
font: 800 11px ui-sans-serif, system-ui, sans-serif;
letter-spacing: .08em;
text-transform: uppercase;
cursor: pointer;
box-shadow: 0 8px 22px rgba(30,45,38,.13);
}
#reset:hover { background: #fffaf0; }
#reset:active { transform: translateY(1px); }
@media (max-width: 650px) {
.title-card { top: 10px; left: 10px; padding: 13px; width: min(310px, calc(100vw - 20px)); }
.legend { gap: 5px; }
.legend-item { font-size: 10px; }
.subtitle { margin-bottom: 10px; }
.controls { display: none; }
#reset { top: auto; right: 10px; bottom: 10px; }
}
</style>
</head>
<body>
<section class="panel title-card" aria-label="Scene information">
<div class="eyebrow"><span class="live-dot"></span> Voxel market vignette</div>
<h1>Borough service lane</h1>
<p class="subtitle">A supplier pushes a loaded handcart toward the brick loading bay while shoppers remain in the pedestrian aisle.</p>
<div class="legend">
<div class="legend-item"><span class="swatch aisle"></span> Pedestrian aisle</div>
<div class="legend-item"><span class="swatch route"></span> Delivery route</div>
</div>
</section>
<button id="reset" type="button">Reset view</button>
<div class="panel controls">
<strong>Drag</strong> orbit · <strong>Wheel</strong> zoom<br>
<strong>Shift + drag</strong> pan · <strong>Arrows</strong> rotate
</div>
<script type="module">
import * as THREE from 'https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js';
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdbe5df);
scene.fog = new THREE.Fog(0xdbe5df, 19, 38);
const renderer = new THREE.WebGLRenderer({ antialias: true, powerPreference: 'high-performance' });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
document.body.prepend(renderer.domElement);
const camera = new THREE.OrthographicCamera(-10, 10, 7, -7, 0.1, 100);
const target = new THREE.Vector3(0, 1.05, -0.25);
const spherical = { yaw: 0.66, pitch: 0.79, radius: 15.5 };
const materialCache = new Map();
const tempObject = new THREE.Object3D();
function material(color, options = {}) {
const key = `${color}|${JSON.stringify(options)}`;
if (!materialCache.has(key)) {
materialCache.set(key, new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0,
...options
}));
}
return materialCache.get(key);
}
function box(parent, w, h, d, color, x = 0, y = 0, z = 0, options = {}) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
material(color, options)
);
mesh.position.set(x, y, z);
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
parent.add(mesh);
return mesh;
}
function canvasTexture(title, subtitle, background = '#f3edda', foreground = '#183c30', accent = '#d8583c') {
const canvas = document.createElement('canvas');
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext('2d');
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = foreground;
ctx.lineWidth = 12;
ctx.strokeRect(12, 12, canvas.width - 24, canvas.height - 24);
ctx.fillStyle = accent;
ctx.fillRect(36, 36, 18, 184);
ctx.fillRect(970, 36, 18, 184);
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillStyle = foreground;
let size = 80;
ctx.font = `800 ${size}px Arial`;
while (ctx.measureText(title).width > 820 && size > 34) {
size -= 2;
ctx.font = `800 ${size}px Arial`;
}
ctx.fillText(title, 512, subtitle ? 105 : 128);
if (subtitle) {
ctx.font = '700 29px Arial';
ctx.fillStyle = '#52665d';
ctx.fillText(subtitle, 512, 184);
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
function makeSign(parent, title, subtitle, x, y, z, w, h, rotationY = 0, colors = {}) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotationY;
parent.add(group);
box(group, w, h, 0.13, colors.board || '#173b31', 0, 0, 0);
const face = new THREE.Mesh(
new THREE.PlaneGeometry(w - 0.08, h - 0.08),
new THREE.MeshBasicMaterial({
map: canvasTexture(
title,
subtitle,
colors.background || '#f3edda',
colors.foreground || '#183c30',
colors.accent || '#d8583c'
),
toneMapped: false
})
);
face.position.z = 0.071;
group.add(face);
return group;
}
// Lighting
scene.add(new THREE.HemisphereLight(0xe8f2eb, 0x756b56, 2.1));
const sun = new THREE.DirectionalLight(0xfff0d2, 3.1);
sun.position.set(7, 12, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -13;
sun.shadow.camera.right = 13;
sun.shadow.camera.top = 13;
sun.shadow.camera.bottom = -13;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xbfd7db, 0.75);
fill.position.set(-8, 6, -4);
scene.add(fill);
// Base and paving
box(scene, 15.2, 0.55, 13.2, '#6d7568', 0, -0.31, 0);
box(scene, 14.8, 0.12, 12.8, '#a9a38f', 0, -0.02, 0);
// Warm pedestrian aisle
box(scene, 5.55, 0.16, 11.65, '#cbbb9d', -2.05, 0.08, 0.05);
for (let z = -5.2; z <= 5.3; z += 1.05) {
box(scene, 5.4, 0.025, 0.035, '#aa9b82', -2.05, 0.175, z);
}
for (let x = -4.55; x < 0.5; x += 1.0) {
box(scene, 0.035, 0.025, 11.45, '#aa9b82', x, 0.176, 0.05);
}
// Cool, visually separate delivery lane
box(scene, 5.75, 0.13, 11.7, '#647d7d', 3.48, 0.065, 0.05);
// Lane edges and dashed route
box(scene, 0.10, 0.035, 11.45, '#e7dfbd', 5.98, 0.145, 0.05);
for (let z = -5.1; z <= 5.5; z += 1.15) {
box(scene, 0.13, 0.035, 0.64, '#f1c84a', 3.35, 0.15, z);
}
// Raised separator curb and bollards
box(scene, 0.24, 0.34, 10.55, '#ddd3b8', 0.54, 0.18, 0.48);
box(scene, 0.28, 0.08, 10.58, '#f0e6cc', 0.54, 0.36, 0.48);
for (const z of [4.5, 1.0, -2.5, -4.45]) {
box(scene, 0.22, 0.82, 0.22, '#263b37', 0.78, 0.55, z);
box(scene, 0.24, 0.16, 0.24, '#f1c84a', 0.78, 0.72, z);
}
// Pixel arrows pointing toward the loading bay
function laneArrow(z) {
const group = new THREE.Group();
group.position.set(3.35, 0.18, z);
scene.add(group);
box(group, 0.15, 0.035, 0.75, '#f1c84a', 0, 0, 0.28);
box(group, 0.23, 0.035, 0.24, '#f1c84a', 0, 0, -0.35);
box(group, 0.23, 0.035, 0.24, '#f1c84a', -0.22, 0, -0.17);
box(group, 0.23, 0.035, 0.24, '#f1c84a', 0.22, 0, -0.17);
box(group, 0.23, 0.035, 0.24, '#f1c84a', -0.43, 0, 0.01);
box(group, 0.23, 0.035, 0.24, '#f1c84a', 0.43, 0, 0.01);
}
laneArrow(3.7);
laneArrow(0.55);
laneArrow(-2.65);
// Market hall facade
box(scene, 7.65, 4.35, 0.82, '#29483e', -2.7, 2.18, -5.45);
box(scene, 7.95, 0.24, 1.04, '#183b32', -2.7, 4.40, -5.37);
box(scene, 7.8, 0.18, 0.96, '#d8ccb0', -2.7, 0.12, -5.35);
// Market facade windows
for (const x of [-5.35, -3.55, -1.65]) {
box(scene, 1.18, 1.35, 0.10, '#d8cfb5', x, 2.34, -4.99);
box(scene, 0.91, 1.08, 0.12, '#182d2a', x, 2.34, -4.92);
box(scene, 0.075, 1.08, 0.14, '#d8cfb5', x, 2.34, -4.84);
}
makeSign(
scene,
'BOROUGH MARKET',
'PRODUCE • FOOD HALL • FLOWERS',
-2.72, 3.67, -4.93,
6.65, 0.92
);
// Brick loading-bay building with a real opening
box(scene, 1.18, 4.38, 0.82, '#9c513c', 1.65, 2.19, -5.45);
box(scene, 1.52, 4.38, 0.82, '#9c513c', 6.06, 2.19, -5.45);
box(scene, 3.08, 1.08, 0.82, '#9c513c', 3.78, 3.84, -5.45);
box(scene, 0.25, 4.48, 4.2, '#8e4938', 6.84, 2.24, -3.45);
box(scene, 6.25, 0.24, 1.15, '#34463e', 3.90, 4.46, -5.38);
// Dark interior visible through the opening
box(scene, 3.02, 3.30, 0.12, '#15211f', 3.78, 1.65, -5.64);
box(scene, 3.00, 0.12, 1.4, '#4e554a', 3.78, 0.22, -5.08);
// Brick courses
const brickColors = ['#a95942', '#934b39', '#ad6248', '#894536'];
let brickIndex = 0;
for (let row = 0; row < 15; row++) {
const y = 0.18 + row * 0.285;
for (let x = 0.96; x <= 6.72; x += 0.51) {
const inDoor = x > 2.17 && x < 5.39 && y < 3.32;
if (inDoor) continue;
box(
scene,
0.46,
0.22,
0.065,
brickColors[(brickIndex++ + row) % brickColors.length],
x + (row % 2 ? 0.10 : 0),
y,
-4.99
);
}
}
// Loading-bay frame
box(scene, 0.16, 3.34, 0.16, '#e2d5b7', 2.18, 1.67, -4.90);
box(scene, 0.16, 3.34, 0.16, '#e2d5b7', 5.39, 1.67, -4.90);
box(scene, 3.38, 0.16, 0.16, '#e2d5b7', 3.78, 3.34, -4.90);
// Partly lowered roller shutter
for (let i = 0; i < 6; i++) {
box(scene, 2.97, 0.17, 0.12, i % 2 ? '#b8aa8d' : '#c9bba0', 3.78, 2.42 + i * 0.17, -5.30);
}
makeSign(
scene,
'LOADING BAY 2',
'DELIVERIES • AUTHORISED ACCESS',
3.78, 3.84, -4.89,
2.75, 0.73,
0,
{ background: '#f0e6cf', foreground: '#64362b', accent: '#f0ad38' }
);
// Roof vents
box(scene, 0.95, 0.54, 0.85, '#59635c', 5.15, 4.78, -5.35);
box(scene, 0.55, 0.18, 0.62, '#39443f', 5.15, 5.10, -5.35);
// Crates stacked beside the doorway, outside the main route
function crate(parent, x, y, z, w = 0.75, h = 0.55, d = 0.65) {
const g = new THREE.Group();
g.position.set(x, y, z);
parent.add(g);
box(g, w, h, d, '#8d5d38', 0, h / 2, 0);
box(g, w + 0.03, 0.08, d + 0.03, '#b87d47', 0, h * 0.82, 0);
box(g, w + 0.03, 0.08, d + 0.03, '#b87d47', 0, h * 0.18, 0);
box(g, 0.08, h + 0.02, d + 0.04, '#c08a50', -w * 0.32, h / 2, 0);
box(g, 0.08, h + 0.02, d + 0.04, '#c08a50', w * 0.32, h / 2, 0);
return g;
}
crate(scene, 6.13, 0.18, -4.42, 0.72, 0.48, 0.65);
crate(scene, 6.13, 0.68, -4.42, 0.68, 0.44, 0.60);
crate(scene, 6.18, 0.18, -3.58, 0.64, 0.48, 0.58);
// Market stalls
function createStall(z, title, stripeA, stripeB, produceColors) {
const stall = new THREE.Group();
stall.position.set(-5.42, 0.16, z);
scene.add(stall);
// Counter and legs
box(stall, 1.45, 0.96, 2.92, '#334e43', 0, 0.50, 0);
box(stall, 1.62, 0.14, 3.08, '#b98a54', 0, 1.04, 0);
box(stall, 1.50, 0.16, 3.04, '#6b4934', 0, 0.12, 0);
// Back shelving
box(stall, 0.18, 1.70, 2.82, '#526b59', -0.75, 1.25, 0);
// Awning posts
for (const zz of [-1.43, 1.43]) {
box(stall, 0.11, 2.55, 0.11, '#263c34', 1.03, 1.28, zz);
box(stall, 0.11, 2.55, 0.11, '#263c34', -1.00, 1.28, zz);
}
// Striped canopy
for (let i = 0; i < 7; i++) {
const zz = -1.35 + i * 0.45;
box(stall, 2.22, 0.17, 0.45, i % 2 ? stripeA : stripeB, 0.02, 2.57, zz);
box(stall, 0.12, 0.32, 0.45, i % 2 ? stripeA : stripeB, 1.10, 2.39, zz);
}
// Produce bins and blocky fruit
for (let row = 0; row < 3; row++) {
for (const px of [-0.38, 0.36]) {
const zz = -0.91 + row * 0.91;
box(stall, 0.61, 0.25, 0.68, '#75492f', px, 1.22, zz);
for (let ix = 0; ix < 2; ix++) {
for (let iz = 0; iz < 2; iz++) {
const color = produceColors[(row + ix + iz) % produceColors.length];
box(
stall,
0.19,
0.19,
0.20,
color,
px - 0.13 + ix * 0.26,
1.43,
zz - 0.15 + iz * 0.30
);
}
}
}
}
makeSign(
stall,
title,
'MARKET STALL',
1.16,
2.13,
0,
2.48,
0.56,
Math.PI / 2,
{ background: '#f3e8cb', foreground: '#244538', accent: stripeA }
);
}
createStall(-3.35, 'FRESH PRODUCE', '#cf5b3f', '#f0dfb9', ['#d84735', '#e7a62d', '#6d9d45', '#8fbc4c']);
createStall(-0.12, 'BREAD & CAKES', '#2f7153', '#ead8ad', ['#c67a3f', '#e3b65b', '#9d4f31']);
createStall(3.08, 'FLOWERS', '#bb4d55', '#f0dfb9', ['#e35b67', '#f3c94e', '#f1eee0', '#a85b97']);
// Voxel people
const people = [];
function createPerson({
x,
z,
coat = '#496b83',
trousers = '#344354',
skin = '#c98762',
hair = '#3a2e28',
rotation = 0,
bagColor = '#9b613f',
supplier = false,
phase = 0
}) {
const root = new THREE.Group();
root.position.set(x, 0.16, z);
root.rotation.y = rotation;
scene.add(root);
const legL = new THREE.Group();
const legR = new THREE.Group();
legL.position.set(-0.16, 0.79, 0);
legR.position.set(0.16, 0.79, 0);
root.add(legL, legR);
for (const leg of [legL, legR]) {
box(leg, 0.24, 0.65, 0.28, trousers, 0, -0.33, 0);
box(leg, 0.27, 0.14, 0.38, '#252a2b', 0, -0.70, -0.07);
}
box(root, 0.65, 0.76, 0.38, coat, 0, 1.10, 0);
box(root, 0.19, 0.15, 0.20, skin, 0, 1.55, 0);
box(root, 0.47, 0.47, 0.45, skin, 0, 1.76, 0);
box(root, 0.49, 0.15, 0.47, hair, 0, 1.98, 0.015);
box(root, 0.10, 0.08, 0.03, '#252725', -0.12, 1.80, -0.235);
box(root, 0.10, 0.08, 0.03, '#252725', 0.12, 1.80, -0.235);
const armL = new THREE.Group();
const armR = new THREE.Group();
armL.position.set(-0.43, 1.36, 0);
armR.position.set(0.43, 1.36, 0);
root.add(armL, armR);
box(armL, 0.22, 0.60, 0.26, coat, 0, -0.28, 0);
box(armR, 0.22, 0.60, 0.26, coat, 0, -0.28, 0);
box(armL, 0.20, 0.18, 0.22, skin, 0, -0.62, 0);
box(armR, 0.20, 0.18, 0.22, skin, 0, -0.62, 0);
if (supplier) {
// Hi-vis vest and reflective bands on the back
box(root, 0.69, 0.65, 0.42, '#e88627', 0, 1.10, 0);
box(root, 0.10, 0.63, 0.035, '#f4e8a2', -0.22, 1.11, 0.228);
box(root, 0.10, 0.63, 0.035, '#f4e8a2', 0.22, 1.11, 0.228);
box(root, 0.69, 0.09, 0.035, '#f4e8a2', 0, 1.08, 0.229);
box(root, 0.54, 0.15, 0.52, '#20483d', 0, 2.02, 0);
box(root, 0.46, 0.07, 0.26, '#20483d', 0, 1.98, -0.34);
armL.rotation.x = 0.60;
armR.rotation.x = 0.60;
} else {
// Small shopping tote
box(root, 0.38, 0.43, 0.20, bagColor, 0.53, 0.67, 0.02);
box(root, 0.05, 0.20, 0.05, '#68442e', 0.43, 0.91, 0.02);
box(root, 0.05, 0.20, 0.05, '#68442e', 0.63, 0.91, 0.02);
}
const person = { root, legL, legR, armL, armR, phase, baseY: root.position.y };
people.push(person);
return person;
}
// Shoppers remain entirely in the warm pedestrian aisle
createPerson({
x: -2.85, z: -3.25, coat: '#a84e48', trousers: '#3f4754', skin: '#8e5b40',
hair: '#282521', rotation: 0.35, bagColor: '#d2a04e', phase: 0.2
});
createPerson({
x: -1.20, z: -1.55, coat: '#466b72', trousers: '#5d4c48', skin: '#d09a76',
hair: '#654033', rotation: -0.75, bagColor: '#e6d8b5', phase: 1.7
});
createPerson({
x: -3.18, z: 0.35, coat: '#d19a42', trousers: '#35485a', skin: '#c88462',
hair: '#5a392b', rotation: 1.48, bagColor: '#6f8054', phase: 3.1
});
createPerson({
x: -1.30, z: 2.12, coat: '#596a43', trousers: '#3b4142', skin: '#e0aa83',
hair: '#8b633b', rotation: -1.50, bagColor: '#9c4c3e', phase: 4.4
});
createPerson({
x: -0.15, z: 4.25, coat: '#73516f', trousers: '#343844', skin: '#9a6449',
hair: '#241f1c', rotation: 0.65, bagColor: '#d4b45d', phase: 5.5
});
// Supplier and handcart: the only moving figures on the delivery lane
const deliveryGroup = new THREE.Group();
deliveryGroup.position.set(3.35, 0.13, 1.2);
scene.add(deliveryGroup);
const supplier = createPerson({
x: 0,
z: 0,
coat: '#294b5a',
trousers: '#283942',
skin: '#d39b73',
hair: '#4c3429',
rotation: 0,
supplier: true,
phase: 0
});
// Move the supplier object into the delivery group.
scene.remove(supplier.root);
deliveryGroup.add(supplier.root);
supplier.root.position.set(0, 0, 0.58);
supplier.baseY = 0;
const cart = new THREE.Group();
cart.position.z = -0.68;
deliveryGroup.add(cart);
box(cart, 1.28, 0.16, 1.18, '#53635d', 0, 0.61, 0);
box(cart, 1.35, 0.10, 0.12, '#33443f', 0, 0.71, 0.46);
box(cart, 1.35, 0.10, 0.12, '#33443f', 0, 0.71, -0.46);
// Squared voxel wheels
for (const x of [-0.74, 0.74]) {
box(cart, 0.25, 0.46, 0.48, '#252d2c', x, 0.30, 0);
box(cart, 0.28, 0.17, 0.17, '#7e8b87', x, 0.30, 0);
}
// Cart handles
box(cart, 0.10, 0.82, 0.10, '#3e4b48', -0.44, 1.03, 0.56);
box(cart, 0.10, 0.82, 0.10, '#3e4b48', 0.44, 1.03, 0.56);
box(cart, 1.00, 0.10, 0.12, '#34423f', 0, 1.45, 0.56);
// Two loaded crates
crate(cart, -0.31, 0.69, 0, 0.58, 0.50, 0.74);
crate(cart, 0.31, 0.69, 0, 0.58, 0.50, 0.74);
for (let i = 0; i < 8; i++) {
const x = -0.49 + (i % 3) * 0.19;
const z = -0.25 + Math.floor(i / 3) * 0.18;
box(cart, 0.17, 0.17, 0.17, i % 2 ? '#d78d2f' : '#b94e35', x, 1.29, z);
}
// Small market details: bollard cone, drain and stacked boxes
function trafficCone(x, z) {
box(scene, 0.42, 0.08, 0.42, '#4c514a', x, 0.19, z);
box(scene, 0.29, 0.46, 0.29, '#dd6838', x, 0.43, z);
box(scene, 0.18, 0.18, 0.18, '#ef8a45', x, 0.72, z);
box(scene, 0.25, 0.10, 0.25, '#f4e4bd', x, 0.61, z);
}
trafficCone(5.35, 4.65);
for (let i = 0; i < 7; i++) {
box(scene, 0.06, 0.035, 0.82, '#3d5352', 5.25 + i * 0.10, 0.15, 4.65);
}
crate(scene, -4.15, 0.16, 4.60, 0.68, 0.42, 0.60);
crate(scene, -4.15, 0.59, 4.60, 0.62, 0.38, 0.55);
// Voxel pigeons
const pigeons = [];
function createPigeon(x, z, phase) {
const root = new THREE.Group();
root.position.set(x, 0.17, z);
scene.add(root);
box(root, 0.34, 0.24, 0.52, '#b9c0bc', 0, 0.25, 0);
box(root, 0.26, 0.27, 0.27, '#d1d5d1', 0, 0.44, -0.28);
box(root, 0.09, 0.08, 0.13, '#df9340', 0, 0.42, -0.47);
box(root, 0.05, 0.05, 0.04, '#222725', -0.10, 0.49, -0.42);
box(root, 0.05, 0.05, 0.04, '#222725', 0.10, 0.49, -0.42);
box(root, 0.12, 0.17, 0.30, '#596967', 0, 0.28, 0.31);
box(root, 0.04, 0.17, 0.04, '#d89443', -0.09, 0.08, -0.08);
box(root, 0.04, 0.17, 0.04, '#d89443', 0.09, 0.08, -0.08);
pigeons.push({ root, phase });
}
createPigeon(-4.45, 4.95, 0.2);
createPigeon(5.90, -1.95, 2.1);
// Camera controls implemented directly, without addon modules.
let dragging = false;
let panning = false;
let lastX = 0;
let lastY = 0;
function resetView() {
spherical.yaw = 0.66;
spherical.pitch = 0.79;
spherical.radius = 15.5;
target.set(0, 1.05, -0.25);
camera.zoom = 1;
camera.updateProjectionMatrix();
}
function updateCamera() {
const cp = Math.cos(spherical.pitch);
camera.position.set(
target.x + Math.sin(spherical.yaw) * cp * spherical.radius,
target.y + Math.sin(spherical.pitch) * spherical.radius,
target.z + Math.cos(spherical.yaw) * cp * spherical.radius
);
camera.lookAt(target);
}
renderer.domElement.addEventListener('pointerdown', event => {
dragging = true;
panning = event.shiftKey || event.button === 2;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener('pointermove', event => {
if (!dragging) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
if (panning) {
const right = new THREE.Vector3(Math.cos(spherical.yaw), 0, -Math.sin(spherical.yaw));
const forward = new THREE.Vector3(Math.sin(spherical.yaw), 0, Math.cos(spherical.yaw));
target.addScaledVector(right, -dx * 0.012);
target.addScaledVector(forward, -dy * 0.012);
} else {
spherical.yaw -= dx * 0.006;
spherical.pitch = THREE.MathUtils.clamp(spherical.pitch + dy * 0.005, 0.42, 1.25);
}
});
function endDrag(event) {
dragging = false;
panning = false;
if (event.pointerId !== undefined && 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();
camera.zoom = THREE.MathUtils.clamp(camera.zoom * Math.exp(-event.deltaY * 0.001), 0.65, 1.85);
camera.updateProjectionMatrix();
}, { passive: false });
window.addEventListener('keydown', event => {
const step = 0.09;
if (event.key === 'ArrowLeft') spherical.yaw += step;
if (event.key === 'ArrowRight') spherical.yaw -= step;
if (event.key === 'ArrowUp') spherical.pitch = THREE.MathUtils.clamp(spherical.pitch - step, 0.42, 1.25);
if (event.key === 'ArrowDown') spherical.pitch = THREE.MathUtils.clamp(spherical.pitch + step, 0.42, 1.25);
if (event.key === '+' || event.key === '=') camera.zoom = THREE.MathUtils.clamp(camera.zoom * 1.08, 0.65, 1.85);
if (event.key === '-') camera.zoom = THREE.MathUtils.clamp(camera.zoom / 1.08, 0.65, 1.85);
if (event.key.toLowerCase() === 'r') resetView();
if (event.key.startsWith('Arrow')) {
event.preventDefault();
camera.updateProjectionMatrix();
}
});
document.getElementById('reset').addEventListener('click', resetView);
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const viewHeight = Math.max(10.7, 15.2 / aspect);
camera.left = -viewHeight * aspect / 2;
camera.right = viewHeight * aspect / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener('resize', resize);
resize();
updateCamera();
const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
const startTime = performance.now();
function animate(now) {
const elapsed = (now - startTime) / 1000;
if (!reducedMotion) {
// Shopper idle motion is deliberately confined to the pedestrian aisle.
for (const person of people) {
const swing = Math.sin(elapsed * 2.1 + person.phase);
person.legL.rotation.x = swing * 0.055;
person.legR.rotation.x = -swing * 0.055;
person.armL.rotation.x = -swing * 0.075;
person.armR.rotation.x = swing * 0.075;
person.root.position.y = person.baseY + Math.abs(swing) * 0.018;
}
// Supplier travels slowly up the marked service lane, pauses at the bay,
// then resets after a short off-screen interval.
const cycle = elapsed % 30;
if (cycle < 18) {
const p = cycle / 18;
const eased = p * p * (3 - 2 * p);
deliveryGroup.visible = true;
deliveryGroup.position.z = THREE.MathUtils.lerp(1.2, -3.75, eased);
} else if (cycle < 25) {
deliveryGroup.visible = true;
deliveryGroup.position.z = -3.75;
} else {
deliveryGroup.visible = false;
}
const push = Math.sin(elapsed * 4.6);
supplier.legL.rotation.x = push * 0.20;
supplier.legR.rotation.x = -push * 0.20;
supplier.armL.rotation.x = 0.58 + push * 0.10;
supplier.armR.rotation.x = 0.58 - push * 0.10;
supplier.root.position.y = Math.abs(push) * 0.025;
for (const pigeon of pigeons) {
pigeon.root.rotation.y = Math.sin(elapsed * 0.7 + pigeon.phase) * 0.55;
pigeon.root.position.y = 0.17 + Math.max(0, Math.sin(elapsed * 2.2 + pigeon.phase)) * 0.025;
}
}
updateCamera();
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```