Prompt specification
Build or customize the Three.js 3D scene "Roman neighborhood bakery supply scene" 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: Roman neighborhood bakery supply scene
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/roman-neighborhood-bakery-supply-scene-x2311
Scene Description Prompt:
Roman neighborhood bakery supply scene. Build a short street containing grain delivery, bakery courtyard, and bread counter. Show workers using separate supply and customer paths through the compact setting. Please build this with Three.js from cdnjs in one self-contained HTML file, using visible voxel blocks.
Working Three.js Starter (roman-neighborhood-bakery-supply-scene-x2311):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Forno di Sant'Angelo — Roman Bakery</title>
<style>
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d8c39b;
font-family: Arial, Helvetica, sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.panel {
position: fixed;
top: 20px;
left: 20px;
width: min(360px, calc(100vw - 40px));
padding: 18px 20px 16px;
color: #39261f;
background: rgba(255, 247, 224, 0.9);
border: 1px solid rgba(89, 52, 35, 0.2);
border-radius: 14px;
box-shadow: 0 12px 35px rgba(65, 39, 24, 0.17);
backdrop-filter: blur(10px);
pointer-events: none;
user-select: none;
}
.eyebrow {
display: inline-block;
margin-bottom: 8px;
padding: 4px 8px;
color: #fff8e7;
background: #9e4936;
border-radius: 4px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(23px, 4vw, 31px);
line-height: 1.05;
letter-spacing: -0.025em;
}
.subtitle {
margin: 8px 0 15px;
color: #755e50;
font-size: 13px;
line-height: 1.45;
}
.legend {
display: grid;
gap: 8px;
padding-top: 13px;
border-top: 1px solid rgba(89, 52, 35, 0.14);
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
font-size: 12px;
font-weight: 700;
}
.swatch {
width: 27px;
height: 8px;
border-radius: 8px;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.supply { background: #df9d31; }
.customer { background: #238c8a; }
.legend small {
display: block;
margin-top: 2px;
color: #8a7565;
font-size: 10px;
font-weight: 400;
}
.panel-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 14px;
padding-top: 12px;
border-top: 1px solid rgba(89, 52, 35, 0.14);
color: #806c5d;
font-size: 10px;
}
button {
padding: 7px 10px;
color: #fff8e7;
background: #4f352a;
border: 0;
border-radius: 6px;
font: inherit;
font-size: 10px;
font-weight: 700;
cursor: pointer;
pointer-events: auto;
}
button:hover { background: #6b4432; }
.hint {
position: fixed;
right: 18px;
bottom: 16px;
padding: 8px 11px;
color: #4d382f;
background: rgba(255, 247, 224, 0.78);
border-radius: 7px;
font-size: 10px;
letter-spacing: 0.03em;
pointer-events: none;
user-select: none;
}
@media (max-width: 600px) {
.panel { top: 12px; left: 12px; padding: 14px 16px; }
.subtitle { margin-bottom: 10px; }
.hint { right: 10px; bottom: 10px; }
}
</style>
</head>
<body>
<section class="panel" aria-label="Scene information">
<div class="eyebrow">ROMA · MORNING DELIVERY</div>
<h1>Forno di Sant’Angelo</h1>
<p class="subtitle">
A compact neighborhood bakery with a separate grain-delivery route
and an independent customer approach to the bread counter.
</p>
<div class="legend">
<div class="legend-row">
<span class="swatch supply"></span>
<span>Supply route
<small>Grain cart → bakery courtyard → oven</small>
</span>
</div>
<div class="legend-row">
<span class="swatch customer"></span>
<span>Customer route
<small>Street approach → bread counter</small>
</span>
</div>
</div>
<div class="panel-footer">
<span>LIVE SCENE · SEPARATE WORK FLOWS</span>
<button id="reset" type="button">Reset view</button>
</div>
</section>
<div class="hint">Drag to orbit · Scroll to zoom · Arrow keys to rotate</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------------
// Renderer and scene
// ------------------------------------------------------------------
const canvas = document.createElement("canvas");
document.body.prepend(canvas);
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#d8c39b");
scene.fog = new THREE.Fog("#d8c39b", 29, 55);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const controls = {
target: new THREE.Vector3(0, 1.0, -0.35),
theta: 0.68,
phi: 1.05,
radius: 22
};
function updateCamera() {
const { target, theta, phi, radius } = controls;
const sinPhi = Math.sin(phi);
camera.position.set(
target.x + radius * sinPhi * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * sinPhi * Math.cos(theta)
);
camera.lookAt(target);
}
updateCamera();
const hemi = new THREE.HemisphereLight("#fff3d5", "#79624f", 2.15);
scene.add(hemi);
const sun = new THREE.DirectionalLight("#fff0cc", 3.1);
sun.position.set(-8, 15, 10);
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 = 45;
sun.shadow.bias = -0.0005;
scene.add(sun);
const fill = new THREE.DirectionalLight("#b8d4dc", 0.65);
fill.position.set(10, 8, -8);
scene.add(fill);
// ------------------------------------------------------------------
// Voxel construction helpers
// ------------------------------------------------------------------
const unitBox = new THREE.BoxGeometry(1, 1, 1);
function material(color, extra = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0,
...extra
});
}
const M = {
plinth: material("#b99568"),
courtyard: material("#d7bd8b"),
courtyardAlt: material("#c9aa78"),
road: material("#73685c"),
curb: material("#d9c4a2"),
stone: material("#b9a17d"),
stoneDark: material("#88765f"),
cream: material("#f1dca9"),
stucco: material("#dfbd82"),
stuccoLight: material("#efc98f"),
ochre: material("#d59a56"),
terracotta: material("#a9573f"),
terracottaLight: material("#c86f49"),
roofDark: material("#874433"),
wood: material("#885334"),
woodLight: material("#ad7444"),
woodDark: material("#4f3327"),
window: material("#273f43", { roughness: 0.4 }),
shutter: material("#50766b"),
shutterBlue: material("#5d7885"),
metal: material("#303333", { roughness: 0.58, metalness: 0.28 }),
flour: material("#eee0bd"),
sack: material("#c8ad78"),
sackDark: material("#aa8957"),
bread: material("#c8873f"),
breadLight: material("#dea052"),
breadScore: material("#8d4f28"),
grain: material("#d9b55f"),
water: material("#6daeb1", { roughness: 0.3, metalness: 0.05 }),
leaf: material("#71815a"),
leafLight: material("#8a996c"),
olive: material("#6b7553"),
orange: material("#dc7a32"),
clothBlue: material("#6b9caa"),
clothRed: material("#b85d4c"),
clothCream: material("#e7d8b7"),
skin: material("#c98f67"),
skinLight: material("#dda77e"),
hair: material("#493126"),
white: material("#f4eddc"),
supplyWorker: material("#b56742"),
customerWorker: material("#3f8587"),
apronSupply: material("#777449"),
apronBaker: material("#eee4cd"),
basket: material("#a7733e")
};
const cobbleMaterials = [
material("#82776a"),
material("#8b806f"),
material("#756c61"),
material("#948573")
];
const tileMaterials = [
material("#d4b785"),
material("#c9aa77"),
material("#ddc18e"),
material("#c0a06f")
];
const roofMaterials = [
material("#a9573f"),
material("#b96043"),
material("#984a36")
];
function box(parent, x, y, z, w, h, d, mat, rotation = 0) {
const mesh = new THREE.Mesh(unitBox, mat);
mesh.position.set(x, y, z);
mesh.scale.set(w, h, d);
mesh.rotation.y = rotation;
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addSign(parent, text, x, y, z, w, h, bg = "#f2dfb5", fg = "#593126") {
const c = document.createElement("canvas");
c.width = 1024;
c.height = 256;
const ctx = c.getContext("2d");
ctx.fillStyle = bg;
ctx.fillRect(0, 0, c.width, c.height);
ctx.strokeStyle = fg;
ctx.lineWidth = 10;
ctx.strokeRect(15, 15, c.width - 30, c.height - 30);
ctx.fillStyle = fg;
ctx.font = "bold 76px Georgia";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, c.width / 2, c.height / 2 + 5);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
box(parent, x, y, z - 0.045, w + 0.08, h + 0.08, 0.1, M.woodDark);
const sign = new THREE.Mesh(
new THREE.PlaneGeometry(w, h),
new THREE.MeshBasicMaterial({ map: texture })
);
sign.position.set(x, y, z + 0.012);
parent.add(sign);
return sign;
}
function crate(parent, x, y, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
parent.add(group);
box(group, 0, 0.08, 0, 0.9, 0.16, 0.7, M.woodLight);
box(group, -0.39, 0.32, 0, 0.12, 0.58, 0.7, M.wood);
box(group, 0.39, 0.32, 0, 0.12, 0.58, 0.7, M.wood);
box(group, 0, 0.32, -0.29, 0.9, 0.58, 0.12, M.wood);
box(group, 0, 0.32, 0.29, 0.9, 0.58, 0.12, M.wood);
return group;
}
function flourSack(parent, x, y, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
parent.add(group);
box(group, 0, 0.24, 0, 0.48, 0.48, 0.4, M.sack);
box(group, 0, 0.5, 0, 0.32, 0.18, 0.28, M.sack);
box(group, 0, 0.61, 0, 0.17, 0.1, 0.15, M.sackDark);
box(group, 0, 0.56, 0, 0.2, 0.05, 0.18, M.woodDark);
return group;
}
function loaf(parent, x, y, z, scale = 1, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
parent.add(group);
box(group, 0, 0.13, 0, 0.68, 0.25, 0.34, M.bread);
box(group, -0.34, 0.11, 0, 0.16, 0.18, 0.25, M.breadLight);
box(group, 0.34, 0.11, 0, 0.16, 0.18, 0.25, M.breadLight);
box(group, -0.19, 0.265, 0, 0.035, 0.025, 0.25, M.breadScore, -0.25);
box(group, 0, 0.265, 0, 0.035, 0.025, 0.25, M.breadScore);
box(group, 0.19, 0.265, 0, 0.035, 0.025, 0.25, M.breadScore, 0.25);
return group;
}
function baguette(parent, x, y, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
parent.add(group);
box(group, 0, 0.09, 0, 0.92, 0.18, 0.18, M.breadLight);
for (let i = -1; i <= 1; i++) {
box(group, i * 0.2, 0.19, 0, 0.035, 0.025, 0.14, M.breadScore, -0.25);
}
return group;
}
function frontWindow(parent, x, y, z, w = 1.15, h = 1.25, shutterMat = M.shutter) {
box(parent, x, y, z, w, h, 0.1, M.window);
box(parent, x, y, z + 0.065, w + 0.12, 0.12, 0.08, M.cream);
box(parent, x, y + h / 2 + 0.02, z + 0.065, w + 0.12, 0.12, 0.08, M.cream);
box(parent, x - w / 2 - 0.04, y, z + 0.065, 0.12, h + 0.12, 0.08, M.cream);
box(parent, x + w / 2 + 0.04, y, z + 0.065, 0.12, h + 0.12, 0.08, M.cream);
box(parent, x, y, z + 0.09, 0.06, h, 0.06, M.cream);
box(parent, x - w / 2 - 0.22, y, z + 0.055, 0.32, h, 0.08, shutterMat);
box(parent, x + w / 2 + 0.22, y, z + 0.055, 0.32, h, 0.08, shutterMat);
}
// ------------------------------------------------------------------
// Ground, street and paving
// ------------------------------------------------------------------
box(scene, 0, -0.58, -0.55, 17.4, 0.72, 12.2, M.plinth);
box(scene, 0, -0.18, 3.1, 16.9, 0.24, 3.0, M.road);
box(scene, -1.25, -0.16, -1.35, 11.25, 0.26, 3.75, M.courtyard);
// Individual road cobbles.
for (let ix = 0; ix < 18; ix++) {
for (let iz = 0; iz < 5; iz++) {
const x = -7.55 + ix * 0.89;
const z = 1.98 + iz * 0.56;
const mat = cobbleMaterials[(ix * 3 + iz * 2) % cobbleMaterials.length];
box(scene, x, -0.025 + ((ix + iz) % 2) * 0.012, z, 0.83, 0.13, 0.49, mat);
}
}
// Raised stone sidewalks.
box(scene, 0, 0.02, 1.42, 16.9, 0.3, 0.56, M.curb);
box(scene, 0, 0.02, 4.72, 16.9, 0.3, 0.56, M.curb);
for (let i = 0; i < 23; i++) {
const x = -8.05 + i * 0.73;
box(scene, x, 0.18, 1.42, 0.67, 0.12, 0.54, tileMaterials[i % 4]);
box(scene, x, 0.18, 4.72, 0.67, 0.12, 0.54, tileMaterials[(i + 1) % 4]);
}
// Courtyard tiles.
for (let ix = 0; ix < 15; ix++) {
for (let iz = 0; iz < 5; iz++) {
const x = -6.48 + ix * 0.75;
const z = -2.76 + iz * 0.73;
box(scene, x, 0.005, z, 0.69, 0.1, 0.66, tileMaterials[(ix + iz * 2) % 4]);
}
}
// ------------------------------------------------------------------
// Main bakery building
// ------------------------------------------------------------------
box(scene, -1.35, 0.18, -4.55, 9.25, 0.32, 3.65, M.stoneDark);
box(scene, -1.35, 2.2, -4.55, 9.05, 3.8, 3.4, M.stucco);
box(scene, -1.35, 4.12, -4.55, 9.28, 0.24, 3.62, M.cream);
box(scene, -1.35, 0.75, -2.81, 9.05, 0.32, 0.13, M.terracottaLight);
// Stepped voxel roof.
for (let row = 0; row < 5; row++) {
const z = -5.93 + row * 0.69;
const y = 4.32 + row * 0.2;
const width = 9.45 - row * 0.18;
const tiles = 11;
for (let col = 0; col < tiles; col++) {
const x = -1.35 - width / 2 + (col + 0.5) * width / tiles;
box(
scene, x, y, z,
width / tiles - 0.025, 0.22, 0.64,
roofMaterials[(row + col) % roofMaterials.length]
);
}
}
// Main door.
box(scene, -3.75, 1.28, -2.78, 1.55, 2.2, 0.14, M.woodDark);
box(scene, -3.75, 1.28, -2.69, 1.28, 1.98, 0.08, M.wood);
box(scene, -3.46, 1.3, -2.63, 0.08, 1.98, 0.08, M.woodDark);
box(scene, -3.72, 1.2, -2.58, 0.1, 0.1, 0.08, M.breadLight);
frontWindow(scene, -0.65, 2.15, -2.79, 1.35, 1.35, M.shutter);
frontWindow(scene, -3.55, 3.35, -2.79, 0.9, 0.72, M.shutterBlue);
addSign(scene, "FORNO", -3.75, 2.78, -2.68, 1.62, 0.46);
// ------------------------------------------------------------------
// Right-hand Roman residence and bread counter
// ------------------------------------------------------------------
box(scene, 5.45, 0.18, -4.05, 4.55, 0.32, 4.05, M.stoneDark);
box(scene, 5.45, 2.58, -4.05, 4.4, 4.5, 3.9, M.ochre);
box(scene, 5.45, 4.85, -4.05, 4.62, 0.24, 4.08, M.cream);
for (let row = 0; row < 5; row++) {
const z = -5.48 + row * 0.69;
const y = 5.02 + row * 0.18;
const width = 4.72 - row * 0.18;
for (let col = 0; col < 6; col++) {
const x = 5.45 - width / 2 + (col + 0.5) * width / 6;
box(scene, x, y, z, width / 6 - 0.025, 0.2, 0.63, roofMaterials[(row + col + 1) % 3]);
}
}
frontWindow(scene, 4.12, 2.35, -2.06, 1.05, 1.25, M.shutterBlue);
frontWindow(scene, 6.28, 2.35, -2.06, 1.05, 1.25, M.shutterBlue);
box(scene, 5.2, 1.05, -2.03, 1.1, 1.9, 0.15, M.woodDark);
box(scene, 5.2, 1.05, -1.93, 0.9, 1.74, 0.08, M.wood);
addSign(scene, "PANE QUOTIDIANO", 5.2, 3.72, -1.95, 3.45, 0.5, "#f2d7a0", "#6c352b");
// Laundry line and blocky hanging cloths.
box(scene, 2.75, 2.12, -1.72, 0.12, 4.1, 0.12, M.metal);
box(scene, 7.55, 2.12, -1.72, 0.12, 4.1, 0.12, M.metal);
box(scene, 5.15, 4.08, -1.72, 4.92, 0.045, 0.045, M.woodDark);
box(scene, 3.58, 3.62, -1.7, 0.58, 0.78, 0.08, M.clothBlue);
box(scene, 4.45, 3.69, -1.7, 0.58, 0.65, 0.08, M.clothCream);
box(scene, 5.38, 3.61, -1.7, 0.6, 0.82, 0.08, M.clothRed);
box(scene, 6.38, 3.68, -1.7, 0.55, 0.68, 0.08, M.clothBlue);
// Bread counter.
box(scene, 4.38, 0.77, 0.02, 4.25, 1.22, 1.22, M.wood);
box(scene, 4.38, 1.43, 0.02, 4.45, 0.18, 1.38, M.woodLight);
for (let i = 0; i < 11; i++) {
box(scene, 2.35 + i * 0.405, 0.78, 0.65, 0.34, 1.05, 0.07, i % 2 ? M.woodLight : M.wood);
}
// Shelves behind the counter.
box(scene, 4.38, 1.03, -0.77, 3.65, 0.12, 0.52, M.woodDark);
box(scene, 4.38, 2.02, -0.77, 3.65, 0.12, 0.52, M.woodDark);
box(scene, 2.61, 1.52, -0.77, 0.1, 1.18, 0.1, M.woodDark);
box(scene, 6.15, 1.52, -0.77, 0.1, 1.18, 0.1, M.woodDark);
// Striped voxel awning.
for (let i = 0; i < 12; i++) {
const x = 2.2 + i * 0.4;
const y = 2.86 - Math.abs(i - 5.5) * 0.025;
box(scene, x, y, 0.15, 0.4, 0.15, 1.55, i % 2 ? M.clothCream : M.clothRed);
box(scene, x, y - 0.13, 0.92, 0.4, 0.27, 0.12, i % 2 ? M.clothCream : M.clothRed);
}
box(scene, 2.2, 1.99, 0.79, 0.12, 1.75, 0.12, M.metal);
box(scene, 6.6, 1.99, 0.79, 0.12, 1.75, 0.12, M.metal);
addSign(scene, "PANE", 4.38, 2.42, 1.02, 1.62, 0.52);
// Bread displayed on the counter and shelves.
loaf(scene, 3.0, 1.53, 0.24, 1.08);
loaf(scene, 3.82, 1.53, 0.18, 1.12, -0.08);
loaf(scene, 4.68, 1.53, 0.25, 1.08, 0.06);
loaf(scene, 5.52, 1.53, 0.16, 1.06);
baguette(scene, 3.65, 1.54, -0.42, 0.05);
baguette(scene, 4.62, 1.54, -0.42, -0.04);
baguette(scene, 5.55, 1.54, -0.42, 0.04);
loaf(scene, 3.25, 1.1, -0.73, 0.88);
loaf(scene, 4.08, 1.1, -0.73, 0.88);
loaf(scene, 4.9, 1.1, -0.73, 0.88);
loaf(scene, 3.25, 2.1, -0.73, 0.88);
loaf(scene, 4.08, 2.1, -0.73, 0.88);
loaf(scene, 4.9, 2.1, -0.73, 0.88);
// ------------------------------------------------------------------
// Courtyard oven, work table and Roman details
// ------------------------------------------------------------------
// Stone oven.
box(scene, -2.6, 0.25, -1.47, 2.15, 0.45, 1.6, M.stoneDark);
box(scene, -2.6, 1.1, -1.47, 1.95, 1.55, 1.45, M.stone);
box(scene, -2.6, 1.97, -1.47, 1.65, 0.3, 1.22, M.stoneDark);
box(scene, -2.6, 2.2, -1.47, 1.25, 0.25, 0.98, M.stone);
box(scene, -2.92, 2.93, -1.63, 0.55, 1.25, 0.55, M.stoneDark);
box(scene, -2.92, 3.61, -1.63, 0.68, 0.18, 0.68, M.terracotta);
// Stone blocks around the oven mouth.
box(scene, -2.6, 0.83, -0.72, 0.95, 0.84, 0.1, M.woodDark);
box(scene, -3.15, 1.0, -0.69, 0.26, 1.12, 0.16, M.stoneLight || M.cream);
box(scene, -2.05, 1.0, -0.69, 0.26, 1.12, 0.16, M.cream);
box(scene, -2.6, 1.37, -0.69, 0.78, 0.26, 0.16, M.cream);
addSign(scene, "FORNO", -2.6, 2.02, -0.68, 1.35, 0.37);
const flames = [];
for (let i = 0; i < 5; i++) {
const flame = box(
scene,
-2.9 + i * 0.15,
0.58 + (i % 2) * 0.08,
-0.61,
0.16,
0.42 + (i % 3) * 0.08,
0.12,
i % 2 ? M.breadLight : M.terracottaLight
);
flames.push(flame);
}
// Work table with flour and dough.
box(scene, -5.02, 0.95, -1.57, 2.1, 0.18, 1.02, M.woodLight);
box(scene, -5.76, 0.48, -1.57, 0.16, 0.92, 0.72, M.woodDark);
box(scene, -4.28, 0.48, -1.57, 0.16, 0.92, 0.72, M.woodDark);
box(scene, -5.44, 1.14, -1.6, 0.52, 0.22, 0.44, M.flour);
box(scene, -4.65, 1.13, -1.49, 0.58, 0.2, 0.4, M.breadLight);
flourSack(scene, -5.92, 0.08, -0.84, 1.05);
flourSack(scene, -5.45, 0.08, -0.8, 0.85);
crate(scene, -5.7, 0.08, -2.27, 0.72);
// Small courtyard well.
box(scene, 0.2, 0.18, -1.25, 1.5, 0.3, 1.5, M.stoneDark);
box(scene, 0.2, 0.48, -1.25, 1.18, 0.08, 1.18, M.water);
box(scene, -0.42, 0.47, -1.25, 0.18, 0.5, 1.45, M.stone);
box(scene, 0.82, 0.47, -1.25, 0.18, 0.5, 1.45, M.stone);
box(scene, 0.2, 0.47, -1.88, 1.42, 0.5, 0.18, M.stone);
box(scene, 0.2, 0.47, -0.62, 1.42, 0.5, 0.18, M.stone);
// Voxel olive tree.
box(scene, -5.7, 0.88, -2.25, 0.28, 1.6, 0.28, M.woodDark);
box(scene, -5.48, 1.48, -2.25, 0.65, 0.22, 0.22, M.wood, -0.35);
box(scene, -5.92, 1.66, -2.25, 0.52, 0.2, 0.2, M.wood, 0.55);
box(scene, -5.7, 2.05, -2.25, 1.42, 0.82, 1.05, M.olive);
box(scene, -6.22, 1.86, -2.08, 0.82, 0.75, 0.84, M.leaf);
box(scene, -5.17, 1.88, -2.44, 0.9, 0.7, 0.78, M.leafLight);
box(scene, -5.72, 2.57, -2.25, 0.85, 0.68, 0.72, M.leafLight);
box(scene, -6.05, 2.22, -1.89, 0.42, 0.42, 0.42, M.olive);
box(scene, -5.31, 2.24, -2.58, 0.4, 0.4, 0.4, M.olive);
// Citrus tree in a terracotta pot.
box(scene, 1.85, 0.28, -1.85, 0.74, 0.5, 0.74, M.terracotta);
box(scene, 1.85, 0.55, -1.85, 0.55, 0.1, 0.55, M.woodDark);
box(scene, 1.85, 1.03, -1.85, 0.23, 1.0, 0.23, M.wood);
box(scene, 1.85, 1.73, -1.85, 1.18, 0.83, 1.04, M.leaf);
box(scene, 1.44, 1.53, -1.66, 0.72, 0.7, 0.75, M.leafLight);
box(scene, 2.25, 1.54, -2.03, 0.65, 0.68, 0.7, M.leaf);
box(scene, 1.56, 1.9, -1.46, 0.19, 0.19, 0.19, M.orange);
box(scene, 2.12, 1.79, -2.19, 0.19, 0.19, 0.19, M.orange);
box(scene, 1.98, 2.05, -1.77, 0.18, 0.18, 0.18, M.orange);
// ------------------------------------------------------------------
// Grain delivery cart
// ------------------------------------------------------------------
const cart = new THREE.Group();
cart.position.set(-6.35, 0.04, 3.05);
scene.add(cart);
box(cart, 0, 0.84, 0, 2.05, 0.2, 1.3, M.wood);
box(cart, 0, 1.13, 0.65, 2.08, 0.55, 0.12, M.woodLight);
box(cart, 0, 1.13, -0.65, 2.08, 0.55, 0.12, M.woodLight);
box(cart, -1.0, 1.13, 0, 0.12, 0.55, 1.3, M.wood);
box(cart, 1.0, 1.13, 0, 0.12, 0.55, 1.3, M.wood);
// Voxel wheels, built from square tire blocks.
function cartWheel(x, z) {
const wheel = new THREE.Group();
wheel.position.set(x, 0.55, z);
cart.add(wheel);
box(wheel, 0, 0, 0, 0.56, 0.25, 0.22, M.metal);
box(wheel, 0, 0.27, 0, 0.25, 0.25, 0.22, M.metal);
box(wheel, 0, -0.27, 0, 0.25, 0.25, 0.22, M.metal);
box(wheel, 0.27, 0, 0, 0.25, 0.25, 0.22, M.metal);
box(wheel, -0.27, 0, 0, 0.25, 0.25, 0.22, M.metal);
box(wheel, 0, 0, 0.04, 0.2, 0.2, 0.24, M.woodLight);
}
cartWheel(-0.67, 0.75);
cartWheel(0.67, 0.75);
cartWheel(-0.67, -0.75);
cartWheel(0.67, -0.75);
box(cart, -1.22, 0.96, 0.45, 0.75, 0.12, 0.12, M.woodDark, -0.25);
box(cart, -1.22, 0.96, -0.45, 0.75, 0.12, 0.12, M.woodDark, 0.25);
flourSack(cart, -0.47, 0.96, 0.08, 0.95);
flourSack(cart, 0.13, 0.96, -0.07, 0.88);
crate(cart, 0.62, 0.96, 0.1, 0.72);
addSign(cart, "FARINA", 0, 1.58, 0.73, 1.35, 0.42, "#e9d59e", "#68412c");
// Loose grain blocks in the cart.
for (let i = 0; i < 12; i++) {
box(
cart,
-0.76 + (i % 4) * 0.16,
1.03 + Math.floor(i / 4) * 0.07,
-0.38 + Math.floor((i % 4) / 2) * 0.17,
0.13, 0.09, 0.13,
M.grain
);
}
// Delivery crate and sacks beside the cart.
crate(scene, -7.25, 0.11, 1.73, 0.85);
flourSack(scene, -7.55, 0.11, 2.38, 0.95);
flourSack(scene, -7.1, 0.11, 2.42, 0.8);
// ------------------------------------------------------------------
// Separate marked routes
// ------------------------------------------------------------------
const supplyPoints = [
{ x: -5.2, z: 2.35 },
{ x: -4.55, z: 2.35 },
{ x: -4.55, z: 0.3 },
{ x: -3.5, z: 0.3 },
{ x: -3.5, z: -0.15 },
{ x: -2.6, z: -0.15 }
];
const customerPoints = [
{ x: 7.25, z: 3.15 },
{ x: 6.25, z: 3.15 },
{ x: 5.8, z: 1.9 },
{ x: 5.18, z: 1.16 }
];
const supplyRouteMat = material("#df9d31", {
emissive: "#7a4610",
emissiveIntensity: 0.14
});
const customerRouteMat = material("#238c8a", {
emissive: "#124d4b",
emissiveIntensity: 0.14
});
function drawRoute(points, mat) {
for (let s = 0; s < points.length - 1; s++) {
const a = points[s];
const b = points[s + 1];
const dx = b.x - a.x;
const dz = b.z - a.z;
const length = Math.hypot(dx, dz);
const angle = -Math.atan2(dz, dx);
const count = Math.max(1, Math.floor(length / 0.42));
for (let i = 0; i < count; i++) {
const t = (i + 0.5) / count;
box(
scene,
a.x + dx * t,
0.19,
a.z + dz * t,
0.25, 0.065, 0.11,
mat,
angle
);
}
// Chunky voxel arrowhead.
const ux = dx / length;
const uz = dz / length;
const px = -uz;
const pz = ux;
const hx = b.x - ux * 0.17;
const hz = b.z - uz * 0.17;
box(
scene, hx + px * 0.13, 0.2, hz + pz * 0.13,
0.27, 0.065, 0.1, mat, angle + 0.63
);
box(
scene, hx - px * 0.13, 0.2, hz - pz * 0.13,
0.27, 0.065, 0.1, mat, angle - 0.63
);
}
}
drawRoute(supplyPoints, supplyRouteMat);
drawRoute(customerPoints, customerRouteMat);
// Small route plaques.
addSign(scene, "FORNITURA", -4.82, 0.44, 1.62, 1.35, 0.34, "#f0d596", "#85501d");
addSign(scene, "CLIENTI", 6.08, 0.44, 1.67, 1.15, 0.34, "#c8e0d7", "#245f5c");
// ------------------------------------------------------------------
// Voxel workers
// ------------------------------------------------------------------
function makeWorker(type, shirtMaterial) {
const group = new THREE.Group();
scene.add(group);
const legLeft = new THREE.Group();
const legRight = new THREE.Group();
legLeft.position.set(-0.17, 0.64, 0);
legRight.position.set(0.17, 0.64, 0);
group.add(legLeft, legRight);
box(legLeft, 0, -0.23, 0, 0.24, 0.48, 0.26, M.hair);
box(legRight, 0, -0.23, 0, 0.24, 0.48, 0.26, M.hair);
box(legLeft, 0, -0.51, 0.07, 0.29, 0.14, 0.4, M.woodDark);
box(legRight, 0, -0.51, 0.07, 0.29, 0.14, 0.4, M.woodDark);
box(group, 0, 0.95, 0, 0.62, 0.72, 0.38, shirtMaterial);
box(group, 0, 1.47, 0, 0.44, 0.43, 0.4, M.skin);
box(group, 0, 1.64, -0.02, 0.46, 0.16, 0.42, M.hair);
const armLeft = new THREE.Group();
const armRight = new THREE.Group();
armLeft.position.set(-0.41, 1.19, 0);
armRight.position.set(0.41, 1.19, 0);
group.add(armLeft, armRight);
box(armLeft, 0, -0.23, 0, 0.18, 0.48, 0.23, shirtMaterial);
box(armRight, 0, -0.23, 0, 0.18, 0.48, 0.23, shirtMaterial);
box(armLeft, 0, -0.49, 0.01, 0.17, 0.16, 0.2, M.skin);
box(armRight, 0, -0.49, 0.01, 0.17, 0.16, 0.2, M.skin);
if (type === "supply") {
box(group, 0, 0.84, 0.225, 0.52, 0.66, 0.06, M.apronSupply);
box(group, 0, 1.72, 0.02, 0.5, 0.12, 0.46, M.cream);
box(group, 0, 1.84, 0.02, 0.4, 0.18, 0.38, M.cream);
box(armRight, 0.05, -0.53, 0.14, 0.47, 0.43, 0.38, M.sack);
box(armRight, 0.05, -0.76, 0.14, 0.2, 0.1, 0.16, M.sackDark);
} else if (type === "customer") {
box(group, 0, 0.85, 0.225, 0.46, 0.61, 0.06, M.clothCream);
box(group, 0, 1.7, 0.02, 0.55, 0.08, 0.5, M.breadLight);
box(group, 0, 1.78, 0.02, 0.36, 0.17, 0.34, M.breadLight);
box(armRight, 0.03, -0.48, 0.16, 0.48, 0.34, 0.37, M.basket);
baguette(armRight, 0.03, 0.02, 0.16, 0.4);
} else {
box(group, 0, 0.86, 0.225, 0.52, 0.65, 0.06, M.apronBaker);
box(group, 0, 1.73, 0.02, 0.52, 0.14, 0.48, M.white);
box(group, 0, 1.86, 0.02, 0.42, 0.23, 0.38, M.white);
box(armRight, 0, -0.43, 0.13, 0.8, 0.12, 0.12, M.woodLight);
}
return { group, legLeft, legRight, armLeft, armRight };
}
const supplyWorker = makeWorker("supply", M.supplyWorker);
const customerWorker = makeWorker("customer", M.customerWorker);
const baker = makeWorker("baker", M.white);
baker.group.position.set(4.05, 0.16, -1.04);
baker.group.rotation.y = Math.PI;
baker.armLeft.rotation.x = -0.45;
baker.armRight.rotation.x = -0.45;
// ------------------------------------------------------------------
// Street details
// ------------------------------------------------------------------
function lamp(x, z) {
box(scene, x, 0.16, z, 0.42, 0.25, 0.42, M.metal);
box(scene, x, 1.4, z, 0.1, 2.5, 0.1, M.metal);
box(scene, x, 2.7, z, 0.48, 0.48, 0.48, M.metal);
box(scene, x, 2.7, z + 0.25, 0.33, 0.34, 0.08, M.breadLight, 0, 0);
box(scene, x, 2.97, z, 0.62, 0.12, 0.62, M.metal);
}
lamp(-7.35, 1.75);
lamp(7.42, 1.78);
// Potted herbs by the counter.
for (const p of [
{ x: 2.45, z: 1.2, c: M.leaf },
{ x: 6.68, z: 1.18, c: M.leafLight }
]) {
box(scene, p.x, 0.38, p.z, 0.48, 0.55, 0.48, M.terracotta);
box(scene, p.x, 0.72, p.z, 0.24, 0.45, 0.24, M.olive);
box(scene, p.x, 1.04, p.z, 0.72, 0.55, 0.62, p.c);
box(scene, p.x - 0.18, 1.31, p.z + 0.05, 0.4, 0.35, 0.42, M.leaf);
}
// A few loose grain blocks on the cobbles beside the delivery cart.
for (let i = 0; i < 9; i++) {
box(
scene,
-5.72 + (i % 3) * 0.17,
0.08,
2.02 + Math.floor(i / 3) * 0.17,
0.12, 0.1, 0.12,
M.grain,
i * 0.35
);
}
// ------------------------------------------------------------------
// Path animation
// ------------------------------------------------------------------
function pathLength(points) {
let total = 0;
for (let i = 0; i < points.length - 1; i++) {
total += Math.hypot(
points[i + 1].x - points[i].x,
points[i + 1].z - points[i].z
);
}
return total;
}
const supplyLength = pathLength(supplyPoints);
const customerLength = pathLength(customerPoints);
function samplePath(points, totalLength, progress) {
let distance = progress * totalLength;
for (let i = 0; i < points.length - 1; i++) {
const a = points[i];
const b = points[i + 1];
const dx = b.x - a.x;
const dz = b.z - a.z;
const length = Math.hypot(dx, dz);
if (distance <= length || i === points.length - 2) {
const t = Math.min(1, distance / length);
return {
x: a.x + dx * t,
z: a.z + dz * t,
dx: dx / length,
dz: dz / length
};
}
distance -= length;
}
const last = points[points.length - 1];
return { x: last.x, z: last.z, dx: 1, dz: 0 };
}
function animateWalker(worker, points, length, time, speed, offset) {
const cycle = (time * speed + offset) % 2;
const progress = cycle <= 1 ? cycle : 2 - cycle;
const sample = samplePath(points, length, progress);
const stride = Math.sin(time * 10.5) * 0.46;
worker.group.position.set(sample.x, 0.17, sample.z);
worker.group.rotation.y = Math.atan2(sample.dx, sample.dz);
worker.legLeft.rotation.x = stride;
worker.legRight.rotation.x = -stride;
worker.armLeft.rotation.x = -stride * 0.55;
worker.armRight.rotation.x = stride * 0.55;
}
// ------------------------------------------------------------------
// Custom camera interaction — no external controls module
// ------------------------------------------------------------------
let dragging = false;
let previousX = 0;
let previousY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(controls.phi - dy * 0.005, 0.48, 1.36);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
14,
29
);
updateCamera();
},
{ passive: false }
);
function resetView() {
controls.target.set(0, 1.0, -0.35);
controls.theta = 0.68;
controls.phi = 1.05;
controls.radius = 22;
updateCamera();
}
document.getElementById("reset").addEventListener("click", resetView);
canvas.addEventListener("dblclick", resetView);
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") controls.theta -= 0.08;
else if (event.key === "ArrowRight") controls.theta += 0.08;
else if (event.key === "ArrowUp") controls.phi = Math.max(0.48, controls.phi - 0.06);
else if (event.key === "ArrowDown") controls.phi = Math.min(1.36, controls.phi + 0.06);
else if (event.key.toLowerCase() === "r") resetView();
else return;
updateCamera();
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
// ------------------------------------------------------------------
// Main loop
// ------------------------------------------------------------------
const clock = new THREE.Clock();
function render() {
const time = clock.getElapsedTime();
animateWalker(
supplyWorker,
supplyPoints,
supplyLength,
time,
0.052,
0.08
);
animateWalker(
customerWorker,
customerPoints,
customerLength,
time,
0.068,
0.42
);
for (let i = 0; i < flames.length; i++) {
const flicker = 0.85 + Math.sin(time * 9 + i * 1.7) * 0.15;
flames[i].scale.y = flicker;
flames[i].position.y += Math.sin(time * 6 + i) * 0.0006;
}
renderer.render(scene, camera);
requestAnimationFrame(render);
}
render();
</script>
</body>
</html>
```