Prompt specification
Build or customize the Three.js 3D scene "Brasília superquadra garden and housing slice" 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: Brasília superquadra garden and housing slice
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/bras-lia-superquadra-garden-and-housing-slice-x2651
Scene Description Prompt:
Please use Three.js from cdnjs for a voxel scene based on this idea: Brasília superquadra garden and housing slice. Build a referenced fragment of a superquadra with a few residential bars, shared trees, paths, and local access road. Make the selective simplification explicit. Return one self-contained HTML file.
Working Three.js Starter (bras-lia-superquadra-garden-and-housing-slice-x2651):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Brasília Superquadra — Selective Voxel Study</title>
<style>
:root {
--ink: #26312f;
--muted: #68736e;
--paper: rgba(247, 244, 234, 0.92);
--line: rgba(38, 49, 47, 0.18);
--green: #376b59;
--terracotta: #b65e45;
--blue: #477d89;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e7e3d7;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid var(--line);
background: var(--paper);
box-shadow: 0 14px 36px rgba(41, 49, 45, 0.12);
backdrop-filter: blur(12px);
}
#title-card {
top: 22px;
left: 22px;
width: min(410px, calc(100vw - 44px));
padding: 18px 20px 17px;
border-radius: 3px;
}
.eyebrow {
margin-bottom: 8px;
color: var(--terracotta);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(22px, 2.3vw, 34px);
font-weight: 650;
letter-spacing: -0.045em;
line-height: 0.98;
}
.subtitle {
margin-top: 10px;
max-width: 340px;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.rule {
width: 42px;
height: 3px;
margin-top: 14px;
background: var(--green);
}
#scope {
right: 22px;
top: 22px;
width: min(330px, calc(100vw - 44px));
padding: 15px 17px;
border-radius: 3px;
}
.scope-heading {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.scope-heading::before {
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--terracotta);
content: "";
box-shadow: 0 0 0 4px rgba(182, 94, 69, 0.13);
}
.scope-row {
display: grid;
grid-template-columns: 54px 1fr;
gap: 9px;
padding: 7px 0;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 11px;
line-height: 1.42;
}
.scope-row strong {
color: var(--ink);
font-size: 9px;
letter-spacing: 0.11em;
text-transform: uppercase;
}
#controls {
right: 22px;
bottom: 22px;
width: 235px;
padding: 12px 14px;
border-radius: 3px;
color: var(--muted);
font-size: 10px;
line-height: 1.55;
}
#controls strong {
display: block;
margin-bottom: 4px;
color: var(--ink);
font-size: 9px;
letter-spacing: 0.13em;
text-transform: uppercase;
}
kbd {
display: inline-block;
min-width: 17px;
padding: 1px 4px;
border: 1px solid var(--line);
border-bottom-width: 2px;
border-radius: 2px;
background: rgba(255, 255, 255, 0.45);
color: var(--ink);
font: inherit;
text-align: center;
}
#legend {
left: 22px;
bottom: 22px;
width: 280px;
padding: 13px 15px;
border-radius: 3px;
}
.legend-items {
display: flex;
flex-wrap: wrap;
gap: 8px 13px;
color: var(--muted);
font-size: 9px;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.legend-item {
display: flex;
align-items: center;
gap: 6px;
}
.swatch {
width: 10px;
height: 10px;
border: 1px solid rgba(0, 0, 0, 0.08);
}
.swatch.green { background: #718b61; }
.swatch.concrete { background: #e7e3d7; }
.swatch.glass { background: #426b72; }
.swatch.cut { background: #b65e45; }
#labels {
position: fixed;
inset: 0;
z-index: 4;
overflow: hidden;
pointer-events: none;
}
.model-label {
position: absolute;
min-width: 118px;
padding: 7px 9px 7px 11px;
border-left: 2px solid var(--green);
background: rgba(248, 245, 236, 0.9);
box-shadow: 0 6px 18px rgba(38, 49, 47, 0.12);
color: var(--ink);
opacity: 0;
transform: translate(-50%, -100%);
transition: opacity 120ms linear;
white-space: nowrap;
}
.model-label::after {
position: absolute;
left: 12px;
bottom: -18px;
width: 1px;
height: 18px;
background: var(--green);
content: "";
}
.model-label::before {
position: absolute;
left: 9px;
bottom: -21px;
width: 7px;
height: 7px;
border: 2px solid #f8f5ec;
border-radius: 50%;
background: var(--green);
content: "";
}
.model-label.cut {
border-left-color: var(--terracotta);
}
.model-label.cut::after {
background: var(--terracotta);
}
.model-label.cut::before {
background: var(--terracotta);
}
.model-label small {
display: block;
margin-bottom: 2px;
color: var(--muted);
font-size: 7px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.model-label span {
display: block;
font-size: 10px;
font-weight: 650;
letter-spacing: 0.025em;
text-transform: uppercase;
}
#north {
position: fixed;
right: 28px;
bottom: 93px;
z-index: 8;
display: grid;
place-items: center;
width: 42px;
height: 52px;
color: var(--ink);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
pointer-events: none;
}
#north svg {
width: 30px;
height: 30px;
overflow: visible;
}
#loading {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
background: #e7e3d7;
color: var(--ink);
transition: opacity 400ms ease;
}
#loading div {
text-align: center;
}
#loading strong {
display: block;
margin-bottom: 8px;
font-size: 12px;
letter-spacing: 0.15em;
text-transform: uppercase;
}
#loading span {
color: var(--muted);
font-size: 11px;
}
@media (max-width: 760px) {
#title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 13px 15px;
}
#scope {
top: auto;
right: 12px;
bottom: 12px;
width: 235px;
padding: 11px 13px;
}
#scope .scope-row {
display: none;
}
#scope .scope-heading {
margin: 0;
}
#legend,
#controls,
#north {
display: none;
}
.model-label {
transform: translate(-50%, -100%) scale(0.88);
}
}
</style>
</head>
<body>
<div id="loading">
<div>
<strong>Assembling the superquadra</strong>
<span>Loading the voxel study…</span>
</div>
</div>
<header id="title-card" class="panel">
<div class="eyebrow">Brasília, DF · Conceptual fragment</div>
<h1>Superquadra<br />Garden & Housing Slice</h1>
<p class="subtitle">
An axonometric voxel study of communal green space, repeated residential bars,
pilotis, and the edge of the local access road.
</p>
<div class="rule"></div>
</header>
<aside id="scope" class="panel">
<div class="scope-heading">Selective simplification</div>
<div class="scope-row">
<strong>Kept</strong>
<span>Slab massing, three-storey bay rhythm, pilotis, garden axes, path hierarchy, and access edge.</span>
</div>
<div class="scope-row">
<strong>Reduced</strong>
<span>Exact plans, most interiors, tree species, engineering, facade detail, and complete urban context.</span>
</div>
<div class="scope-row">
<strong>Accuracy</strong>
<span>Representative architectural model—not a surveyed reconstruction.</span>
</div>
</aside>
<aside id="legend" class="panel">
<div class="legend-items">
<div class="legend-item"><span class="swatch green"></span>Shared green</div>
<div class="legend-item"><span class="swatch concrete"></span>Residential slab</div>
<div class="legend-item"><span class="swatch glass"></span>Window bay</div>
<div class="legend-item"><span class="swatch cut"></span>Illustrative cut</div>
</div>
</aside>
<aside id="controls" class="panel">
<strong>Direct camera controls</strong>
Drag to orbit · right-drag / <kbd>Shift</kbd> + drag to pan ·
scroll to zoom · <kbd>R</kbd> resets · arrow keys orbit
</aside>
<div id="labels">
<div id="label-garden" class="model-label">
<small>01 · Shared open space</small>
<span>Communal garden</span>
</div>
<div id="label-bar" class="model-label">
<small>02 · Representative bar</small>
<span>Pilotis & bay rhythm</span>
</div>
<div id="label-slice" class="model-label cut">
<small>03 · Selective section</small>
<span>Housing slice</span>
</div>
<div id="label-road" class="model-label">
<small>04 · Urban edge</small>
<span>Local access road</span>
</div>
</div>
<div id="north" aria-hidden="true">
<svg viewBox="0 0 30 30">
<path d="M15 2 L21 21 L15 17 L9 21 Z" fill="#26312f" />
<path d="M15 2 L15 17 L9 21 Z" fill="#b65e45" />
</svg>
N
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, camera, and lighting
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color("#e7e3d7");
scene.fog = new THREE.Fog("#e7e3d7", 210, 340);
const renderer = new THREE.WebGLRenderer({ antialias: true });
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;
document.body.prepend(renderer.domElement);
const camera = new THREE.OrthographicCamera(-100, 100, 70, -70, 0.1, 500);
const cameraTarget = new THREE.Vector3(0, 2, 0);
const hemisphere = new THREE.HemisphereLight("#fff8e8", "#71806b", 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight("#fff0cf", 3.2);
sun.position.set(-80, 115, 65);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -100;
sun.shadow.camera.right = 100;
sun.shadow.camera.top = 90;
sun.shadow.camera.bottom = -90;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 260;
sun.shadow.normalBias = 0.035;
sun.shadow.bias = -0.00015;
scene.add(sun);
const fill = new THREE.DirectionalLight("#b9d5df", 0.85);
fill.position.set(80, 45, -80);
scene.add(fill);
// -------------------------------------------------------------------------
// Materials
// -------------------------------------------------------------------------
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0.0,
...options
});
const M = {
base: material("#b9b09c"),
ground: material("#d7cfbb"),
paving: material("#e1d8c4"),
pavingJoint: material("#c8bea9"),
asphalt: material("#4d5351"),
asphaltLight: material("#606663"),
curb: material("#f0eadb"),
grass: material("#708c5d"),
grassDark: material("#5f7d54"),
grassLight: material("#819a69"),
concrete: material("#e9e5d8"),
concreteWarm: material("#ddd7c8"),
white: material("#f5f0e4"),
shadow: material("#6d756f"),
glass: material("#355e67", { roughness: 0.28, metalness: 0.08 }),
glassLight: material("#5b7f86", { roughness: 0.32, metalness: 0.05 }),
green: material("#477160"),
ochre: material("#bf7c46"),
blue: material("#5b8790"),
terra: material("#b65e45"),
yellow: material("#d2a64a"),
trunk: material("#795a3f"),
leafA: material("#56764e"),
leafB: material("#688653"),
leafC: material("#78945f"),
water: material("#4f9fae", { roughness: 0.22, metalness: 0.05 }),
wood: material("#936946"),
rubber: material("#b85f4a"),
rubberBlue: material("#4e8090"),
tire: material("#303534")
};
const world = new THREE.Group();
scene.add(world);
function box(parent, size, position, mat, castShadow = true, receiveShadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
mat
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
parent.add(mesh);
return mesh;
}
function cylinder(parent, radiusTop, radiusBottom, height, position, mat, segments = 10) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radiusTop, radiusBottom, height, segments),
mat
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// -------------------------------------------------------------------------
// Site base, access roads, sidewalks, and plots
// -------------------------------------------------------------------------
box(world, [152, 1.8, 120], [0, -0.9, 0], M.base);
box(world, [150, 0.12, 118], [0, 0.02, 0], M.ground);
// Superquadra ground plane.
box(world, [126, 0.12, 82], [0, 0.12, -5], M.paving);
// Central green field.
box(world, [72, 0.18, 45], [0, 0.2, -2], M.grass);
box(world, [14, 0.06, 22], [-24, 0.31, -2], M.grassDark);
box(world, [14, 0.06, 22], [24, 0.31, -2], M.grassDark);
box(world, [61, 0.06, 13], [0, 0.31, -15], M.grassLight);
box(world, [61, 0.06, 11], [0, 0.31, 12], M.grassLight);
// Orthogonal pedestrian paths.
box(world, [72, 0.15, 4.5], [0, 0.38, -2], M.paving);
box(world, [4.5, 0.16, 45], [0, 0.39, -2], M.paving);
// Path edge strips and paving joints.
for (const x of [-35.8, 35.8]) {
box(world, [0.22, 0.12, 44], [x, 0.4, -2], M.pavingJoint, false);
}
for (const z of [-23.6, 19.6]) {
box(world, [71.5, 0.12, 0.22], [0, 0.4, z], M.pavingJoint, false);
}
for (let x = -34; x <= 34; x += 4) {
box(world, [0.08, 0.03, 4.3], [x, 0.47, -2], M.pavingJoint, false);
}
for (let z = -21; z <= 17; z += 4) {
box(world, [4.3, 0.03, 0.08], [0, 0.48, z], M.pavingJoint, false);
}
// Southern local access road.
box(world, [151, 0.18, 9], [0, 0.18, 49], M.asphalt);
box(world, [9, 0.18, 98], [68, 0.18, 0], M.asphalt);
// Curbs and sidewalks.
box(world, [151, 0.22, 2.2], [0, 0.22, 42.7], M.curb);
box(world, [2.2, 0.22, 6.2], [0, 0.22, 56], M.curb);
box(world, [151, 0.24, 4], [0, 0.22, 39.8], M.paving);
box(world, [151, 0.24, 4], [0, 0.22, 58], M.paving);
box(world, [2.2, 0.22, 98], [61.7, 0.22, 0], M.curb);
box(world, [4, 0.24, 98], [59.4, 0.22, 0], M.paving);
box(world, [2.2, 0.22, 98], [74.3, 0.22, 0], M.curb);
// Dashed road center markings.
for (let x = -70; x <= 70; x += 8) {
box(world, [3.2, 0.025, 0.16], [x, 0.29, 49], M.white, false);
}
for (let z = -43; z <= 40; z += 8) {
box(world, [0.16, 0.025, 3.2], [68, 0.29, z], M.white, false);
}
// -------------------------------------------------------------------------
// Residential bars
// -------------------------------------------------------------------------
const accentMaterials = [M.green, M.ochre, M.blue, M.concreteWarm];
function addPilotis(group, width, depth) {
const count = Math.max(4, Math.floor(width / 7));
const start = -width / 2 + 1.6;
const end = width / 2 - 1.6;
for (let i = 0; i < count; i++) {
const t = count === 1 ? 0.5 : i / (count - 1);
const x = THREE.MathUtils.lerp(start, end, t);
for (const z of [-depth * 0.34, depth * 0.34]) {
box(group, [0.68, 3.5, 0.68], [x, 1.9, z], M.white);
box(group, [1.0, 0.24, 1.0], [x, 0.31, z], M.concreteWarm);
}
}
}
function addFacade(group, width, depth, floors, accentOffset = 0) {
const bayWidth = 4.35;
const bayCount = Math.floor(width / bayWidth);
const usableWidth = bayCount * bayWidth;
const firstX = -usableWidth / 2 + bayWidth / 2;
// Main concrete volume.
box(
group,
[width, floors * 3.1, depth],
[0, 3.6 + (floors * 3.1) / 2, 0],
M.concrete
);
// Floor bands / continuous brise-soleil.
for (let floor = 0; floor <= floors; floor++) {
const y = 3.55 + floor * 3.1;
box(group, [width + 0.4, 0.32, depth + 1.25], [0, y, 0], M.white);
}
for (let floor = 0; floor < floors; floor++) {
const windowY = 4.9 + floor * 3.1;
for (let bay = 0; bay < bayCount; bay++) {
const x = firstX + bay * bayWidth;
const accent = accentMaterials[(bay + floor + accentOffset) % accentMaterials.length];
for (const side of [-1, 1]) {
const z = side * (depth / 2 + 0.075);
// Recess-like colored panel.
box(
group,
[3.25, 2.05, 0.12],
[x, windowY, z],
accent,
false
);
// Dark window inset.
box(
group,
[2.48, 1.38, 0.09],
[x, windowY + 0.05, z + side * 0.075],
bay % 3 === 0 ? M.glassLight : M.glass,
false
);
// Narrow vertical fin.
box(
group,
[0.23, 2.8, 0.48],
[x + bayWidth / 2, windowY, z + side * 0.13],
M.white
);
}
}
}
// End windows.
for (let floor = 0; floor < floors; floor++) {
const y = 4.9 + floor * 3.1;
for (const side of [-1, 1]) {
box(
group,
[0.1, 1.4, 2.35],
[side * (width / 2 + 0.04), y, 0],
M.glass,
false
);
}
}
}
function buildSolidBar({ x, z, width, depth = 10.4, rotation = 0, accentOffset = 0 }) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
world.add(group);
addPilotis(group, width, depth);
addFacade(group, width, depth, 3, accentOffset);
// Roof parapet and small service volumes.
box(group, [width - 0.8, 0.45, depth - 0.6], [0, 13.25, 0], M.white);
box(group, [5.2, 1.3, 4.2], [width * 0.23, 14.05, -1.2], M.concreteWarm);
box(group, [3.8, 0.65, 2.8], [-width * 0.2, 13.75, 1.1], M.shadow);
box(group, [3.2, 0.18, 2.3], [-width * 0.2, 14.15, 1.1], M.blue);
// A few low benches beneath the pilotis.
for (let i = -1; i <= 1; i++) {
box(group, [2.2, 0.22, 0.55], [i * width * 0.24, 0.82, 4.1], M.wood);
}
return group;
}
// Four representative bars around the communal green.
buildSolidBar({ x: 0, z: -32, width: 88, accentOffset: 0 });
buildSolidBar({ x: -12, z: 26, width: 64, accentOffset: 1 });
buildSolidBar({ x: -43, z: -2, width: 48, rotation: Math.PI / 2, accentOffset: 2 });
buildSolidBar({ x: 43, z: -2, width: 48, rotation: Math.PI / 2, accentOffset: 3 });
// Illustrative cutaway / housing slice at the east end of the southern bar.
const slice = new THREE.Group();
slice.position.set(32, 0, 26);
world.add(slice);
const sliceWidth = 24;
const sliceDepth = 10.4;
for (let floor = 0; floor <= 3; floor++) {
const y = 3.55 + floor * 3.1;
box(slice, [sliceWidth, 0.28, sliceDepth], [0, y, 0], M.white);
box(
slice,
[sliceWidth, 0.12, 0.16],
[0, y + 0.12, sliceDepth / 2 + 0.05],
M.terra,
false
);
}
// Back wall and structural ends remain.
box(slice, [sliceWidth, 9.3, 0.3], [0, 8.25, -sliceDepth / 2], M.concrete);
box(slice, [0.35, 9.3, sliceDepth], [-sliceWidth / 2, 8.25, 0], M.concrete);
box(slice, [0.35, 9.3, sliceDepth], [sliceWidth / 2, 8.25, 0], M.concrete);
// Exposed floor partitions, shown as a simplified apartment rhythm.
for (let floor = 0; floor < 3; floor++) {
const baseY = 3.7 + floor * 3.1;
for (let x = -8; x <= 8; x += 4) {
box(slice, [0.18, 2.72, 4.9], [x, baseY + 1.36, -2.65], M.white);
}
// Small furniture blocks provide scale without claiming a detailed plan.
box(slice, [2.2, 0.55, 1.55], [-6, baseY + 0.48, -3.55], M.ochre);
box(slice, [1.6, 0.55, 1.4], [-2, baseY + 0.48, -3.6], M.blue);
box(slice, [2.1, 0.75, 1.2], [6, baseY + 0.58, -3.7], M.green);
box(slice, [1.25, 0.5, 1.2], [9.8, baseY + 0.45, -2.8], M.terra);
}
// A compact stair / circulation core.
box(slice, [2.8, 9.3, 3.2], [10.2, 8.25, -3.4], M.concreteWarm);
for (let step = 0; step < 11; step++) {
box(
slice,
[2.3, 0.18, 0.45],
[10.2, 3.95 + step * 0.26, 0.4 - step * 0.22],
M.shadow,
false
);
}
// Partial roof emphasizes that the near facade has been removed.
box(slice, [sliceWidth - 1.2, 0.35, 5], [0, 13.02, -2.65], M.white);
// Cut edge marker.
box(slice, [0.22, 9.5, 0.28], [-sliceWidth / 2, 8.25, sliceDepth / 2], M.terra);
// -------------------------------------------------------------------------
// Communal garden: reflecting pool, sculpture, playground, trees
// -------------------------------------------------------------------------
// Reflecting pool and central plaza.
box(world, [13, 0.3, 13], [0, 0.5, -2], M.concreteWarm);
box(world, [10.5, 0.22, 10.5], [0, 0.68, -2], M.water);
box(world, [11.4, 0.3, 0.65], [0, 0.73, -7.15], M.white);
box(world, [11.4, 0.3, 0.65], [0, 0.73, 3.15], M.white);
box(world, [0.65, 0.3, 10.2], [-5.35, 0.73, -2], M.white);
box(world, [0.65, 0.3, 10.2], [5.35, 0.73, -2], M.white);
// Abstract modernist voxel sculpture.
box(world, [1.1, 5.5, 1.1], [-0.9, 3.35, -2], M.green);
box(world, [1.15, 4.2, 1.15], [0.7, 3.0, -1.85], M.blue);
box(world, [1.7, 1.2, 1.7], [0.15, 5.75, -2], M.terra);
// Playground surface.
box(world, [15, 0.18, 11], [23, 0.47, 10.5], M.rubberBlue);
box(world, [4.4, 0.42, 4.4], [19.5, 0.75, 8], M.rubber);
box(world, [3.2, 0.42, 3.2], [25.5, 0.75, 8], M.yellow);
box(world, [1.0, 2.7, 1.0], [27, 1.7, 12], M.green);
box(world, [3.2, 0.45, 1.1], [25.6, 3.0, 11.5], M.terra);
// Small recreation blocks.
box(world, [3.0, 0.75, 1.2], [-22, 0.7, 11.8], M.wood);
box(world, [0.7, 2.5, 0.7], [-19.5, 1.7, 15.5], M.blue);
function makeTree(x, z, scale = 1, variant = 0) {
const tree = new THREE.Group();
tree.position.set(x, 0.35, z);
tree.scale.setScalar(scale);
box(tree, [0.62, 3.4, 0.62], [0, 1.7, 0], M.trunk);
box(tree, [0.42, 1.8, 0.42], [0.65, 2.7, 0], M.trunk);
const leaves = [M.leafA, M.leafB, M.leafC];
const leaf = leaves[variant % leaves.length];
box(tree, [2.7, 2.3, 2.6], [0, 4.2, 0], leaf);
box(tree, [2.0, 1.8, 2.1], [-1.35, 3.55, 0.15], leaf);
box(tree, [2.1, 1.9, 2.2], [1.25, 3.65, -0.1], leaf);
box(tree, [2.4, 1.65, 2.3], [0.15, 5.45, 0.05], M.leafB);
box(tree, [1.4, 1.35, 1.5], [-0.45, 5.9, 0.35], leaf);
world.add(tree);
}
const treePositions = [
[-31, -18, 1.0], [-19, -18, 0.9], [-9, -18, 1.1],
[9, -18, 1.0], [20, -18, 0.85], [31, -18, 1.05],
[-31, 8, 0.9], [-19, 9, 1.05], [-8, 9, 0.85],
[9, 9, 1.05], [21, 11, 0.85], [31, 9, 0.95],
[-34, -9, 0.8], [34, -9, 0.85],
[-34, 11, 0.85], [34, 12, 0.85],
[-55, -43, 0.9], [-42, -43, 1.05], [-28, -43, 0.85],
[-14, -43, 1.0], [0, -43, 0.85], [14, -43, 1.0],
[28, -43, 0.9], [42, -43, 1.0], [55, -43, 0.85],
[-55, 35, 0.8], [-42, 35, 0.9], [55, 35, 0.85]
];
treePositions.forEach(([x, z, scale], i) => makeTree(x, z, scale, i));
// -------------------------------------------------------------------------
// Street furniture, people, cars, and landscape details
// -------------------------------------------------------------------------
function addBench(x, z, rotation = 0) {
const bench = new THREE.Group();
bench.position.set(x, 0.45, z);
bench.rotation.y = rotation;
world.add(bench);
box(bench, [3.2, 0.22, 0.75], [0, 0.75, 0], M.wood);
box(bench, [3.2, 0.75, 0.16], [0, 1.15, -0.36], M.wood);
box(bench, [0.24, 0.72, 0.62], [-1.15, 0.36, 0], M.shadow);
box(bench, [0.24, 0.72, 0.62], [1.15, 0.36, 0], M.shadow);
}
addBench(-25, 1.2);
addBench(16, 1.2);
addBench(-8, -15.5, Math.PI / 2);
addBench(8, 15.2, Math.PI / 2);
addBench(-48, 39.4);
addBench(47, 39.4);
function addLamp(x, z, rotation = 0) {
const lamp = new THREE.Group();
lamp.position.set(x, 0.35, z);
lamp.rotation.y = rotation;
world.add(lamp);
box(lamp, [0.18, 5.2, 0.18], [0, 2.6, 0], M.shadow);
box(lamp, [1.65, 0.18, 0.18], [0.7, 5.05, 0], M.shadow);
box(lamp, [0.9, 0.28, 0.55], [1.25, 4.9, 0], M.white);
}
for (const x of [-54, -34, -14, 6, 26, 46]) {
addLamp(x, 38.2, Math.PI);
addLamp(x, 59.4, 0);
}
for (const z of [-38, -18, 2, 22, 40]) {
addLamp(60.3, z, -Math.PI / 2);
}
function addPerson(x, z, colorMat, rotation = 0) {
const person = new THREE.Group();
person.position.set(x, 0.5, z);
person.rotation.y = rotation;
world.add(person);
box(person, [0.48, 0.72, 0.34], [0, 1.2, 0], colorMat);
box(person, [0.34, 0.34, 0.34], [0, 1.78, 0], M.wood);
box(person, [0.16, 0.72, 0.18], [-0.14, 0.42, 0], M.shadow);
box(person, [0.16, 0.72, 0.18], [0.14, 0.42, 0], M.shadow);
}
addPerson(-7.5, -0.8, M.terra, 0.6);
addPerson(7.8, -3.2, M.blue, -0.4);
addPerson(19, 5.5, M.green, 1.2);
addPerson(-18, 2.4, M.ochre, -1.1);
addPerson(-41, 39.8, M.blue, 0.2);
addPerson(57.5, 10, M.terra, Math.PI / 2);
function addCar(x, z, rotation, colorMat) {
const car = new THREE.Group();
car.position.set(x, 0.48, z);
car.rotation.y = rotation;
world.add(car);
box(car, [3.7, 0.78, 1.65], [0, 0.52, 0], colorMat);
box(car, [1.85, 0.72, 1.42], [-0.2, 1.22, 0], M.glassLight);
box(car, [3.15, 0.18, 1.75], [0, 0.88, 0], colorMat);
for (const wheelX of [-1.15, 1.15]) {
for (const side of [-1, 1]) {
box(car, [0.65, 0.58, 0.24], [wheelX, 0.18, side * 0.82], M.tire, false);
}
}
}
addCar(-48, 47.1, 0, M.white);
addCar(-25, 50.8, 0, M.terra);
addCar(16, 47.0, 0, M.blue);
addCar(40, 50.8, 0, M.green);
addCar(66.2, -30, Math.PI / 2, M.white);
addCar(69.8, 9, Math.PI / 2, M.ochre);
// Additional site-edge planting boxes.
for (const x of [-58, -48, 48, 58]) {
box(world, [4.0, 0.55, 2.0], [x, 0.55, 33.6], M.concreteWarm);
box(world, [3.5, 0.12, 1.55], [x, 0.88, 33.6], M.grass);
}
// -------------------------------------------------------------------------
// Direct camera controls — no external controls addon
// -------------------------------------------------------------------------
const controlState = {
azimuth: 0.72,
elevation: 0.68,
zoom: 1,
target: cameraTarget,
dragging: false,
mode: "orbit",
pointerX: 0,
pointerY: 0
};
const canvas = renderer.domElement;
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
controlState.dragging = true;
controlState.mode = event.button === 2 || event.shiftKey ? "pan" : "orbit";
controlState.pointerX = event.clientX;
controlState.pointerY = event.clientY;
});
canvas.addEventListener("pointermove", (event) => {
if (!controlState.dragging) return;
const dx = event.clientX - controlState.pointerX;
const dy = event.clientY - controlState.pointerY;
controlState.pointerX = event.clientX;
controlState.pointerY = event.clientY;
if (controlState.mode === "orbit") {
controlState.azimuth -= dx * 0.006;
controlState.elevation = THREE.MathUtils.clamp(
controlState.elevation + dy * 0.005,
0.25,
1.25
);
} else {
const forward = new THREE.Vector3()
.subVectors(controlState.target, camera.position);
forward.y = 0;
forward.normalize();
const right = new THREE.Vector3()
.crossVectors(forward, new THREE.Vector3(0, 1, 0))
.normalize();
const unit = 135 / window.innerHeight / controlState.zoom;
controlState.target.addScaledVector(right, -dx * unit);
controlState.target.addScaledVector(forward, dy * unit);
}
});
function endPointer(event) {
controlState.dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controlState.zoom = THREE.MathUtils.clamp(
controlState.zoom * Math.exp(-event.deltaY * 0.001),
0.65,
2.4
);
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
const key = event.key.toLowerCase();
if (key === "r") {
controlState.azimuth = 0.72;
controlState.elevation = 0.68;
controlState.zoom = 1;
controlState.target.set(0, 2, 0);
}
if (key === "arrowleft") controlState.azimuth -= 0.08;
if (key === "arrowright") controlState.azimuth += 0.08;
if (key === "arrowup") {
controlState.elevation = THREE.MathUtils.clamp(controlState.elevation + 0.06, 0.25, 1.25);
}
if (key === "arrowdown") {
controlState.elevation = THREE.MathUtils.clamp(controlState.elevation - 0.06, 0.25, 1.25);
}
if (key === "+" || key === "=") controlState.zoom = Math.min(2.4, controlState.zoom * 1.1);
if (key === "-") controlState.zoom = Math.max(0.65, controlState.zoom / 1.1);
});
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
const halfHeight = Math.max(68, 82 / aspect) / controlState.zoom;
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
resize();
function updateCamera() {
const distance = 180;
const horizontalDistance = Math.cos(controlState.elevation) * distance;
camera.position.set(
controlState.target.x + Math.sin(controlState.azimuth) * horizontalDistance,
controlState.target.y + Math.sin(controlState.elevation) * distance,
controlState.target.z + Math.cos(controlState.azimuth) * horizontalDistance
);
camera.lookAt(controlState.target);
}
// -------------------------------------------------------------------------
// Screen-space labels
// -------------------------------------------------------------------------
const labels = [
{ element: document.getElementById("label-garden"), anchor: new THREE.Vector3(0, 1.3, 0) },
{ element: document.getElementById("label-bar"), anchor: new THREE.Vector3(-14, 14, -31) },
{ element: document.getElementById("label-slice"), anchor: new THREE.Vector3(32, 13, 30) },
{ element: document.getElementById("label-road"), anchor: new THREE.Vector3(18, 1, 49) }
];
function updateLabels() {
for (const label of labels) {
const projected = label.anchor.clone().project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.08 &&
projected.x < 1.08 &&
projected.y > -1.08 &&
projected.y < 1.08;
if (!visible) {
label.element.style.opacity = "0";
continue;
}
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
label.element.style.opacity = "1";
}
}
// -------------------------------------------------------------------------
// Render loop
// -------------------------------------------------------------------------
let firstFrame = true;
function animate() {
requestAnimationFrame(animate);
updateCamera();
renderer.render(scene, camera);
updateLabels();
if (firstFrame) {
firstFrame = false;
const loading = document.getElementById("loading");
loading.style.opacity = "0";
setTimeout(() => loading.remove(), 450);
}
}
animate();
</script>
</body>
</html>
```