Prompt specification
Build or customize the Three.js 3D scene "Cafe chairs around a Trastevere doorway" 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: Cafe chairs around a Trastevere doorway
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/cafe-chairs-around-a-trastevere-doorway-x2866
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows Trastevere's squares and lanes in Rome. Create a compact neighborhood vignette with original cafe furniture, residents, and a delivery handcart. Keep a clear route between the doorway and the square beyond. Voxel style.
Working Three.js Starter (cafe-chairs-around-a-trastevere-doorway-x2866):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Trastevere — A Voxel Morning</title>
<style>
:root {
color-scheme: light;
--ink: #263b35;
--cream: #fff8e8;
--terracotta: #c85f3c;
--sage: #6f9173;
--gold: #d9ad57;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dbe9e4;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
#app,
canvas {
width: 100%;
height: 100%;
display: block;
}
canvas {
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 5;
}
.title-card {
position: absolute;
top: 24px;
left: 24px;
max-width: min(410px, calc(100vw - 48px));
padding: 18px 20px 17px;
border: 1px solid rgba(255, 255, 255, 0.62);
border-radius: 18px;
background: rgba(255, 249, 235, 0.88);
box-shadow: 0 14px 40px rgba(55, 65, 49, 0.14);
backdrop-filter: blur(12px);
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 7px;
color: var(--terracotta);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 22px;
height: 3px;
border-radius: 3px;
background: var(--terracotta);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(29px, 4vw, 43px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
margin: 10px 0 0;
max-width: 330px;
color: #64756d;
font-size: 13px;
line-height: 1.5;
}
.route-card {
position: absolute;
left: 24px;
bottom: 24px;
display: flex;
align-items: center;
gap: 13px;
padding: 12px 15px;
border: 1px solid rgba(255, 255, 255, 0.66);
border-radius: 14px;
background: rgba(255, 249, 235, 0.86);
box-shadow: 0 10px 30px rgba(55, 65, 49, 0.12);
backdrop-filter: blur(10px);
font-size: 12px;
}
.route-icon {
position: relative;
width: 48px;
height: 12px;
flex: 0 0 auto;
}
.route-icon::before {
content: "";
position: absolute;
top: 5px;
left: 2px;
width: 37px;
height: 3px;
border-radius: 4px;
background: repeating-linear-gradient(
90deg,
var(--gold) 0 7px,
transparent 7px 10px
);
}
.route-icon::after {
content: "";
position: absolute;
top: 1px;
right: 2px;
width: 0;
height: 0;
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-left: 8px solid var(--gold);
}
.route-card strong {
display: block;
margin-bottom: 2px;
font-size: 12px;
}
.route-card span {
color: #758078;
}
.controls {
position: absolute;
right: 24px;
bottom: 24px;
display: flex;
align-items: center;
gap: 8px;
pointer-events: auto;
}
.controls button {
min-height: 40px;
padding: 0 14px;
border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 12px;
background: rgba(255, 249, 235, 0.9);
box-shadow: 0 8px 24px rgba(55, 65, 49, 0.13);
color: var(--ink);
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
backdrop-filter: blur(10px);
transition: transform 150ms ease, background 150ms ease;
}
.controls button:hover {
transform: translateY(-2px);
background: #fffdf5;
}
.controls button.active {
color: white;
background: var(--terracotta);
}
.controls .icon-button {
width: 40px;
padding: 0;
font-size: 20px;
}
.hint {
position: absolute;
right: 25px;
top: 25px;
padding: 9px 12px;
border-radius: 10px;
background: rgba(38, 59, 53, 0.72);
color: rgba(255, 255, 255, 0.88);
font-size: 10px;
letter-spacing: 0.05em;
backdrop-filter: blur(8px);
}
.world-label {
position: absolute;
z-index: 4;
padding: 6px 9px;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 8px;
background: rgba(255, 249, 235, 0.9);
box-shadow: 0 5px 18px rgba(38, 59, 53, 0.12);
color: var(--ink);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.04em;
white-space: nowrap;
pointer-events: none;
transform: translate(-50%, -100%);
transition: opacity 120ms linear;
}
.world-label::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 2px;
height: 12px;
background: rgba(38, 59, 53, 0.45);
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #dbe9e4;
color: var(--ink);
font: 700 12px/1.4 system-ui, sans-serif;
letter-spacing: 0.15em;
text-transform: uppercase;
transition: opacity 500ms ease, visibility 500ms ease;
}
#loading.hidden {
opacity: 0;
visibility: hidden;
}
@media (max-width: 700px) {
.title-card {
top: 14px;
left: 14px;
padding: 14px 16px;
}
.subtitle {
font-size: 12px;
}
.hint {
display: none;
}
.route-card {
left: 14px;
bottom: 70px;
}
.controls {
right: 14px;
bottom: 14px;
}
.controls button {
padding: 0 11px;
}
}
</style>
</head>
<body>
<div id="app"></div>
<div class="hud">
<section class="title-card">
<div class="eyebrow">Voxel Rome · Trastevere</div>
<h1>A morning in<br />Trastevere</h1>
<p class="subtitle">
A quiet side lane opening into Piazza Santa Maria, with terracotta roofs,
green shutters, neighborhood coffee, and the rhythm of everyday life.
</p>
</section>
<div class="hint">DRAG TO ORBIT · SCROLL TO ZOOM · R TO RESET</div>
<div class="route-card">
<div class="route-icon"></div>
<div>
<strong>Doorway → Piazza</strong>
<span>The pale paving stones mark the open route.</span>
</div>
</div>
<div class="controls">
<button id="tourButton" type="button">Walk the route</button>
<button id="resetButton" type="button">Reset view</button>
<button id="zoomOutButton" class="icon-button" type="button" aria-label="Zoom out">−</button>
<button id="zoomInButton" class="icon-button" type="button" aria-label="Zoom in">+</button>
</div>
</div>
<div id="doorLabel" class="world-label">THE BLUE DOOR</div>
<div id="cafeLabel" class="world-label">CAFFÈ DEL VICOLO</div>
<div id="piazzaLabel" class="world-label">PIAZZA SANTA MARIA</div>
<div id="cartLabel" class="world-label">MORNING DELIVERY</div>
<div id="loading">Building Trastevere…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, scene, and camera
// -------------------------------------------------------------------------
const app = document.getElementById("app");
const renderer = new THREE.WebGLRenderer({
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.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
app.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color("#dbe9e4");
scene.fog = new THREE.Fog("#dbe9e4", 52, 96);
const camera = new THREE.OrthographicCamera(-20, 20, 14, -14, 0.1, 160);
const hemisphere = new THREE.HemisphereLight("#eaf8f4", "#9b7655", 2.15);
scene.add(hemisphere);
const sunlight = new THREE.DirectionalLight("#fff0c6", 3.25);
sunlight.position.set(-15, 27, 18);
sunlight.castShadow = true;
sunlight.shadow.mapSize.set(2048, 2048);
sunlight.shadow.camera.left = -25;
sunlight.shadow.camera.right = 25;
sunlight.shadow.camera.top = 27;
sunlight.shadow.camera.bottom = -27;
sunlight.shadow.camera.near = 1;
sunlight.shadow.camera.far = 75;
sunlight.shadow.bias = -0.00025;
sunlight.shadow.normalBias = 0.025;
scene.add(sunlight);
const warmFill = new THREE.DirectionalLight("#f4a36f", 0.65);
warmFill.position.set(18, 10, -15);
scene.add(warmFill);
let seed = 1847;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.88,
metalness: options.metalness ?? 0,
flatShading: options.flatShading ?? true,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1,
emissive: options.emissive ?? "#000000",
emissiveIntensity: options.emissiveIntensity ?? 0,
side: options.side ?? THREE.FrontSide
});
}
const M = {
ground: material("#ad8861"),
earthSide: material("#835f45"),
lane: material("#b7a184"),
square: material("#c6b394"),
paleStone: material("#ead9b8"),
route: material("#f0d49a", {
emissive: "#8c5a21",
emissiveIntensity: 0.12
}),
plasterCream: material("#e8d5ae"),
plasterPeach: material("#d99b78"),
plasterOchre: material("#d8b76f"),
plasterRose: material("#c98673"),
plasterSage: material("#b8b995"),
roof: material("#a74f38"),
roofLight: material("#c46643"),
roofDark: material("#8e4133"),
shutterGreen: material("#527460"),
shutterBlue: material("#577985"),
window: material("#263f42", { roughness: 0.45 }),
windowLight: material("#b8d7d0", { roughness: 0.32 }),
dark: material("#26312e"),
black: material("#292d2b"),
wood: material("#81583c"),
woodLight: material("#b28150"),
woodDark: material("#553e31"),
stone: material("#d4c3a2"),
stoneDark: material("#aa967c"),
cream: material("#f4ead3"),
red: material("#c85b42"),
brick: material("#ad533e"),
green: material("#66865b"),
greenDark: material("#405f45"),
greenLight: material("#8ca16e"),
ochre: material("#d59d43"),
blue: material("#638c9c"),
denim: material("#42617b"),
shirtWhite: material("#ece4d0"),
skin1: material("#d99b72"),
skin2: material("#a96848"),
skin3: material("#e4b58c"),
hair1: material("#433129"),
hair2: material("#70503a"),
metal: material("#4d5550", { metalness: 0.65, roughness: 0.4 }),
silver: material("#aeb5ae", { metalness: 0.6, roughness: 0.3 }),
water: material("#62a8b0", {
roughness: 0.2,
transparent: true,
opacity: 0.86
}),
tomato: material("#cf4f32"),
bread: material("#d8a653")
};
function box(w, h, d, x, y, z, mat, parent = scene, cast = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function group(x = 0, y = 0, z = 0, parent = scene) {
const g = new THREE.Group();
g.position.set(x, y, z);
parent.add(g);
return g;
}
// -------------------------------------------------------------------------
// Ground, paving, and the deliberately unobstructed route
// -------------------------------------------------------------------------
box(36, 0.8, 39, 0, -0.45, -1.5, M.earthSide);
box(35.5, 0.16, 38.5, 0, -0.02, -1.5, M.ground);
box(5.15, 0.17, 18.2, 0, 0.05, 2.05, M.lane);
box(21.2, 0.19, 8.8, 0, 0.06, -9.8, M.square);
box(0.62, 0.24, 18.1, -2.55, 0.08, 2.05, M.stone);
box(0.62, 0.24, 18.1, 2.55, 0.08, 2.05, M.stone);
function paveGrid(minX, maxX, minZ, maxZ, nx, nz, baseColor) {
const geometry = new THREE.BoxGeometry(0.74, 0.065, 0.61);
const mesh = new THREE.InstancedMesh(
geometry,
material("#ffffff"),
nx * nz
);
const dummy = new THREE.Object3D();
const color = new THREE.Color();
let index = 0;
for (let iz = 0; iz < nz; iz++) {
for (let ix = 0; ix < nx; ix++) {
const x = THREE.MathUtils.lerp(minX, maxX, (ix + 0.5) / nx);
const z = THREE.MathUtils.lerp(minZ, maxZ, (iz + 0.5) / nz);
dummy.position.set(
x + (random() - 0.5) * 0.04,
0.17 + (random() - 0.5) * 0.018,
z + (random() - 0.5) * 0.04
);
dummy.rotation.y = (random() - 0.5) * 0.025;
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
color.set(baseColor).offsetHSL(
0,
(random() - 0.5) * 0.035,
(random() - 0.5) * 0.075
);
mesh.setColorAt(index, color);
index++;
}
}
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
mesh.receiveShadow = true;
scene.add(mesh);
}
paveGrid(-2.25, 2.25, -6.35, 10.2, 6, 27, "#aa9276");
paveGrid(-10.1, 10.1, -13.8, -6.05, 27, 12, "#baa383");
// A pale stepped-stone route from the foreground doorway to the piazza.
box(1.28, 0.13, 0.76, -2.22, 0.23, 9.65, M.route);
box(1.3, 0.13, 0.76, -1.48, 0.23, 9.08, M.route);
for (let i = 0; i < 19; i++) {
const z = 8.38 - i * 0.98;
const x = i % 2 === 0 ? -0.05 : 0.05;
box(1.56, 0.14, 0.76, x, 0.235, z, M.route);
}
// Small route markers at the piazza entrance.
box(0.24, 0.2, 0.24, -0.83, 0.29, -6.15, M.ochre);
box(0.24, 0.2, 0.24, 0.83, 0.29, -6.15, M.ochre);
// -------------------------------------------------------------------------
// Architecture helpers
// -------------------------------------------------------------------------
function southWindow(x, frontZ, y, shutterMaterial = M.shutterGreen) {
box(1.02, 1.38, 0.1, x, y, frontZ + 0.055, M.dark);
box(0.78, 1.12, 0.035, x, y + 0.03, frontZ + 0.12, M.window);
box(0.06, 1.18, 0.06, x, y + 0.03, frontZ + 0.16, M.cream);
box(0.82, 0.06, 0.06, x, y + 0.05, frontZ + 0.16, M.cream);
box(1.3, 0.12, 0.31, x, y - 0.75, frontZ + 0.08, M.stone);
box(0.35, 1.44, 0.12, x - 0.69, y, frontZ + 0.1, shutterMaterial);
box(0.35, 1.44, 0.12, x + 0.69, y, frontZ + 0.1, shutterMaterial);
for (let i = 0; i < 4; i++) {
box(0.035, 1.26, 0.035, x - 0.79 + i * 0.18, y, frontZ + 0.18, M.woodDark);
box(0.035, 1.26, 0.035, x + 0.51 + i * 0.18, y, frontZ + 0.18, M.woodDark);
}
}
function sideWindow(x, z, y, face, shutterMaterial = M.shutterGreen) {
box(0.1, 1.32, 1.0, x, y, z, M.dark);
box(0.035, 1.08, 0.76, x + face * 0.065, y + 0.03, z, M.window);
box(0.12, 0.12, 1.26, x + face * 0.08, y - 0.73, z, M.stone);
box(0.12, 1.39, 0.33, x + face * 0.1, y, z - 0.67, shutterMaterial);
box(0.12, 1.39, 0.33, x + face * 0.1, y, z + 0.67, shutterMaterial);
}
function balcony(x, frontZ, y, width = 1.8) {
box(width, 0.15, 0.72, x, y - 0.68, frontZ + 0.34, M.stone);
box(width, 0.08, 0.08, x, y - 0.2, frontZ + 0.66, M.dark);
for (let i = 0; i < 6; i++) {
box(0.045, 0.48, 0.045,
x - width / 2 + 0.12 + i * (width - 0.24) / 5,
y - 0.43,
frontZ + 0.66,
M.dark
);
}
}
function building({
x,
z,
w,
d,
h,
color,
roofMaterial = M.roof,
side = "none",
windows = true,
doorX = null,
floors = null
}) {
const wall = material(color);
const frontZ = z + d / 2;
box(w, h, d, x, h / 2, z, wall);
box(w + 0.16, 0.42, d + 0.16, x, 0.27, z, M.stoneDark);
box(w + 0.3, 0.22, d + 0.3, x, h + 0.08, z, M.cream);
box(w + 0.16, 0.24, d + 0.16, x, h + 0.29, z, roofMaterial);
const tileRows = Math.max(3, Math.floor(d / 0.72));
for (let i = 0; i < tileRows; i++) {
box(
w - 0.18,
0.1,
0.39,
x,
h + 0.45,
z - d / 2 + 0.38 + i * ((d - 0.75) / (tileRows - 1)),
i % 3 === 0 ? M.roofLight : roofMaterial
);
}
box(0.62, 1.6, 0.68, x + w * 0.27, h + 1.1, z - d * 0.22, M.brick);
box(0.75, 0.16, 0.8, x + w * 0.27, h + 1.96, z - d * 0.22, M.roofDark);
if (windows) {
const floorCount = floors ?? Math.max(1, Math.floor((h - 1.1) / 2.65));
const columns = Math.max(1, Math.floor(w / 2.25));
for (let floor = 0; floor < floorCount; floor++) {
const y = 2.08 + floor * 2.65;
if (y + 0.8 > h) continue;
for (let col = 0; col < columns; col++) {
const wx =
x - w / 2 + (w / (columns + 1)) * (col + 1);
if (
floor === 0 &&
doorX !== null &&
Math.abs(wx - doorX) < 1.15
) {
continue;
}
southWindow(wx, frontZ, y);
if (floor > 0 && col % 2 === 0) {
balcony(wx, frontZ, y, 1.7);
}
}
}
if (side !== "none") {
const face = side === "east" ? 1 : -1;
const sideX = x + face * (w / 2 + 0.035);
const sideFloors = Math.max(1, Math.floor((h - 1.2) / 3));
for (let floor = 0; floor < sideFloors; floor++) {
const y = 2.2 + floor * 3;
if (y + 0.75 < h) {
sideWindow(sideX, z + 0.15, y, face);
}
}
}
}
return { frontZ };
}
// Lane buildings.
building({
x: -4.6, z: 6.8, w: 5.4, d: 6.4, h: 8.4,
color: "#e2bc83", side: "east", doorX: -2.55
});
building({
x: -5.0, z: 1.0, w: 5.4, d: 5.4, h: 7.4,
color: "#cf8f72", side: "east"
});
building({
x: -5.0, z: -3.35, w: 5.5, d: 4.2, h: 6.8,
color: "#d6bd82", side: "east"
});
building({
x: 4.7, z: 7.5, w: 5.4, d: 5.2, h: 7.3,
color: "#d99572", side: "west"
});
building({
x: 5.0, z: 1.0, w: 5.2, d: 5.8, h: 7.9,
color: "#e4c993", side: "west"
});
building({
x: 5.15, z: -3.25, w: 5.2, d: 4.2, h: 8.0,
color: "#b9b38a", side: "west"
});
// Piazza-facing buildings.
building({
x: -5.2, z: -13.0, w: 9.0, d: 4.0, h: 8.2,
color: "#d6ad76", windows: false
});
building({
x: 4.55, z: -13.7, w: 7.6, d: 4.2, h: 8.8,
color: "#d9c39a", windows: false
});
// -------------------------------------------------------------------------
// The blue doorway and its threshold
// -------------------------------------------------------------------------
const doorZ = 10.06;
box(1.62, 2.9, 0.18, -2.55, 1.48, doorZ, M.paleStone);
box(1.25, 2.53, 0.11, -2.55, 1.3, doorZ + 0.08, M.dark);
box(0.08, 2.52, 0.08, -2.55, 1.3, doorZ + 0.16, M.woodDark);
box(1.18, 0.1, 0.08, -2.55, 1.25, doorZ + 0.16, M.woodDark);
// The open door panel, rotated around its hinge.
const doorPivot = group(-3.18, 0, doorZ + 0.12);
doorPivot.rotation.y = -0.88;
box(1.1, 2.48, 0.13, 0.55, 1.3, 0, M.shutterBlue);
box(0.82, 0.88, 0.05, 0.55, 1.73, 0.08, M.windowLight);
box(0.08, 0.85, 0.05, 0.55, 1.73, 0.12, M.shutterBlue);
box(0.08, 0.06, 0.14, 0.97, 1.08, 0.13, M.ochre);
box(1.95, 0.18, 0.78, -2.55, 0.2, 10.45, M.paleStone);
box(1.7, 0.13, 0.62, -2.55, 0.38, 10.43, M.stone);
box(1.9, 0.14, 0.72, -2.55, 2.98, doorZ + 0.01, M.cream);
// Lamp over the doorway.
box(0.12, 0.12, 0.38, -2.55, 3.35, doorZ + 0.15, M.dark);
box(0.34, 0.44, 0.34, -2.55, 3.13, doorZ + 0.31, M.ochre);
box(0.27, 0.32, 0.27, -2.55, 3.13, doorZ + 0.33, M.cream);
// -------------------------------------------------------------------------
// Stylized bell tower: a visual anchor for Piazza Santa Maria
// -------------------------------------------------------------------------
const towerX = 7.55;
const towerZ = -13.9;
box(3.35, 11.9, 3.55, towerX, 5.95, towerZ, M.plasterCream);
box(3.62, 0.45, 3.82, towerX, 0.28, towerZ, M.stoneDark);
box(3.6, 0.28, 3.8, towerX, 8.45, towerZ, M.cream);
box(3.5, 3.05, 3.7, towerX, 10.05, towerZ, M.plasterOchre);
box(3.8, 0.27, 4.0, towerX, 11.65, towerZ, M.cream);
// Belfry openings.
box(0.72, 1.6, 0.12, towerX - 0.72, 10.2, towerZ + 1.88, M.dark);
box(0.72, 1.6, 0.12, towerX + 0.72, 10.2, towerZ + 1.88, M.dark);
box(0.12, 1.6, 0.72, towerX + 1.68, 10.2, towerZ - 0.68, M.dark);
// Stepped terracotta roof.
box(3.65, 0.28, 3.85, towerX, 11.9, towerZ, M.roof);
box(3.05, 0.35, 3.25, towerX, 12.18, towerZ, M.roofLight);
box(2.45, 0.38, 2.65, towerX, 12.53, towerZ, M.roof);
box(1.85, 0.4, 2.05, towerX, 12.9, towerZ, M.roofLight);
box(1.25, 0.42, 1.45, towerX, 13.3, towerZ, M.roof);
box(0.72, 0.44, 0.9, towerX, 13.7, towerZ, M.roofDark);
box(0.12, 0.9, 0.12, towerX, 14.35, towerZ, M.dark);
box(0.62, 0.12, 0.12, towerX, 14.62, towerZ, M.dark);
// Brick corner details.
for (let i = 0; i < 9; i++) {
const y = 1.1 + i * 0.95;
box(0.52, 0.38, 0.12, towerX - 1.52, y, towerZ + 1.81, M.brick);
box(0.52, 0.38, 0.12, towerX + 1.52, y, towerZ + 1.81, M.brick);
}
// -------------------------------------------------------------------------
// Original café furniture and façade
// -------------------------------------------------------------------------
function makeSign(text, x, y, z, w, h, bg = "#36594b", fg = "#fff2d6") {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 192;
const ctx = canvas.getContext("2d");
ctx.fillStyle = bg;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = fg;
ctx.lineWidth = 8;
ctx.strokeRect(14, 14, canvas.width - 28, canvas.height - 28);
ctx.fillStyle = fg;
ctx.font = "bold 58px Georgia";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, canvas.width / 2, canvas.height / 2 + 2);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sign = new THREE.Mesh(
new THREE.PlaneGeometry(w, h),
new THREE.MeshBasicMaterial({ map: texture })
);
sign.position.set(x, y, z);
scene.add(sign);
return sign;
}
makeSign("CAFFÈ DEL VICOLO", -5.2, 3.68, -10.87, 4.6, 0.78);
// Striped, block-built awning.
for (let i = 0; i < 8; i++) {
box(
0.58,
0.16,
1.45,
-7.35 + i * 0.58,
3.08,
-10.18,
i % 2 === 0 ? M.red : M.cream
);
}
box(4.72, 0.24, 0.18, -5.2, 3.0, -9.43, M.woodDark);
// Café counter and its small espresso corner.
box(3.55, 1.05, 0.85, -5.2, 0.65, -9.72, M.shutterGreen);
box(3.8, 0.16, 1.08, -5.2, 1.24, -9.7, M.cream);
box(0.72, 0.52, 0.46, -5.55, 1.56, -9.75, M.silver);
box(0.48, 0.18, 0.34, -5.55, 1.9, -9.73, M.dark);
box(0.18, 0.2, 0.18, -4.8, 1.48, -9.72, M.cream);
box(0.22, 0.28, 0.22, -4.36, 1.53, -9.72, M.ochre);
function cafeTable(x, z, tableMaterial = M.woodLight) {
const g = group(x, 0, z);
box(0.95, 0.13, 0.95, 0, 1.02, 0, tableMaterial);
box(0.17, 0.87, 0.17, 0, 0.54, 0, M.dark);
box(0.57, 0.1, 0.57, 0, 0.11, 0, M.dark);
box(0.15, 0.15, 0.15, 0.23, 1.17, -0.16, M.cream);
box(0.16, 0.05, 0.16, 0.23, 1.26, -0.16, M.red);
return g;
}
function cafeChair(x, z, rotation = 0, chairMaterial = M.shutterGreen) {
const g = group(x, 0, z);
g.rotation.y = rotation;
box(0.62, 0.12, 0.61, 0, 0.58, 0, chairMaterial);
box(0.62, 0.73, 0.12, 0, 0.94, -0.26, chairMaterial);
for (const sx of [-0.22, 0.22]) {
for (const sz of [-0.22, 0.22]) {
box(0.075, 0.52, 0.075, sx, 0.29, sz, M.dark);
}
}
return g;
}
cafeTable(-7.65, -7.05);
cafeChair(-8.45, -7.05, Math.PI / 2);
cafeChair(-6.85, -7.05, -Math.PI / 2);
cafeTable(-4.7, -7.05, M.ochre);
cafeChair(-5.5, -7.05, Math.PI / 2, M.red);
cafeChair(-3.9, -7.05, -Math.PI / 2, M.red);
cafeTable(-7.55, -9.45, M.woodLight);
cafeChair(-8.35, -9.45, Math.PI / 2, M.shutterGreen);
cafeChair(-6.75, -9.45, -Math.PI / 2, M.shutterGreen);
// -------------------------------------------------------------------------
// Voxel fountain, benches, planters, and street details
// -------------------------------------------------------------------------
const fountain = group(4.65, 0, -9.25);
box(3.5, 0.3, 3.5, 0, 0.26, 0, M.stoneDark);
box(3.05, 0.25, 3.05, 0, 0.49, 0, M.stone);
box(2.7, 0.08, 2.7, 0, 0.65, 0, M.water);
box(0.38, 0.55, 2.75, -1.3, 0.68, 0, M.stone);
box(0.38, 0.55, 2.75, 1.3, 0.68, 0, M.stone);
box(2.25, 0.55, 0.38, 0, 0.68, -1.3, M.stone);
box(2.25, 0.55, 0.38, 0, 0.68, 1.3, M.stone);
box(0.62, 1.65, 0.62, 0, 1.35, 0, M.stone);
box(1.75, 0.23, 1.75, 0, 2.2, 0, M.stoneDark);
box(1.42, 0.08, 1.42, 0, 2.34, 0, M.water);
for (const sx of [-0.56, 0.56]) {
box(0.16, 0.65, 0.16, sx, 1.55, 0, M.water);
}
const fountainWater = fountain.children.find(
child => child.geometry?.parameters?.width === 2.7
);
function bench(x, z, rotation = 0) {
const g = group(x, 0, z);
g.rotation.y = rotation;
for (let i = 0; i < 3; i++) {
box(2.2, 0.12, 0.19, 0, 0.64, -0.24 + i * 0.24, M.wood);
}
for (let i = 0; i < 3; i++) {
box(2.2, 0.16, 0.1, 0, 1.02 + i * 0.25, -0.33, M.wood);
}
box(0.16, 0.58, 0.62, -0.85, 0.3, 0, M.dark);
box(0.16, 0.58, 0.62, 0.85, 0.3, 0, M.dark);
}
bench(7.45, -6.35, Math.PI / 2);
bench(-8.8, -6.35, Math.PI / 2);
function planter(x, z, size = 1, foliage = M.green) {
const g = group(x, 0, z);
box(size * 0.72, size * 0.62, size * 0.72, 0, size * 0.31, 0, M.roof);
box(size * 0.8, size * 0.11, size * 0.8, 0, size * 0.64, 0, M.roofLight);
box(size * 0.78, size * 0.65, size * 0.72, 0, size * 1.02, 0, foliage);
box(size * 0.52, size * 0.48, size * 0.62, -size * 0.18, size * 1.48, 0.05, M.greenLight);
box(size * 0.42, size * 0.38, size * 0.48, size * 0.28, size * 1.42, -0.08, foliage);
return g;
}
planter(-2.0, 5.85, 0.82);
planter(2.1, 5.9, 0.78, M.greenLight);
planter(-8.45, -5.75, 0.88);
planter(8.65, -7.0, 1.05);
// Small street tree.
const tree = group(-8.65, 0, -10.7);
box(0.42, 3.8, 0.42, 0, 1.9, 0, M.woodDark);
box(2.6, 1.25, 2.25, 0, 3.9, 0, M.greenDark);
box(1.85, 1.05, 1.8, -0.65, 4.75, 0.15, M.green);
box(1.5, 0.9, 1.45, 0.72, 4.65, -0.2, M.greenLight);
box(1.25, 0.7, 1.25, 0.05, 5.3, 0.1, M.green);
// Street lamp.
box(0.14, 3.9, 0.14, -2.23, 1.95, 3.5, M.dark);
box(0.38, 0.16, 0.38, -2.23, 0.12, 3.5, M.dark);
box(0.42, 0.14, 0.42, -2.23, 3.85, 3.5, M.dark);
box(0.34, 0.52, 0.34, -2.23, 4.12, 3.5, M.ochre);
box(0.26, 0.4, 0.26, -2.23, 4.12, 3.5, M.cream);
// Laundry line across the lane.
box(4.6, 0.035, 0.035, 0, 5.45, -0.75, M.dark);
box(0.15, 5.45, 0.15, -2.25, 2.73, -0.75, M.dark);
box(0.15, 5.45, 0.15, 2.25, 2.73, -0.75, M.dark);
const laundry = [
[-1.65, M.shirtWhite, 0.58, 0.78],
[-0.75, M.blue, 0.7, 0.62],
[0.2, M.ochre, 0.5, 0.74],
[1.0, M.shutterGreen, 0.63, 0.57],
[1.7, M.cream, 0.44, 0.68]
];
for (const [x, mat, w, h] of laundry) {
box(w, h, 0.055, x, 5.36 - h / 2, -0.75, mat);
box(0.08, 0.14, 0.07, x - w * 0.3, 5.39, -0.72, M.woodDark);
box(0.08, 0.14, 0.07, x + w * 0.3, 5.39, -0.72, M.woodDark);
}
// -------------------------------------------------------------------------
// Residents
// -------------------------------------------------------------------------
const people = [];
function makePerson({
x,
z,
shirt = M.blue,
pants = M.denim,
skin = M.skin1,
hair = M.hair1,
rotation = 0,
scale = 1,
walking = false,
phase = 0
}) {
const g = group(x, 0, z);
g.rotation.y = rotation;
g.scale.setScalar(scale);
box(0.66, 0.82, 0.4, 0, 1.15, 0, shirt);
box(0.18, 0.22, 0.2, 0, 1.67, 0, skin);
box(0.5, 0.49, 0.48, 0, 1.96, 0, skin);
box(0.53, 0.18, 0.51, 0, 2.2, 0.01, hair);
box(0.1, 0.12, 0.13, 0, 1.96, -0.27, skin);
box(0.07, 0.06, 0.035, -0.13, 2.03, -0.255, M.dark);
box(0.07, 0.06, 0.035, 0.13, 2.03, -0.255, M.dark);
const legL = group(-0.18, 0.76, 0, g);
const legR = group(0.18, 0.76, 0, g);
box(0.23, 0.61, 0.25, 0, -0.3, 0, pants, legL);
box(0.23, 0.61, 0.25, 0, -0.3, 0, pants, legR);
box(0.27, 0.15, 0.41, 0, -0.66, -0.07, M.dark, legL);
box(0.27, 0.15, 0.41, 0, -0.66, -0.07, M.dark, legR);
const armL = group(-0.43, 1.48, 0, g);
const armR = group(0.43, 1.48, 0, g);
box(0.18, 0.64, 0.2, 0, -0.3, 0, shirt, armL);
box(0.18, 0.64, 0.2, 0, -0.3, 0, shirt, armR);
box(0.17, 0.16, 0.18, 0, -0.68, 0, skin, armL);
box(0.17, 0.16, 0.18, 0, -0.68, 0, skin, armR);
people.push({
group: g,
legL,
legR,
armL,
armR,
baseX: x,
baseZ: z,
phase,
walking
});
return g;
}
makePerson({
x: 1.55, z: 1.25,
shirt: M.blue, pants: M.stoneDark,
hair: M.hair2, scale: 0.92,
walking: true, phase: 0.4
});
makePerson({
x: 2.2, z: 4.35,
shirt: M.ochre, pants: M.woodDark,
skin: M.skin2, hair: M.hair1,
scale: 0.96, phase: 1.4
});
makePerson({
x: 2.15, z: -5.9,
shirt: M.shutterGreen, pants: M.woodDark,
skin: M.skin3, hair: M.hair2,
scale: 0.87, phase: 2.2
});
makePerson({
x: -8.45, z: -8.7,
shirt: M.red, pants: M.denim,
skin: M.skin2, hair: M.hair1,
rotation: 0.25, scale: 0.9, phase: 2.8
});
// A seated café regular.
const seated = group(-4.7, 0, -6.42);
box(0.58, 0.72, 0.4, 0, 1.02, 0, M.cream, seated);
box(0.48, 0.45, 0.46, 0, 1.61, 0, M.skin2, seated);
box(0.5, 0.16, 0.49, 0, 1.84, 0.01, M.hair2, seated);
box(0.19, 0.53, 0.25, -0.37, 1.15, 0, M.cream, seated);
box(0.19, 0.53, 0.25, 0.37, 1.15, 0, M.cream, seated);
box(0.22, 0.2, 0.58, -0.17, 0.7, -0.35, M.denim, seated);
box(0.22, 0.2, 0.58, 0.17, 0.7, -0.35, M.denim, seated);
// -------------------------------------------------------------------------
// Delivery handcart
// -------------------------------------------------------------------------
const cart = group(2.05, 0, 2.95);
cart.rotation.y = 0.035;
box(1.72, 0.2, 1.35, 0, 0.83, 0, M.woodLight, cart);
box(1.76, 0.36, 0.12, 0, 1.07, -0.62, M.wood, cart);
box(1.76, 0.36, 0.12, 0, 1.07, 0.62, M.wood, cart);
box(0.12, 0.36, 1.18, -0.83, 1.07, 0, M.wood, cart);
box(0.12, 0.36, 1.18, 0.83, 1.07, 0, M.wood, cart);
// Squared, deliberately voxel-like wheels.
for (const side of [-1, 1]) {
box(0.19, 0.7, 0.7, side * 0.94, 0.38, -0.12, M.black, cart);
box(0.23, 0.2, 0.2, side * 1.03, 0.38, -0.12, M.ochre, cart);
box(0.18, 0.4, 0.4, side * 0.94, 0.38, -0.12, M.metal, cart);
}
// Handles.
for (const side of [-0.66, 0.66]) {
box(0.12, 0.12, 1.8, side, 0.95, 1.3, M.woodDark, cart);
}
box(1.42, 0.12, 0.12, 0, 0.95, 2.12, M.woodDark, cart);
// Crates and produce.
box(0.75, 0.55, 0.68, -0.36, 1.19, -0.15, M.wood, cart);
box(0.75, 0.55, 0.68, 0.38, 1.19, 0.18, M.woodLight, cart);
box(0.85, 0.18, 0.75, -0.36, 1.5, -0.15, M.woodDark, cart);
box(0.85, 0.18, 0.75, 0.38, 1.5, 0.18, M.woodDark, cart);
for (let i = 0; i < 4; i++) {
box(
0.22, 0.22, 0.22,
-0.55 + (i % 2) * 0.35,
1.63,
-0.32 + Math.floor(i / 2) * 0.34,
M.tomato,
cart
);
}
for (let i = 0; i < 3; i++) {
box(
0.48, 0.23, 0.25,
0.19 + i * 0.09,
1.69,
0.04 + i * 0.06,
M.bread,
cart
);
}
// -------------------------------------------------------------------------
// Small piazza life: pigeons and a crate-side cat
// -------------------------------------------------------------------------
function pigeon(x, z, rotation = 0) {
const g = group(x, 0.3, z);
g.rotation.y = rotation;
box(0.3, 0.26, 0.48, 0, 0, 0, M.stoneDark, g);
box(0.23, 0.23, 0.23, 0, 0.18, -0.2, M.stone, g);
box(0.09, 0.08, 0.13, 0, 0.16, -0.37, M.ochre, g);
box(0.09, 0.05, 0.15, 0.1, 0.26, -0.14, M.windowLight, g);
box(0.09, 0.05, 0.15, -0.1, 0.26, -0.14, M.windowLight, g);
}
pigeon(3.1, -8.3, 0.4);
pigeon(5.65, -10.1, -0.7);
pigeon(6.0, -9.85, 0.2);
const cat = group(3.9, 0.32, -6.65);
box(0.48, 0.32, 0.75, 0, 0, 0, M.woodDark, cat);
box(0.38, 0.36, 0.38, 0, 0.26, -0.33, M.woodDark, cat);
box(0.11, 0.14, 0.08, -0.12, 0.47, -0.34, M.woodDark, cat);
box(0.11, 0.14, 0.08, 0.12, 0.47, -0.34, M.woodDark, cat);
box(0.12, 0.42, 0.12, 0, 0.17, 0.43, M.woodDark, cat);
// -------------------------------------------------------------------------
// Voxel sky details
// -------------------------------------------------------------------------
const cloudMaterial = material("#f6f3e7");
function cloud(x, y, z, scale = 1) {
const g = group(x, y, z);
box(2.7 * scale, 0.8 * scale, 1.1 * scale, 0, 0, 0, cloudMaterial, g);
box(1.3 * scale, 1.1 * scale, 1.0 * scale, -0.9 * scale, 0.35 * scale, 0, cloudMaterial, g);
box(1.5 * scale, 1.35 * scale, 1.0 * scale, 0.65 * scale, 0.4 * scale, 0, cloudMaterial, g);
box(1.0 * scale, 0.75 * scale, 0.9 * scale, 1.55 * scale, 0.05 * scale, 0, cloudMaterial, g);
}
cloud(-12, 17, -20, 1.4);
cloud(12, 15, -25, 1.1);
cloud(1, 19, -30, 0.8);
box(2.3, 2.3, 0.55, -16, 16.5, -24, material("#f4d991"));
// -------------------------------------------------------------------------
// Custom camera controls — no external controls/addons
// -------------------------------------------------------------------------
const defaultView = {
yaw: 0.57,
pitch: 0.63,
zoom: 1,
target: new THREE.Vector3(0, 2.0, -1.5)
};
let yaw = defaultView.yaw;
let pitch = defaultView.pitch;
let zoom = defaultView.zoom;
const target = defaultView.target.clone();
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
let touring = false;
let tourStart = 0;
const tourCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-2.55, 1.65, 10.2),
new THREE.Vector3(-0.8, 1.65, 8.8),
new THREE.Vector3(0, 1.65, 5.0),
new THREE.Vector3(0, 1.65, 0.0),
new THREE.Vector3(0, 1.65, -4.7),
new THREE.Vector3(0, 1.65, -8.5)
]);
function updateCamera() {
const radius = 42;
const horizontal = radius * Math.cos(pitch);
camera.position.set(
target.x + horizontal * Math.sin(yaw),
target.y + radius * Math.sin(pitch),
target.z + horizontal * Math.cos(yaw)
);
camera.lookAt(target);
camera.zoom = zoom;
camera.updateProjectionMatrix();
}
function stopTour() {
if (!touring) return;
touring = false;
tourButton.textContent = "Walk the route";
tourButton.classList.remove("active");
}
renderer.domElement.addEventListener("pointerdown", event => {
if (event.pointerType === "mouse" && event.button !== 0) return;
stopTour();
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
yaw -= dx * 0.006;
pitch = THREE.MathUtils.clamp(pitch + dy * 0.0045, 0.3, 1.12);
lastPointerX = event.clientX;
lastPointerY = event.clientY;
updateCamera();
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
stopTour();
zoom = THREE.MathUtils.clamp(
zoom * Math.exp(-event.deltaY * 0.001),
0.72,
2.25
);
updateCamera();
},
{ passive: false }
);
const resetButton = document.getElementById("resetButton");
const tourButton = document.getElementById("tourButton");
const zoomInButton = document.getElementById("zoomInButton");
const zoomOutButton = document.getElementById("zoomOutButton");
resetButton.addEventListener("click", () => {
stopTour();
yaw = defaultView.yaw;
pitch = defaultView.pitch;
zoom = defaultView.zoom;
target.copy(defaultView.target);
updateCamera();
});
zoomInButton.addEventListener("click", () => {
stopTour();
zoom = THREE.MathUtils.clamp(zoom * 1.15, 0.72, 2.25);
updateCamera();
});
zoomOutButton.addEventListener("click", () => {
stopTour();
zoom = THREE.MathUtils.clamp(zoom / 1.15, 0.72, 2.25);
updateCamera();
});
tourButton.addEventListener("click", () => {
if (touring) {
stopTour();
return;
}
touring = true;
tourStart = performance.now();
tourButton.textContent = "Stop walking";
tourButton.classList.add("active");
});
window.addEventListener("keydown", event => {
if (event.key.toLowerCase() === "r") {
resetButton.click();
}
});
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const viewHeight = aspect < 1 ? 31 / aspect : 27;
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();
// -------------------------------------------------------------------------
// World-space labels
// -------------------------------------------------------------------------
const labels = [
{
element: document.getElementById("doorLabel"),
position: new THREE.Vector3(-2.55, 3.75, 10.1)
},
{
element: document.getElementById("cafeLabel"),
position: new THREE.Vector3(-5.2, 4.25, -9.9)
},
{
element: document.getElementById("piazzaLabel"),
position: new THREE.Vector3(1.5, 0.8, -6.7)
},
{
element: document.getElementById("cartLabel"),
position: new THREE.Vector3(2.05, 2.1, 2.9)
}
];
const projected = new THREE.Vector3();
function updateLabels() {
for (const label of labels) {
projected.copy(label.position).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.1 &&
Math.abs(projected.y) < 1.1;
label.element.style.opacity = visible ? "1" : "0";
label.element.style.left =
`${(projected.x * 0.5 + 0.5) * window.innerWidth}px`;
label.element.style.top =
`${(-projected.y * 0.5 + 0.5) * window.innerHeight}px`;
}
}
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate(now) {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
// Gentle resident movement, kept off the marked route.
for (const person of people) {
if (person.walking) {
const swing = Math.sin(elapsed * 5.4 + person.phase) * 0.48;
person.legL.rotation.x = swing;
person.legR.rotation.x = -swing;
person.armL.rotation.x = -swing * 0.75;
person.armR.rotation.x = swing * 0.75;
person.group.position.z = person.baseZ + Math.sin(elapsed * 0.7 + person.phase) * 0.18;
} else {
const breathing = Math.sin(elapsed * 1.5 + person.phase) * 0.025;
person.group.position.y = breathing;
}
}
if (fountainWater) {
fountainWater.position.y = 0.65 + Math.sin(elapsed * 2.1) * 0.012;
}
M.route.emissiveIntensity =
0.11 + (Math.sin(elapsed * 2.2) * 0.5 + 0.5) * 0.13;
if (touring) {
const progress = THREE.MathUtils.clamp(
(now - tourStart) / 11500,
0,
1
);
const eased = progress * progress * (3 - 2 * progress);
tourCurve.getPointAt(eased, target);
yaw = THREE.MathUtils.lerp(0.57, 0.2, eased);
pitch = THREE.MathUtils.lerp(0.63, 0.74, eased);
zoom = THREE.MathUtils.lerp(1, 1.16, eased);
updateCamera();
if (progress >= 1) {
stopTour();
}
}
updateLabels();
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
document.getElementById("loading").classList.add("hidden");
</script>
</body>
</html>
```