Prompt specification
Build or customize the Three.js 3D scene "Bellavista block at the foot of the hill" 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: Bellavista block at the foot of the hill
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/bellavista-block-at-the-foot-of-the-hill-x2791
Scene Description Prompt:
Please use Three.js from cdnjs for a voxel scene based on this idea: Bellavista block at the foot of the hill. Build a bounded voxel scene with referenced low-rise facades, cultural storefronts, trees, and steep green background. Use original venue names and preserve the street's human scale. Return one self-contained HTML file.
Working Three.js Starter (bellavista-block-at-the-foot-of-the-hill-x2791):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#dbe5dc" />
<title>Bellavista at the Hill’s Foot — Voxel Neighborhood</title>
<style>
:root {
--ink: #26352f;
--paper: rgba(250, 247, 237, 0.92);
--line: rgba(38, 53, 47, 0.16);
--accent: #d56349;
--shadow: 0 18px 55px rgba(37, 53, 46, 0.16);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dbe5dc;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#viewport,
#viewport canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
}
.title-card {
position: fixed;
z-index: 5;
top: 22px;
left: 24px;
width: min(390px, calc(100vw - 48px));
padding: 18px 20px 17px;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 16px;
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 7px;
color: #758078;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 38px);
font-weight: 850;
letter-spacing: -0.045em;
line-height: 0.98;
}
h1 span {
display: block;
margin-top: 7px;
color: #617068;
font-size: 0.47em;
font-weight: 650;
letter-spacing: -0.02em;
}
.title-card p {
margin: 12px 0 0;
max-width: 330px;
color: #657168;
font-size: 12px;
line-height: 1.45;
}
.controls {
position: fixed;
z-index: 6;
top: 22px;
right: 24px;
display: flex;
gap: 8px;
}
button {
appearance: none;
border: 1px solid rgba(255, 255, 255, 0.78);
border-radius: 12px;
padding: 11px 14px;
background: var(--paper);
color: var(--ink);
box-shadow: 0 8px 24px rgba(37, 53, 46, 0.12);
font: inherit;
font-size: 12px;
font-weight: 750;
cursor: pointer;
backdrop-filter: blur(12px);
transition:
transform 150ms ease,
background 150ms ease;
}
button:hover {
transform: translateY(-1px);
background: #fffdf6;
}
button:active {
transform: translateY(1px);
}
.venue-card {
position: fixed;
z-index: 7;
left: 24px;
bottom: 24px;
width: min(340px, calc(100vw - 48px));
padding: 18px 44px 18px 18px;
border: 1px solid rgba(255, 255, 255, 0.78);
border-radius: 16px;
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(12px);
opacity: 0;
transform: translateY(12px);
pointer-events: none;
transition:
opacity 180ms ease,
transform 180ms ease;
}
.venue-card.show {
opacity: 1;
transform: translateY(0);
pointer-events: auto;
}
.venue-card .venue-type {
color: var(--accent);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.venue-card h2 {
margin: 5px 0 7px;
font-size: 23px;
letter-spacing: -0.035em;
}
.venue-card p {
margin: 0;
color: #647169;
font-size: 12px;
line-height: 1.55;
}
.venue-card .venue-meta {
margin-top: 10px;
color: #8b928c;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.close {
position: absolute;
top: 10px;
right: 10px;
width: 30px;
height: 30px;
padding: 0;
border: 0;
border-radius: 50%;
background: rgba(38, 53, 47, 0.08);
box-shadow: none;
font-size: 17px;
}
.hint {
position: fixed;
z-index: 5;
right: 24px;
bottom: 24px;
padding: 10px 13px;
border: 1px solid rgba(255, 255, 255, 0.65);
border-radius: 11px;
background: rgba(250, 247, 237, 0.8);
color: #68736c;
box-shadow: 0 8px 25px rgba(37, 53, 46, 0.1);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.035em;
pointer-events: none;
backdrop-filter: blur(10px);
}
#loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-content: center;
gap: 14px;
background: #dbe5dc;
color: #58675f;
text-align: center;
transition: opacity 400ms ease;
}
#loading.gone {
opacity: 0;
pointer-events: none;
}
.loader {
width: 38px;
height: 38px;
margin: auto;
border: 4px solid rgba(38, 53, 47, 0.12);
border-top-color: var(--accent);
border-radius: 50%;
animation: spin 800ms linear infinite;
}
#loading span {
font-size: 11px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@media (max-width: 720px) {
.title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 14px 16px;
}
.title-card p {
display: none;
}
.controls {
top: auto;
right: 12px;
bottom: 12px;
flex-direction: column;
}
.hint {
display: none;
}
.venue-card {
left: 12px;
bottom: 74px;
width: calc(100vw - 24px);
}
}
</style>
</head>
<body>
<div id="viewport"></div>
<section class="title-card">
<div class="eyebrow">Voxel neighborhood study · Five original venues</div>
<h1>Bellavista <span>at the foot of the green hill</span></h1>
<p>A bounded street diorama of low-rise facades, cultural storefronts, shaded trees, and a steep urban edge.</p>
</section>
<nav class="controls" aria-label="Scene controls">
<button id="duskButton" type="button" aria-pressed="false">Dusk light</button>
<button id="resetButton" type="button">Reset view</button>
</nav>
<aside id="venueCard" class="venue-card" aria-live="polite">
<button id="closeCard" class="close" type="button" aria-label="Close venue details">×</button>
<div id="venueType" class="venue-type"></div>
<h2 id="venueTitle"></h2>
<p id="venueText"></p>
<div id="venueMeta" class="venue-meta"></div>
</aside>
<div class="hint">Drag to orbit · Wheel or pinch to zoom · Click a venue</div>
<div id="loading">
<div class="loader"></div>
<span>Building the neighborhood</span>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const viewport = document.getElementById("viewport");
const scene = new THREE.Scene();
const daySky = new THREE.Color("#dbe5dc");
const duskSky = new THREE.Color("#59667a");
scene.background = daySky.clone();
scene.fog = new THREE.Fog(daySky.clone(), 58, 112);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute("aria-label", "Interactive voxel neighborhood diorama");
viewport.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-20, 20, 20, -20, 0.1, 180);
const world = new THREE.Group();
scene.add(world);
const hemisphere = new THREE.HemisphereLight("#fff5dc", "#55705c", 1.75);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight("#fff0cf", 2.75);
sun.position.set(-19, 31, 22);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -32;
sun.shadow.camera.right = 32;
sun.shadow.camera.top = 30;
sun.shadow.camera.bottom = -24;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 90;
sun.shadow.bias = -0.0004;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const coolFill = new THREE.DirectionalLight("#b8d4ed", 0.55);
coolFill.position.set(22, 15, -18);
scene.add(coolFill);
const unitCube = new THREE.BoxGeometry(1, 1, 1);
const unitEdges = new THREE.EdgesGeometry(unitCube);
const edgeMaterial = new THREE.LineBasicMaterial({
color: "#263a31",
transparent: true,
opacity: 0.17
});
const materialCache = new Map();
const signMaterials = [];
const lampLights = [];
const venueMeshes = [];
function solidMaterial(color) {
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0.0
})
);
}
return materialCache.get(color);
}
function box(
parent,
x,
y,
z,
width,
height,
depth,
materialOrColor,
edges = false,
castShadow = true
) {
const material =
typeof materialOrColor === "string"
? solidMaterial(materialOrColor)
: materialOrColor;
const mesh = new THREE.Mesh(unitCube, material);
mesh.position.set(x, y, z);
mesh.scale.set(width, height, depth);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
if (edges) {
const outline = new THREE.LineSegments(unitEdges, edgeMaterial);
outline.renderOrder = 2;
mesh.add(outline);
}
return mesh;
}
const glassMaterial = new THREE.MeshStandardMaterial({
color: "#426a70",
roughness: 0.24,
metalness: 0.18,
emissive: "#ffbd70",
emissiveIntensity: 0
});
const lampGlowMaterial = new THREE.MeshStandardMaterial({
color: "#fff1b5",
emissive: "#ffb75a",
emissiveIntensity: 0.22,
roughness: 0.4
});
let seed = 38127;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function makeSign(
parent,
title,
subtitle,
x,
y,
z,
width,
height,
background = "#26352f",
foreground = "#fff6de"
) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const context = canvas.getContext("2d");
context.fillStyle = background;
context.fillRect(0, 0, canvas.width, canvas.height);
context.strokeStyle = foreground;
context.globalAlpha = 0.45;
context.lineWidth = 5;
context.strokeRect(14, 14, canvas.width - 28, canvas.height - 28);
context.globalAlpha = 1;
context.fillStyle = foreground;
context.textAlign = "center";
context.textBaseline = "middle";
let fontSize = 86;
context.font = `800 ${fontSize}px system-ui, sans-serif`;
while (context.measureText(title).width > 920 && fontSize > 42) {
fontSize -= 2;
context.font = `800 ${fontSize}px system-ui, sans-serif`;
}
context.fillText(title, 512, 102);
context.globalAlpha = 0.82;
context.font = "600 27px system-ui, sans-serif";
context.fillText(subtitle, 512, 185);
context.globalAlpha = 1;
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
const material = new THREE.MeshStandardMaterial({
map: texture,
roughness: 0.72,
emissive: "#ffffff",
emissiveMap: texture,
emissiveIntensity: 0
});
signMaterials.push(material);
const sign = new THREE.Mesh(new THREE.PlaneGeometry(width, height), material);
sign.position.set(x, y, z);
sign.castShadow = false;
sign.receiveShadow = true;
parent.add(sign);
return sign;
}
// ---------------------------------------------------------------------
// Bounded terrain base and street
// ---------------------------------------------------------------------
box(world, 0, -0.62, 0, 48, 1.24, 32, "#c5b58f", true);
box(world, 0, 0.015, 0, 47.85, 0.09, 31.8, "#d2c4a5");
box(world, 0, 0.12, 6.2, 47.8, 0.16, 7.6, "#4d5654", false, false);
box(world, 0, 0.17, 1.28, 47.8, 0.22, 2.35, "#d8cfb9", false, false);
box(world, 0, 0.17, 12.55, 47.8, 0.22, 5.45, "#ddd3bc", false, false);
box(world, 0, 0.25, 2.48, 47.8, 0.26, 0.22, "#eee3ca", false, false);
box(world, 0, 0.25, 9.96, 47.8, 0.26, 0.22, "#eee3ca", false, false);
const pavingSeam = "#b8aa8e";
for (let x = -23; x <= 23; x += 2) {
box(world, x, 0.24, 1.25, 0.045, 0.025, 2.1, pavingSeam, false, false);
box(world, x, 0.24, 12.6, 0.045, 0.025, 5.15, pavingSeam, false, false);
}
for (let x = -22; x < 24; x += 4.5) {
if (Math.abs(x - 12.5) < 4) continue;
box(world, x, 0.215, 6.2, 2.2, 0.035, 0.13, "#e8ddbb", false, false);
}
for (let z = 3.15; z < 9.7; z += 0.95) {
box(world, 12.5, 0.225, z, 3.3, 0.035, 0.48, "#eee7d2", false, false);
}
// Drain grates and utility details.
for (const x of [-17, -3, 7, 19]) {
box(world, x, 0.27, 2.37, 1.0, 0.05, 0.32, "#737873", false, false);
for (let i = 0; i < 5; i++) {
box(world, x - 0.38 + i * 0.19, 0.31, 2.37, 0.07, 0.035, 0.3, "#313936", false, false);
}
}
// ---------------------------------------------------------------------
// Steep terraced green hill
// ---------------------------------------------------------------------
const hillRows = [
{ z: -14.25, height: 12.4 },
{ z: -12.1, height: 8.7 },
{ z: -9.95, height: 4.55 }
];
const hillHeights = new Map();
const hillDark = ["#315d40", "#386b46", "#3d744c"];
const hillLight = ["#548657", "#62985b", "#73a761"];
for (const row of hillRows) {
for (let x = -23; x <= 23; x += 2) {
const wave = Math.sin(x * 0.31 + row.z * 0.2) * 1.05;
const height = Math.max(2.8, row.height + wave + (random() - 0.5) * 1.25);
hillHeights.set(`${x},${row.z}`, height);
let currentHeight = 0;
let layer = 0;
while (currentHeight < height - 0.01) {
const segment = Math.min(2, height - currentHeight);
const color = hillDark[(layer + Math.abs(x) / 2) % hillDark.length];
box(
world,
x,
currentHeight + segment / 2,
row.z,
2.03,
segment,
2.08,
color,
false,
false
);
currentHeight += segment;
layer++;
}
const cap = hillLight[Math.abs(Math.round(x / 2)) % hillLight.length];
box(
world,
x,
height + 0.12,
row.z,
2.05,
0.25,
2.09,
cap,
false,
false
);
}
}
// A stepped path climbing the right side of the hill.
for (let i = 0; i < 12; i++) {
const x = 15.4 + Math.sin(i * 0.75) * 1.25;
const z = -10.15 - i * 0.42;
const y = 4.45 + i * 0.72;
box(world, x, y, z, 1.45, 0.24, 0.72, "#b9ab83", false, false);
}
// ---------------------------------------------------------------------
// Trees and shrubs
// ---------------------------------------------------------------------
function makeTree(x, y, z, scale = 1, palette = 0) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
world.add(group);
const leafColors = [
["#477c47", "#5d914f", "#72a45a"],
["#3e7045", "#56854a", "#699c55"],
["#527d43", "#6b934e", "#82a95c"]
];
const leaves = leafColors[Math.floor(palette) % leafColors.length];
box(group, 0, 1.15, 0, 0.42, 2.3, 0.42, "#6f5840");
box(group, 0, 2.55, 0, 2.25, 1.55, 2.15, leaves[0]);
box(group, -0.85, 3.2, 0.1, 1.35, 1.25, 1.5, leaves[1]);
box(group, 0.88, 3.12, -0.05, 1.35, 1.25, 1.45, leaves[1]);
box(group, 0.05, 3.85, 0.05, 1.45, 1.15, 1.35, leaves[2]);
return group;
}
const hillTreeSpots = [
[-21, -14.25, 0.72],
[-17, -12.1, 0.68],
[-12, -14.25, 0.74],
[-2, -14.25, 0.65],
[3, -12.1, 0.7],
[8, -14.25, 0.68],
[13, -12.1, 0.7],
[19, -14.25, 0.73],
[22, -12.1, 0.64]
];
for (const [x, z, scale] of hillTreeSpots) {
const height = hillHeights.get(`${x},${z}`) || 5;
makeTree(x, height + 0.23, z, scale, Math.abs(x) / 3);
}
const streetTreeSpots = [-21.5, -6.5, 11.3, 22];
streetTreeSpots.forEach((x, index) => {
box(world, x, 0.27, 1.7, 1.55, 0.13, 1.55, "#665b48", false, false);
makeTree(x, 0.31, 1.7, 0.78 + (index % 2) * 0.06, index);
});
for (let i = 0; i < 28; i++) {
const x = -22 + random() * 44;
const z = -15.2 + random() * 6;
const height = hillHeights.get(`${Math.round(x / 2) * 2},${z}`) || 4;
box(
world,
x,
height + 0.45,
z,
0.45 + random() * 0.5,
0.55 + random() * 0.35,
0.5 + random() * 0.45,
i % 3 === 0 ? "#789c54" : "#658d4b",
false,
false
);
}
// ---------------------------------------------------------------------
// Buildings and original cultural venues
// ---------------------------------------------------------------------
function addAwning(parent, x, y, z, width, colors) {
const awning = new THREE.Group();
awning.position.set(x, y, z);
awning.rotation.x = -0.09;
parent.add(awning);
const count = 10;
const stripWidth = width / count;
for (let i = 0; i < count; i++) {
box(
awning,
-width / 2 + stripWidth * (i + 0.5),
0,
0,
stripWidth + 0.015,
0.14,
1.25,
colors[i % colors.length]
);
}
box(awning, 0, -0.13, 0.62, width + 0.12, 0.18, 0.12, colors[0]);
}
function addBalcony(parent, x, floorY, width = 2.45) {
box(parent, x, floorY, 0.75, width, 0.18, 1.15, "#d9c9a7");
box(parent, x - width / 2 + 0.06, floorY + 0.55, 1.27, 0.1, 1.1, 0.1, "#35443d");
box(parent, x + width / 2 - 0.06, floorY + 0.55, 1.27, 0.1, 1.1, 0.1, "#35443d");
box(parent, x, floorY + 1.08, 1.27, width, 0.1, 0.1, "#35443d");
for (let i = 0; i < 5; i++) {
box(
parent,
x - width / 2 + 0.18 + i * ((width - 0.36) / 4),
floorY + 0.55,
1.27,
0.07,
1.0,
0.07,
"#35443d"
);
}
}
const buildings = [
{
x: -19.5,
w: 7,
floors: 2,
color: "#bf7059",
trim: "#efd3ad",
roof: "#8d5549",
shop: "LUMA ROOM",
subtitle: "ART · BOOKS",
type: "Neighborhood gallery",
description:
"A daylit room for small editions, artist books, and changing window displays. The original venue occupies the quietest corner of the block.",
meta: "Gallery · reading room · 10–18h"
},
{
x: -11.5,
w: 8,
floors: 3,
color: "#d7a84f",
trim: "#f3dfb8",
roof: "#9b6b3f",
shop: "TEATRO SOL",
subtitle: "STAGE · SONG",
type: "Pocket theatre",
description:
"An intimate neighborhood stage with a narrow sun-yellow frontage, a small illuminated marquee, and evening performances above the street.",
meta: "Theatre · live music"
},
{
x: -3,
w: 7,
floors: 2,
color: "#d8c9a3",
trim: "#f2e7c8",
roof: "#a3916f",
shop: "NIDO WORKSHOP",
subtitle: "MAKE · REPAIR",
type: "Craft workshop",
description:
"A hands-on workshop where neighbors share tools, mend household objects, and display small-batch work directly on the pavement.",
meta: "Ceramics · repair · classes"
},
{
x: 5.5,
w: 9,
floors: 3,
color: "#76927a",
trim: "#e3ddc2",
roof: "#56735f",
shop: "CAFÉ NUBE",
subtitle: "COFFEE · LISTENING",
type: "Café and listening room",
description:
"A café that becomes an informal listening room after dark. Its striped awning, outdoor tables, and green facade keep the block social.",
meta: "Café · records · evening sessions"
},
{
x: 15.5,
w: 8,
floors: 2,
color: "#c98d83",
trim: "#efd7c5",
roof: "#8f625c",
shop: "VERSO SALA",
subtitle: "DANCE · MOVEMENT",
type: "Movement studio",
description:
"A compact rehearsal studio with tall windows and a warm rose-colored facade. Classes fill the upper floor through the late afternoon.",
meta: "Dance · movement · rehearsal"
}
];
function makeBuilding(config, index) {
const group = new THREE.Group();
group.position.x = config.x;
world.add(group);
const floorHeight = 2.85;
const buildingHeight = config.floors * floorHeight;
const depth = index === 3 ? 8.3 : 7.8;
const centerZ = -depth / 2;
box(
group,
0,
buildingHeight / 2,
centerZ,
config.w,
buildingHeight,
depth,
config.color,
true
);
// Foundation and shadowed storefront surround.
box(group, 0, 0.29, 0.08, config.w + 0.16, 0.58, 0.28, config.trim);
box(group, 0, 1.36, 0.1, config.w - 0.58, 2.38, 0.2, "#34423d");
const bay = (config.w - 0.85) / 3;
const left = -(config.w - 0.85) / 2;
for (let i = 0; i < 2; i++) {
const cx = left + bay * (i + 0.5);
box(group, cx, 1.32, 0.23, bay * 0.78, 1.95, 0.12, glassMaterial);
box(group, cx - bay * 0.4, 1.32, 0.31, 0.09, 2.03, 0.1, config.trim);
box(group, cx + bay * 0.4, 1.32, 0.31, 0.09, 2.03, 0.1, config.trim);
box(group, cx, 0.35, 0.31, bay * 0.86, 0.1, 0.14, config.trim);
box(group, cx, 2.3, 0.31, bay * 0.86, 0.1, 0.14, config.trim);
}
const doorX = left + bay * 2.5;
box(group, doorX, 1.22, 0.25, bay * 0.58, 2.05, 0.13, glassMaterial);
box(group, doorX - bay * 0.31, 1.22, 0.34, 0.1, 2.14, 0.12, config.trim);
box(group, doorX + bay * 0.31, 1.22, 0.34, 0.1, 2.14, 0.12, config.trim);
box(group, doorX, 2.3, 0.34, bay * 0.72, 0.11, 0.13, config.trim);
box(group, doorX + 0.28, 1.15, 0.43, 0.07, 0.34, 0.08, "#e7c986");
// Main venue sign.
makeSign(
group,
config.shop,
config.subtitle,
0,
2.82,
0.36,
Math.min(config.w - 0.95, 6.3),
0.68,
config.trim,
"#263a33"
);
// Upper-floor windows, shutters and sills.
const windowCount = config.w >= 8 ? 4 : 3;
const spacing = config.w >= 8 ? 1.75 : 1.72;
for (let floor = 1; floor < config.floors; floor++) {
const windowY = floor * floorHeight + 1.3;
for (let i = 0; i < windowCount; i++) {
const x = (i - (windowCount - 1) / 2) * spacing;
box(group, x, windowY, 0.085, 1.32, 1.52, 0.14, "#42504a");
box(group, x, windowY, 0.18, 1.11, 1.32, 0.1, glassMaterial);
box(group, x, windowY, 0.26, 0.07, 1.34, 0.08, config.trim);
box(group, x - 0.78, windowY, 0.17, 0.32, 1.4, 0.12, config.roof);
box(group, x + 0.78, windowY, 0.17, 0.32, 1.4, 0.12, config.roof);
box(group, x, windowY - 0.78, 0.25, 1.52, 0.12, 0.28, config.trim);
}
}
// A selected set of shallow balconies.
if (index === 1 || index === 3) {
const middleWindow = (windowCount - 1) / 2;
const balconyX = (middleWindow - (windowCount - 1) / 2) * spacing;
addBalcony(group, balconyX, floorHeight - 0.08, 2.45);
}
// Roof slab and low parapets.
box(group, 0, buildingHeight + 0.12, centerZ, config.w + 0.38, 0.25, depth + 0.35, config.roof);
box(group, 0, buildingHeight + 0.43, 0.02, config.w + 0.3, 0.62, 0.28, config.trim);
box(
group,
-config.w / 2 - 0.05,
buildingHeight + 0.43,
centerZ,
0.26,
0.62,
depth + 0.25,
config.trim
);
box(
group,
config.w / 2 + 0.05,
buildingHeight + 0.43,
centerZ,
0.26,
0.62,
depth + 0.25,
config.trim
);
// Rooftop chimney, tank, planters and antenna.
box(
group,
-config.w * 0.26,
buildingHeight + 0.85,
-depth * 0.55,
0.58,
1.45,
0.62,
config.roof
);
box(
group,
-config.w * 0.26,
buildingHeight + 1.61,
-depth * 0.55,
0.72,
0.15,
0.74,
"#35443e"
);
if (index === 2 || index === 4) {
for (const side of [-1, 1]) {
box(
group,
side * config.w * 0.27,
buildingHeight + 0.52,
-depth * 0.42,
1.4,
0.65,
0.9,
"#b38c63"
);
box(
group,
side * config.w * 0.27,
buildingHeight + 0.98,
-depth * 0.42,
1.15,
0.4,
0.65,
"#557a48"
);
}
}
if (index === 1) {
for (const legX of [-0.55, 0.55]) {
box(group, legX, buildingHeight + 0.62, -depth * 0.3, 0.12, 0.75, 0.12, "#4b5750");
}
box(group, 0, buildingHeight + 1.12, -depth * 0.3, 1.35, 0.95, 1.0, "#5d6b63");
box(group, 0, buildingHeight + 1.62, -depth * 0.3, 1.5, 0.12, 1.15, "#35443d");
}
if (index === 3) {
box(group, config.w * 0.29, buildingHeight + 1.45, -depth * 0.48, 0.08, 2.25, 0.08, "#3e4c45");
box(group, config.w * 0.29, buildingHeight + 2.22, -depth * 0.48, 1.15, 0.08, 0.08, "#3e4c45");
box(group, config.w * 0.29 - 0.4, buildingHeight + 2.0, -depth * 0.48, 0.08, 0.45, 0.08, "#3e4c45");
}
// Venue-specific street details.
if (index === 0) {
makeSign(group, "PRINT / 24", "SMALL EDITIONS", -1.55, 1.35, 0.39, 1.25, 0.78, "#e7d7b5", "#34443c");
makeSign(group, "OPEN", "ART & BOOKS", 1.55, 1.35, 0.39, 1.2, 0.78, "#e7d7b5", "#34443c");
}
if (index === 1) {
addAwning(group, 0, 2.2, 0.9, config.w - 1.0, ["#f1d89c", "#ba6e50"]);
box(group, 0, 2.28, 1.58, config.w - 0.6, 0.28, 0.2, "#4a4038");
for (let i = 0; i < 9; i++) {
box(
group,
-2.8 + i * 0.7,
2.28,
1.71,
0.12,
0.12,
0.08,
lampGlowMaterial,
false,
false
);
}
}
if (index === 2) {
addAwning(group, -1.65, 2.2, 0.86, 2.8, ["#d5b965", "#617c63"]);
for (const side of [-1, 1]) {
box(group, side * 2.45, 0.45, 1.2, 0.9, 0.85, 0.8, "#9b7955");
box(group, side * 2.45, 0.9, 1.2, 0.72, 0.12, 0.66, "#bf9665");
}
}
if (index === 3) {
addAwning(group, -1.25, 2.18, 0.94, 4.4, ["#eee1b9", "#567963"]);
}
if (index === 4) {
makeSign(group, "MOVE", "CLASSES", -1.8, 1.3, 0.39, 1.25, 0.82, "#e9d2bd", "#5a4844");
box(group, 1.65, 1.3, 0.38, 1.1, 1.72, 0.1, "#d8b7a1");
}
const venue = {
title: config.shop,
type: config.type,
description: config.description,
meta: config.meta
};
group.traverse((object) => {
if (object.isMesh) {
object.userData.venue = venue;
venueMeshes.push(object);
}
});
}
buildings.forEach(makeBuilding);
// ---------------------------------------------------------------------
// Street furniture, café seating, cars and people
// ---------------------------------------------------------------------
function addBench(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.25, z);
group.rotation.y = rotation;
world.add(group);
box(group, 0, 0.48, 0, 2.25, 0.16, 0.58, "#9b704b");
box(group, 0, 0.92, -0.23, 2.25, 0.65, 0.13, "#9b704b");
box(group, -0.78, 0.23, 0, 0.14, 0.46, 0.48, "#43504a");
box(group, 0.78, 0.23, 0, 0.14, 0.46, 0.48, "#43504a");
}
addBench(-16.5, 11.15, 0);
addBench(7.5, 11.15, 0);
addBench(18.5, 11.15, Math.PI);
function addTable(x, z) {
const group = new THREE.Group();
group.position.set(x, 0.25, z);
world.add(group);
box(group, 0, 0.9, 0, 1.02, 0.12, 1.02, "#d9c7a0");
box(group, 0, 0.45, 0, 0.13, 0.9, 0.13, "#3d4a43");
for (const side of [-1, 1]) {
box(group, side * 0.78, 0.42, 0, 0.48, 0.12, 0.48, "#647d69");
box(group, side * 0.95, 0.7, 0, 0.1, 0.58, 0.48, "#647d69");
box(group, side * 0.78, 0.2, 0, 0.09, 0.42, 0.09, "#43504a");
}
box(group, 0.15, 1.02, -0.08, 0.16, 0.16, 0.16, "#d46d50");
box(group, -0.2, 1.03, 0.18, 0.13, 0.19, 0.13, "#ead8b1");
}
for (const x of [3.7, 7.2, 9.3]) addTable(x, 1.45);
function addLamp(x, z) {
box(world, x, 2.25, z, 0.14, 4.2, 0.14, "#34413b");
box(world, x + 0.35, 4.28, z, 0.8, 0.12, 0.12, "#34413b");
box(world, x + 0.66, 4.14, z, 0.58, 0.28, 0.48, "#34413b");
box(world, x + 0.66, 3.98, z, 0.4, 0.09, 0.32, lampGlowMaterial, false, false);
const light = new THREE.PointLight("#ffc16b", 0, 6, 2);
light.position.set(x + 0.66, 3.75, z);
scene.add(light);
lampLights.push(light);
}
for (const x of [-22.5, -7.5, 10.5, 22]) addLamp(x, 9.55);
function addBollard(x, z) {
box(world, x, 0.62, z, 0.18, 1.05, 0.18, "#3e4b45");
box(world, x, 1.04, z, 0.25, 0.14, 0.25, "#69746d");
}
for (const x of [-24, -16, -8, 0, 8, 16, 24]) {
addBollard(x, 10.15);
}
function addPlanter(x, z, color = "#4f7c4b") {
box(world, x, 0.58, z, 1.1, 0.65, 1.1, "#b38d60");
box(world, x, 0.98, z, 0.88, 0.28, 0.88, color);
box(world, x - 0.2, 1.28, z, 0.42, 0.5, 0.42, "#5f8d4e");
}
addPlanter(-14.2, 1.55, "#527c48");
addPlanter(12.2, 1.55, "#628b4c");
addPlanter(1.4, 11.35, "#517b47");
function makeCar(x, z, color, flip = false) {
const group = new THREE.Group();
group.position.set(x, 0.23, z);
group.rotation.y = flip ? Math.PI : 0;
world.add(group);
box(group, 0, 0.7, 0, 3.65, 0.72, 1.55, color, true);
box(group, -0.15, 1.3, 0, 1.9, 0.72, 1.35, "#91a6a0", true);
box(group, -0.15, 1.36, 0.695, 1.48, 0.45, 0.06, glassMaterial);
box(group, -0.15, 1.36, -0.695, 1.48, 0.45, 0.06, glassMaterial);
for (const wx of [-1.18, 1.18]) {
for (const wz of [-0.78, 0.78]) {
box(group, wx, 0.38, wz, 0.64, 0.64, 0.25, "#252c29");
box(group, wx, 0.38, wz * 1.03, 0.34, 0.34, 0.04, "#717b76");
}
}
box(group, 1.83, 0.74, 0.49, 0.08, 0.22, 0.32, "#f5db95", false, false);
box(group, 1.83, 0.74, -0.49, 0.08, 0.22, 0.32, "#f5db95", false, false);
box(group, -1.84, 0.72, 0, 0.08, 0.17, 0.8, "#b95143", false, false);
}
makeCar(-10.5, 4.25, "#d9c48c", false);
makeCar(17.5, 8.05, "#66858b", true);
function makePerson(x, z, shirt, trousers = "#3e4744", scale = 1, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.25, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
world.add(group);
box(group, -0.16, 0.3, 0, 0.22, 0.6, 0.24, trousers);
box(group, 0.16, 0.3, 0, 0.22, 0.6, 0.24, trousers);
box(group, 0, 0.91, 0, 0.56, 0.66, 0.34, shirt);
box(group, -0.37, 0.9, 0, 0.17, 0.58, 0.22, shirt);
box(group, 0.37, 0.9, 0, 0.17, 0.58, 0.22, shirt);
box(group, 0, 1.47, 0, 0.36, 0.38, 0.35, "#c9936e");
box(group, 0, 1.66, -0.01, 0.38, 0.12, 0.36, "#4e4035");
}
makePerson(-17.1, 1.35, "#c96850", "#535b58", 0.96, 0.3);
makePerson(-8.2, 1.7, "#e4c16b", "#4e5d62", 1.02, -0.4);
makePerson(-1.8, 1.25, "#6e947c", "#725b4b", 0.92, 0.7);
makePerson(4.1, 1.7, "#d7a356", "#45534e", 0.98, -0.7);
makePerson(13.6, 1.35, "#7c708d", "#4e5553", 0.95, 0.1);
makePerson(19.5, 1.8, "#d47b69", "#4d5350", 1.0, -0.5);
makePerson(-12.2, 11.6, "#567a8a", "#7b5f4b", 1.03, 2.7);
makePerson(2.8, 11.4, "#b78362", "#3e4845", 0.93, 3.4);
makePerson(14.1, 11.8, "#6e8d68", "#515b58", 0.98, -1.2);
// A compact neighborhood noticeboard.
box(world, -6.3, 1.35, 11.9, 0.14, 2.2, 0.14, "#5d665e");
box(world, -6.3, 1.65, 11.86, 1.8, 1.25, 0.16, "#7f6548");
makeSign(world, "TODAY", "STUDIO / FILM / MUSIC", -6.3, 1.65, 11.98, 1.55, 0.9, "#e9dfc5", "#465149");
// ---------------------------------------------------------------------
// Camera and direct orbit controls (no addons)
// ---------------------------------------------------------------------
const desired = {
azimuth: 0.39,
polar: 1.01,
zoom: 31.5
};
const current = {
azimuth: desired.azimuth,
polar: desired.polar,
zoom: desired.zoom
};
const target = new THREE.Vector3(0, 4.2, -1.4);
function updateCamera() {
const aspect = window.innerWidth / window.innerHeight;
const responsiveZoom = desired.zoom * Math.max(1, 1.2 / aspect);
const radius = 61;
const sinPolar = Math.sin(current.polar);
camera.position.set(
target.x + radius * sinPolar * Math.sin(current.azimuth),
target.y + radius * Math.cos(current.polar),
target.z + radius * sinPolar * Math.cos(current.azimuth)
);
camera.lookAt(target);
camera.left = (-responsiveZoom * aspect) / 2;
camera.right = (responsiveZoom * aspect) / 2;
camera.top = responsiveZoom / 2;
camera.bottom = -responsiveZoom / 2;
camera.updateProjectionMatrix();
}
function resetView() {
desired.azimuth = 0.39;
desired.polar = 1.01;
desired.zoom = 31.5;
}
const pointers = new Map();
let gestureDistance = 0;
let moved = false;
const canvas = renderer.domElement;
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
moved = false;
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
gestureDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
canvas.addEventListener("pointermove", (event) => {
const previous = pointers.get(event.pointerId);
if (previous && pointers.size === 1) {
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
desired.azimuth = clamp(desired.azimuth - dx * 0.006, -0.92, 1.02);
desired.polar = clamp(desired.polar + dy * 0.005, 0.72, 1.34);
moved = moved || Math.abs(dx) + Math.abs(dy) > 2;
}
if (pointers.size === 2) {
const oldPoints = [...pointers.values()];
const oldDistance = Math.hypot(
oldPoints[0].x - oldPoints[1].x,
oldPoints[0].y - oldPoints[1].y
);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
const newPoints = [...pointers.values()];
const newDistance = Math.hypot(
newPoints[0].x - newPoints[1].x,
newPoints[0].y - newPoints[1].y
);
if (newDistance > 0 && oldDistance > 0) {
desired.zoom = clamp(desired.zoom * (oldDistance / newDistance), 21, 48);
}
moved = true;
} else {
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
}
if (pointers.size === 0) {
const hover = pickVenue(event);
canvas.style.cursor = hover ? "pointer" : "grab";
}
});
function pointerEnd(event) {
pointers.delete(event.pointerId);
if (event.type === "pointerup" && !moved) {
const venue = pickVenue(event);
if (venue) showVenue(venue);
}
}
canvas.addEventListener("pointerup", pointerEnd);
canvas.addEventListener("pointercancel", pointerEnd);
canvas.addEventListener("pointerleave", (event) => {
if (event.buttons === 0) pointers.delete(event.pointerId);
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desired.zoom = clamp(desired.zoom * Math.exp(event.deltaY * 0.001), 21, 48);
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetView);
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
function pickVenue(event) {
const bounds = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - bounds.left) / bounds.width) * 2 - 1;
pointer.y = -((event.clientY - bounds.top) / bounds.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(venueMeshes, false);
return hits.length ? hits[0].object.userData.venue : null;
}
// ---------------------------------------------------------------------
// UI, day/dusk mode and resize
// ---------------------------------------------------------------------
const venueCard = document.getElementById("venueCard");
const venueTitle = document.getElementById("venueTitle");
const venueType = document.getElementById("venueType");
const venueText = document.getElementById("venueText");
const venueMeta = document.getElementById("venueMeta");
const duskButton = document.getElementById("duskButton");
const resetButton = document.getElementById("resetButton");
const closeCard = document.getElementById("closeCard");
function showVenue(venue) {
venueTitle.textContent = venue.title;
venueType.textContent = venue.type;
venueText.textContent = venue.description;
venueMeta.textContent = venue.meta;
venueCard.classList.add("show");
}
closeCard.addEventListener("click", () => venueCard.classList.remove("show"));
resetButton.addEventListener("click", resetView);
let isDusk = false;
function setDusk(enabled) {
isDusk = enabled;
const sky = enabled ? duskSky : daySky;
scene.background.copy(sky);
scene.fog.color.copy(sky);
hemisphere.intensity = enabled ? 0.72 : 1.75;
hemisphere.color.set(enabled ? "#a9b5d0" : "#fff5dc");
hemisphere.groundColor.set(enabled ? "#34463f" : "#55705c");
sun.color.set(enabled ? "#ffad78" : "#fff0cf");
sun.intensity = enabled ? 1.45 : 2.75;
sun.position.set(enabled ? -24 : -19, enabled ? 18 : 31, enabled ? 8 : 22);
coolFill.intensity = enabled ? 0.72 : 0.55;
renderer.toneMappingExposure = enabled ? 1.16 : 1.05;
glassMaterial.emissiveIntensity = enabled ? 0.62 : 0;
lampGlowMaterial.emissiveIntensity = enabled ? 2.8 : 0.22;
signMaterials.forEach((material) => {
material.emissiveIntensity = enabled ? 0.68 : 0;
});
lampLights.forEach((light) => {
light.intensity = enabled ? 2.1 : 0;
});
duskButton.textContent = enabled ? "Daylight" : "Dusk light";
duskButton.setAttribute("aria-pressed", String(enabled));
}
duskButton.addEventListener("click", () => setDusk(!isDusk));
window.addEventListener("resize", () => {
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
renderer.setSize(window.innerWidth, window.innerHeight);
updateCamera();
});
renderer.setAnimationLoop(() => {
current.azimuth += (desired.azimuth - current.azimuth) * 0.12;
current.polar += (desired.polar - current.polar) * 0.12;
current.zoom += (desired.zoom - current.zoom) * 0.12;
updateCamera();
renderer.render(scene, camera);
});
updateCamera();
renderer.render(scene, camera);
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("gone");
});
</script>
</body>
</html>
```