Prompt specification
Build or customize the Three.js 3D scene "Hackesche Höfe tiled archway fragment" 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: Hackesche Höfe tiled archway fragment
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/hackesche-h-fe-tiled-archway-fragment-x2813
Scene Description Prompt:
A voxel Hackesche Höfe tiled archway in Berlin, connecting street frontage with an inner courtyard. Three.js from cdnjs, one HTML file.
Working Three.js Starter (hackesche-h-fe-tiled-archway-fragment-x2813):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hackesche Höfe — Voxel Berlin</title>
<style>
* { box-sizing: border-box; }
html, body {
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #a9d5e2;
color: #173943;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.panel {
position: fixed;
z-index: 5;
pointer-events: none;
}
.title {
top: 24px;
left: 26px;
max-width: 360px;
text-shadow: 0 1px 0 rgba(255,255,255,.35);
}
.eyebrow {
display: inline-block;
margin-bottom: 8px;
padding: 6px 9px;
border: 1px solid rgba(23,57,67,.35);
border-radius: 4px;
background: rgba(247,239,210,.76);
backdrop-filter: blur(8px);
font-size: 10px;
font-weight: 800;
letter-spacing: .19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 4vw, 54px);
font-weight: 600;
line-height: .92;
letter-spacing: -.045em;
}
.subtitle {
max-width: 310px;
margin: 10px 0 0;
font-size: 12px;
line-height: 1.5;
opacity: .78;
}
.views {
right: 22px;
bottom: 22px;
display: flex;
gap: 7px;
pointer-events: auto;
}
button {
border: 1px solid rgba(23,57,67,.32);
border-radius: 5px;
padding: 10px 12px;
background: rgba(247,239,210,.86);
color: #173943;
font: 700 10px/1 inherit;
letter-spacing: .09em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(8px);
box-shadow: 0 3px 12px rgba(35,65,70,.12);
transition: transform .15s ease, background .15s ease;
}
button:hover {
transform: translateY(-2px);
background: #fff7dd;
}
.hint {
left: 24px;
bottom: 22px;
padding: 9px 11px;
border-radius: 5px;
background: rgba(247,239,210,.72);
backdrop-filter: blur(8px);
font-size: 10px;
font-weight: 650;
letter-spacing: .045em;
opacity: .85;
}
.vignette {
position: fixed;
inset: 0;
z-index: 3;
pointer-events: none;
background:
radial-gradient(circle at 50% 45%, transparent 45%, rgba(37,64,66,.13) 120%),
linear-gradient(to bottom, rgba(255,255,255,.08), transparent 30%);
}
@media (max-width: 680px) {
.title { top: 17px; left: 18px; }
.subtitle { display: none; }
.views { right: 12px; bottom: 12px; }
.hint { left: 12px; bottom: 56px; }
}
</style>
</head>
<body>
<div class="title panel">
<div class="eyebrow">Berlin · 1996</div>
<h1>Hackesche<br>Höfe</h1>
<p class="subtitle">A voxel passage from the street into the colorful courtyard of Mitte.</p>
</div>
<div class="views panel">
<button data-view="street">Street</button>
<button data-view="passage">Passage</button>
<button data-view="courtyard">Courtyard</button>
</div>
<div class="hint panel">Drag to orbit · Wheel to zoom · Shift-drag to pan · R to reset</div>
<div class="vignette"></div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer and scene
// ------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xa9d5e2);
scene.fog = new THREE.Fog(0xa9d5e2, 32, 76);
const camera = new THREE.PerspectiveCamera(42, innerWidth / innerHeight, 0.1, 120);
const hemi = new THREE.HemisphereLight(0xd9f1ff, 0x806747, 2.15);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffe2ac, 3.2);
sun.position.set(-13, 20, 11);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -25;
sun.shadow.camera.right = 25;
sun.shadow.camera.top = 25;
sun.shadow.camera.bottom = -25;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 65;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9bd7eb, 0.7);
fill.position.set(12, 8, -16);
scene.add(fill);
// ------------------------------------------------------------
// Instanced voxel batches
// ------------------------------------------------------------
const batches = {
solid: [],
glass: [],
glow: []
};
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const tempMatrix = new THREE.Matrix4();
const tempPosition = new THREE.Vector3();
const tempScale = new THREE.Vector3();
const tempQuaternion = new THREE.Quaternion();
const tempEuler = new THREE.Euler();
const tempColor = new THREE.Color();
function put(type, w, h, d, x, y, z, color, rx = 0, ry = 0, rz = 0) {
tempPosition.set(x, y, z);
tempScale.set(w, h, d);
tempEuler.set(rx, ry, rz);
tempQuaternion.setFromEuler(tempEuler);
tempMatrix.compose(tempPosition, tempQuaternion, tempScale);
batches[type].push({ matrix: tempMatrix.clone(), color });
}
function flushBatch(type, material) {
const entries = batches[type];
const mesh = new THREE.InstancedMesh(unitBox, material, entries.length);
entries.forEach((entry, i) => {
mesh.setMatrixAt(i, entry.matrix);
mesh.setColorAt(i, tempColor.set(entry.color));
});
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
mesh.castShadow = type !== "glow";
mesh.receiveShadow = type !== "glow";
scene.add(mesh);
return mesh;
}
let seed = 1987;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function pick(list) {
return list[Math.floor(random() * list.length)];
}
function range(a, b) {
return a + (b - a) * random();
}
// ------------------------------------------------------------
// Ground and street
// ------------------------------------------------------------
put("solid", 40, 0.55, 42, 0, -0.42, -5, 0x817d6d);
put("solid", 33, 0.18, 11.2, 0, -0.08, 5.8, 0x777a73);
const streetColors = [0x777a74, 0x85877f, 0x6f736e, 0x929087, 0x7d8078];
for (let z = 0.7; z < 11; z += 0.68) {
for (let x = -16; x <= 16; x += 0.68) {
if (Math.abs(x) < 2.3 && z < 1.3) continue;
put(
"solid", 0.62, 0.12, 0.61,
x + range(-0.025, 0.025), 0.015 + range(-0.012, 0.012), z + range(-0.02, 0.02),
pick(streetColors)
);
}
}
// Sidewalk and curb.
put("solid", 33, 0.22, 1.2, 0, 0.03, 0.35, 0xb5aa91);
put("solid", 33, 0.27, 0.28, 0, 0.08, 0.95, 0x9d9785);
for (let x = -15.5; x < 16; x += 1.15) {
put("solid", 1.06, 0.055, 0.76, x, 0.17, 0.38, pick([0xb9af98, 0xc0b59b, 0xaaa38e]));
}
// Street bollards.
for (const x of [-4.5, 4.5, 9.2, -9.2]) {
put("solid", 0.25, 0.88, 0.25, x, 0.44, 1.2, 0x253e43);
put("solid", 0.29, 0.10, 0.29, x, 0.78, 1.2, 0xd8c99e);
}
// ------------------------------------------------------------
// Main Hackesche Höfe facade
// ------------------------------------------------------------
const facadeWidth = 15.12;
const blockSize = 0.42;
const facadeRows = 21;
const facadeCols = 36;
const archSpring = 2.35;
const archRadius = 2.20;
const facadeOchre = [
0xd99445, 0xe2a04b, 0xcf873d, 0xe8aa55,
0xd99547, 0xdb9b49, 0xc97e36, 0xe3a151
];
function isOpening(x, y) {
if (Math.abs(x) >= archRadius) return false;
if (y <= archSpring) return true;
const dy = y - archSpring;
if (dy > archRadius) return false;
return Math.abs(x) < Math.sqrt(archRadius * archRadius - dy * dy);
}
function cellAt(col, row) {
if (col < 0 || row < 0 || col >= facadeCols || row >= facadeRows) return null;
const x = -facadeWidth / 2 + (col + 0.5) * blockSize;
const y = (row + 0.5) * blockSize;
return { col, row, x, y, opening: isOpening(x, y) };
}
const facadeCells = [];
for (let row = 0; row < facadeRows; row++) {
for (let col = 0; col < facadeCols; col++) {
const cell = cellAt(col, row);
facadeCells.push(cell);
if (cell.opening) continue;
put(
"solid",
blockSize - 0.035, blockSize - 0.035, 0.68,
cell.x, cell.y, 0,
pick(facadeOchre)
);
}
}
// Colored glazed voxel tiles around the arch.
const tileColors = [0x287b84, 0x245b78, 0x43a3a1, 0xdfc66f, 0x376f8b];
let tileIndex = 0;
for (const cell of facadeCells) {
if (cell.opening) continue;
const adjacentToOpening = [
cellAt(cell.col - 1, cell.row),
cellAt(cell.col + 1, cell.row),
cellAt(cell.col, cell.row - 1),
cellAt(cell.col, cell.row + 1)
].some(other => other && other.opening);
if (adjacentToOpening) {
put(
"solid", 0.335, 0.335, 0.115,
cell.x, cell.y, 0.395,
tileColors[tileIndex++ % tileColors.length]
);
}
}
// Pixel-style window construction.
function frontWindow(x, y, width = 0.88, height = 1.42, z = 0.41, shutter = 0x3f665e) {
put("glass", width, height, 0.09, x, y, z, 0x244e5b);
put("solid", 0.12, height + 0.18, 0.13, x - width / 2 - 0.05, y, z + 0.06, 0xe7d9aa);
put("solid", 0.12, height + 0.18, 0.13, x + width / 2 + 0.05, y, z + 0.06, 0xe7d9aa);
put("solid", width + 0.22, 0.12, 0.13, x, y + height / 2 + 0.06, z + 0.06, 0xe7d9aa);
put("solid", width + 0.22, 0.14, 0.17, x, y - height / 2 - 0.06, z + 0.07, 0xd4c38f);
put("solid", 0.065, height, 0.11, x, y, z + 0.09, 0xd9c99a);
put("solid", width, 0.065, 0.11, x, y + 0.05, z + 0.09, 0xd9c99a);
put("solid", 0.20, height + 0.05, 0.10, x - width / 2 - 0.22, y, z + 0.03, shutter);
put("solid", 0.20, height + 0.05, 0.10, x + width / 2 + 0.22, y, z + 0.03, shutter);
}
// Windows on the two facade wings.
const wingXs = [-6.35, -4.9, -3.42, 3.42, 4.9, 6.35];
const windowYs = [2.25, 4.45, 6.58];
for (const y of windowYs) {
for (const x of wingXs) {
frontWindow(
x, y, 0.82, 1.42,
0.405,
x < 0 ? 0x466e63 : 0x365b6b
);
}
}
// Three central upper windows.
for (const x of [-1.34, 0, 1.34]) {
frontWindow(x, 5.83, 0.78, 1.48, 0.405, 0x416b65);
}
// Horizontal facade trim.
put("solid", 15.35, 0.22, 0.92, 0, 8.72, 0, 0xb97b39);
put("solid", 15.1, 0.18, 0.84, 0, 0.12, 0, 0xa85f30);
// Pixel sign.
const glyphs = {
H: ["10001","10001","10001","11111","10001","10001","10001"],
A: ["01110","10001","10001","11111","10001","10001","10001"],
C: ["01111","10000","10000","10000","10000","10000","01111"],
K: ["10001","10010","10100","11000","10100","10010","10001"],
E: ["11111","10000","10000","11110","10000","10000","11111"],
S: ["01111","10000","10000","01110","00001","00001","11110"],
O: ["01110","10001","10001","10001","10001","10001","01110"],
"Ö": ["01010","01110","10001","10001","10001","10001","01110"],
F: ["11111","10000","10000","11110","10000","10000","10000"],
" ": ["00000","00000","00000","00000","00000","00000","00000"]
};
const signText = "HACKESCHE HÖFE";
const pixel = 0.10;
const signWidth = (signText.length * 6 - 1) * pixel;
put("solid", signWidth + 0.55, 1.03, 0.18, 0, 7.66, 0.48, 0x244b55);
put("solid", signWidth + 0.35, 0.08, 0.20, 0, 8.08, 0.51, 0xd7c16f);
let cursor = -signWidth / 2;
for (const char of signText) {
const glyph = glyphs[char];
for (let row = 0; row < glyph.length; row++) {
for (let col = 0; col < glyph[row].length; col++) {
if (glyph[row][col] === "1") {
put(
"solid", pixel * 0.82, pixel * 0.82, 0.11,
cursor + col * pixel, 7.66 + (3 - row) * pixel, 0.62,
0xf2e6b5
);
}
}
}
cursor += 6 * pixel;
}
// Wall lanterns flanking the portal.
for (const x of [-2.82, 2.82]) {
put("solid", 0.13, 0.42, 0.15, x, 4.83, 0.56, 0x253d40);
put("solid", 0.32, 0.43, 0.32, x, 4.48, 0.68, 0x243f46);
put("glow", 0.18, 0.25, 0.18, x, 4.48, 0.87, 0xffd77c);
}
// ------------------------------------------------------------
// Neighboring street buildings
// ------------------------------------------------------------
function neighboringBuilding(cx, width, height, baseColor, accentColor) {
put("solid", width, height, 2.15, cx, height / 2, 0.12, baseColor);
put("solid", width + 0.25, 0.28, 2.35, cx, height + 0.04, 0.12, accentColor);
put("solid", width + 0.12, 0.22, 2.25, cx, 0.11, 0.12, accentColor);
for (let y = 1.55; y < height - 0.6; y += 2.05) {
for (let x = cx - width / 2 + 1.15; x < cx + width / 2 - 0.5; x += 1.85) {
frontWindow(x, y, 0.86, 1.48, 1.235, random() > 0.5 ? 0x52675c : 0x435d68);
}
}
}
neighboringBuilding(-10.55, 6.2, 8.7, 0xb87e58, 0x9b644c);
neighboringBuilding(10.65, 6.25, 9.45, 0xc49467, 0xa86f50);
// ------------------------------------------------------------
// Interior passage
// ------------------------------------------------------------
const passageColors = [0x225363, 0x2b6872, 0x1d4b62, 0x357d82, 0x3d8c8a];
// Floor.
put("solid", 4.55, 0.16, 7.2, 0, 0.01, -3.35, 0x304f59);
for (let z = -6.8; z < 0; z += 0.47) {
for (let x = -2.05; x <= 2.05; x += 0.47) {
put(
"solid", 0.42, 0.12, 0.42,
x + range(-0.025, 0.025), 0.12, z,
pick([0x3c6266, 0x496d6e, 0x35565e, 0x527877])
);
}
}
// Tiled side walls.
for (let z = -6.9; z < 0.1; z += 0.42) {
for (let y = 0.22; y < 4.1; y += 0.42) {
put("solid", 0.34, 0.38, 0.39, -2.27, y, z, pick(passageColors));
put("solid", 0.34, 0.38, 0.39, 2.27, y, z, pick(passageColors));
}
}
// Stepped barrel-vault roof.
for (let z = -6.9; z < 0.1; z += 0.42) {
for (let x = -2.1; x <= 2.1; x += 0.42) {
const normalized = x / 2.25;
const curve = Math.sqrt(Math.max(0, 1 - normalized * normalized));
const y = 4.02 + curve * 0.72;
put("solid", 0.39, 0.38, 0.39, x, y, z, pick(passageColors));
}
}
// Dark threshold and small passage lanterns.
put("solid", 4.5, 0.12, 0.28, 0, 0.18, 0.02, 0x243a40);
for (const z of [-1.2, -4.5]) {
put("glow", 0.15, 0.28, 0.15, -2.03, 2.85, z, 0xffc96f);
put("glow", 0.15, 0.28, 0.15, 2.03, 2.85, z, 0xffc96f);
}
// ------------------------------------------------------------
// Courtyard paving
// ------------------------------------------------------------
put("solid", 18.2, 0.20, 18.4, 0, 0.0, -8.65, 0x829181);
const courtyardPavers = [0x9b9b86, 0x8d927f, 0xa4a18a, 0x858d7d, 0xb0a58d];
for (let z = -17.4; z < -0.2; z += 0.72) {
for (let x = -8.55; x <= 8.55; x += 0.72) {
put(
"solid", 0.65, 0.11, 0.65,
x + range(-0.03, 0.03), 0.15 + range(-0.012, 0.012), z + range(-0.025, 0.025),
pick(courtyardPavers)
);
}
}
// ------------------------------------------------------------
// Courtyard buildings
// ------------------------------------------------------------
// Back facade, assembled as colored masonry blocks.
const backPalette = [0xca8a58, 0xd49a61, 0x779795, 0x5f8d91, 0xd1b279, 0xb96e52];
for (let row = 0; row < 15; row++) {
for (let col = 0; col < 27; col++) {
const x = -8.45 + col * 0.65;
const y = 0.3 + row * 0.57;
let color = pick(backPalette);
if (row === 0) color = 0x7e7566;
put("solid", 0.61, 0.53, 0.72, x, y, -17.05, color);
}
}
put("solid", 18, 0.24, 0.95, 0, 8.72, -17.02, 0x536e70);
put("solid", 18, 0.16, 0.85, 0, 0.25, -17.02, 0x636d67);
const backWindowXs = [-7.25, -4.85, -2.45, 0, 2.45, 4.85, 7.25];
for (const y of [1.55, 3.65, 5.75, 7.7]) {
for (const x of backWindowXs) {
frontWindow(x, y, 0.88, 1.38, -16.62, random() > 0.5 ? 0x4f776e : 0x435e78);
}
}
// Side courtyard facades.
function sideFacade(x, colorA, colorB) {
for (let z = -7.4; z > -17.0; z -= 0.66) {
for (let y = 0.35; y < 8.8; y += 0.64) {
const color = ((Math.floor(y / 0.64) + Math.floor(z / 0.66)) % 3 === 0) ? colorB : colorA;
put("solid", 0.72, 0.59, 0.61, x, y, z, color);
}
}
put("solid", 0.95, 0.22, 10.6, x, 8.76, -12.1, 0x4d7376);
}
sideFacade(-8.72, 0xc98e5e, 0xd2a56b);
sideFacade(8.72, 0x6b9490, 0x83a49a);
function sideWindow(x, z, y, shutter) {
put("glass", 0.09, 1.38, 0.88, x, y, z, 0x244d5c);
put("solid", 0.13, 1.54, 0.11, x + (x < 0 ? 0.06 : -0.06), y, z - 0.49, 0xe1d2a5);
put("solid", 0.13, 1.54, 0.11, x + (x < 0 ? 0.06 : -0.06), y, z + 0.49, 0xe1d2a5);
put("solid", 0.13, 0.11, 1.08, x + (x < 0 ? 0.06 : -0.06), y + 0.76, z, 0xe1d2a5);
put("solid", 0.13, 0.11, 1.08, x + (x < 0 ? 0.06 : -0.06), y - 0.76, z, 0xd1bf8d);
put("solid", 0.10, 1.4, 0.08, x + (x < 0 ? 0.09 : -0.09), y, z, 0xd5c695);
put("solid", 0.10, 0.65, 0.16, x + (x < 0 ? 0.11 : -0.11), y, z - 0.60, shutter);
}
for (const z of [-8.7, -11.2, -13.7, -15.8]) {
for (const y of [1.55, 3.65, 5.75, 7.7]) {
sideWindow(-8.28, z, y, 0x456e63);
sideWindow(8.28, z, y, 0x425e75);
}
}
// ------------------------------------------------------------
// Courtyard greenery
// ------------------------------------------------------------
function tree(x, z, scale = 1) {
const planterColor = pick([0x9a7657, 0x8a684f, 0xa27d5b]);
put("solid", 1.65 * scale, 0.62 * scale, 1.65 * scale, x, 0.42, z, planterColor);
put("solid", 1.45 * scale, 0.15 * scale, 1.45 * scale, x, 0.75 * scale, z, 0x554b38);
put("solid", 0.34 * scale, 2.25 * scale, 0.34 * scale, x, 1.85 * scale, z, 0x6d5139);
put("solid", 0.27 * scale, 1.25 * scale, 0.27 * scale, x + 0.48 * scale, 2.55 * scale, z, 0x6d5139);
put("solid", 0.25 * scale, 1.0 * scale, 0.25 * scale, x - 0.38 * scale, 2.35 * scale, z + 0.12, 0x6d5139);
const greens = [0x4f7850, 0x5f8858, 0x426d49, 0x71935b];
for (let i = 0; i < 34; i++) {
const angle = random() * Math.PI * 2;
const radius = random() * 1.05 * scale;
const px = x + Math.cos(angle) * radius;
const pz = z + Math.sin(angle) * radius;
const py = (3.0 + random() * 1.25) * scale;
const size = (0.42 + random() * 0.38) * scale;
put("solid", size, size, size, px, py, pz, pick(greens));
}
}
tree(-6.7, -8.4, 1.05);
tree(6.5, -8.7, 0.95);
tree(-6.8, -15.0, 0.88);
tree(6.7, -14.8, 1.03);
// Small shrubs.
for (const [x, z] of [[-3.8,-7.6], [3.8,-7.5], [-4.0,-15.8], [4.0,-15.7]]) {
put("solid", 1.2, 0.38, 0.8, x, 0.38, z, 0x8d6c51);
for (let i = 0; i < 9; i++) {
put(
"solid", 0.38, 0.35, 0.38,
x + range(-0.42, 0.42), 0.68 + range(0, 0.22), z + range(-0.25, 0.25),
pick([0x4f7950, 0x628957, 0x426c48])
);
}
}
// ------------------------------------------------------------
// String lights and laundry
// ------------------------------------------------------------
for (const z of [-9.2, -13.2]) {
put("solid", 0.17, 5.4, 0.17, -7.75, 2.7, z, 0x3c4f4c);
put("solid", 0.17, 5.4, 0.17, 7.75, 2.7, z, 0x3c4f4c);
const segments = 24;
for (let i = 0; i < segments; i++) {
const x1 = -7.75 + (15.5 * i / segments);
const x2 = -7.75 + (15.5 * (i + 1) / segments);
const y1 = 5.25 - 0.62 * (1 - Math.pow(x1 / 7.75, 2));
const y2 = 5.25 - 0.62 * (1 - Math.pow(x2 / 7.75, 2));
const length = Math.hypot(x2 - x1, y2 - y1);
const angle = Math.atan2(y2 - y1, x2 - x1);
put(
"solid", length, 0.035, 0.035,
(x1 + x2) / 2, (y1 + y2) / 2, z,
0x394747, 0, 0, angle
);
if (i % 2 === 0) {
put("solid", 0.035, 0.18, 0.035, x1, y1 - 0.11, z, 0x394747);
put("glow", 0.14, 0.16, 0.14, x1, y1 - 0.25, z, 0xffd37b);
}
}
}
// Laundry line between the side buildings.
put("solid", 15.2, 0.035, 0.035, 0, 4.3, -11.75, 0x3a4745);
const laundryColors = [0xe7dcc0, 0x6f9f9d, 0xcc765a, 0xe4b95d, 0x6d7d9b];
for (let i = 0; i < 10; i++) {
const x = -6.7 + i * 1.47;
put(
"solid", 0.62, 0.82, 0.08,
x, 3.86, -11.75,
pick(laundryColors)
);
}
// ------------------------------------------------------------
// Café furniture and courtyard details
// ------------------------------------------------------------
function cafeTable(x, z) {
put("solid", 1.12, 0.13, 0.84, x, 0.94, z, 0xb5774e);
put("solid", 0.12, 0.78, 0.12, x, 0.52, z, 0x354747);
put("solid", 0.72, 0.10, 0.55, x, 0.18, z, 0x354747);
}
function chair(x, z, rotation = 0) {
put("solid", 0.62, 0.12, 0.62, x, 0.57, z, 0x3e6f68, 0, rotation);
put("solid", 0.62, 0.68, 0.12, x, 0.91, z - 0.25, 0x3e6f68, 0, rotation);
put("solid", 0.10, 0.48, 0.10, x - 0.23, 0.29, z - 0.22, 0x34494a);
put("solid", 0.10, 0.48, 0.10, x + 0.23, 0.29, z - 0.22, 0x34494a);
}
cafeTable(3.1, -10.3);
chair(2.15, -10.3);
chair(4.05, -10.3);
cafeTable(-3.0, -12.7);
chair(-3.95, -12.7);
chair(-2.05, -12.7);
// Benches.
for (const [x, z] of [[-4.5,-9.8], [4.7,-14.2]]) {
put("solid", 2.4, 0.16, 0.62, x, 0.62, z, 0x9b6947);
put("solid", 2.4, 0.62, 0.12, x, 0.98, z - 0.27, 0x9b6947);
put("solid", 0.16, 0.55, 0.48, x - 0.9, 0.33, z, 0x33484a);
put("solid", 0.16, 0.55, 0.48, x + 0.9, 0.33, z, 0x33484a);
}
// Utility cabinet and bicycles.
put("solid", 0.82, 1.35, 0.62, -7.45, 0.79, -12.2, 0x456e6c);
put("solid", 0.68, 0.55, 0.08, -7.45, 1.05, -11.85, 0x9eb5a1);
function bicycle(x, z) {
put("solid", 0.72, 0.72, 0.10, x - 0.48, 0.55, z, 0x283b3f);
put("solid", 0.72, 0.72, 0.10, x + 0.48, 0.55, z, 0x283b3f);
put("solid", 0.85, 0.09, 0.09, x - 0.12, 0.75, z, 0xb85c42);
put("solid", 0.09, 0.72, 0.09, x - 0.38, 0.62, z, 0xb85c42);
put("solid", 0.09, 0.72, 0.09, x + 0.28, 0.62, z, 0xb85c42);
put("solid", 0.44, 0.08, 0.08, x - 0.22, 1.00, z, 0x283b3f);
put("solid", 0.10, 0.44, 0.10, x + 0.43, 0.92, z, 0x283b3f);
}
bicycle(-5.8, -10.3);
bicycle(5.9, -8.4);
// Small warm window boxes.
for (const x of [-4.85, -2.45, 2.45, 4.85]) {
put("solid", 1.0, 0.20, 0.24, x, 1.13, -16.47, 0x8a634b);
for (let i = 0; i < 5; i++) {
put(
"solid", 0.22, 0.28, 0.20,
x - 0.38 + i * 0.19, 1.36, -16.46,
pick([0x4e784f, 0x668a58, 0xb46b50])
);
}
}
// ------------------------------------------------------------
// Voxel clouds
// ------------------------------------------------------------
function cloud(x, y, z, scale) {
const whites = [0xe8f1e9, 0xf3f4e8, 0xd7e7e5];
for (let i = 0; i < 15; i++) {
const size = range(0.65, 1.25) * scale;
put(
"solid", size, size * 0.65, size,
x + range(-2.4, 2.4) * scale,
y + range(-0.35, 0.35) * scale,
z + range(-0.7, 0.7) * scale,
pick(whites)
);
}
}
cloud(-10, 11.7, -22, 1.1);
cloud(9, 13.2, -27, 1.35);
cloud(2, 10.8, -30, 0.85);
// ------------------------------------------------------------
// Commit batches
// ------------------------------------------------------------
flushBatch("solid", new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.88,
metalness: 0.0
}));
flushBatch("glass", new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.28,
metalness: 0.18
}));
flushBatch("glow", new THREE.MeshBasicMaterial({
color: 0xffffff,
toneMapped: false
}));
// ------------------------------------------------------------
// Direct camera controls — no addons
// ------------------------------------------------------------
const target = new THREE.Vector3(0, 3.0, -1.1);
let yaw = 0.26;
let pitch = 0.27;
let distance = 19.5;
const defaultView = {
target: new THREE.Vector3(0, 3.0, -1.1),
yaw: 0.26,
pitch: 0.27,
distance: 19.5
};
function updateCamera() {
const horizontal = Math.cos(pitch) * distance;
camera.position.set(
target.x + Math.sin(yaw) * horizontal,
target.y + Math.sin(pitch) * distance,
target.z + Math.cos(yaw) * horizontal
);
camera.lookAt(target);
}
function resetCamera() {
target.copy(defaultView.target);
yaw = defaultView.yaw;
pitch = defaultView.pitch;
distance = defaultView.distance;
updateCamera();
}
const canvas = renderer.domElement;
let dragging = false;
let lastX = 0;
let lastY = 0;
let shiftPressed = false;
canvas.addEventListener("pointerdown", event => {
dragging = true;
lastX = event.clientX;
lastY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
if (shiftPressed) {
const panScale = distance * 0.0012;
target.x -= dx * panScale;
target.z += dy * panScale;
target.x = THREE.MathUtils.clamp(target.x, -15, 15);
target.z = THREE.MathUtils.clamp(target.z, -17, 8);
} else {
yaw -= dx * 0.005;
pitch = THREE.MathUtils.clamp(pitch + dy * 0.004, 0.04, 1.12);
}
updateCamera();
});
function endDrag(event) {
dragging = false;
if (event && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("wheel", event => {
event.preventDefault();
distance = THREE.MathUtils.clamp(distance * Math.exp(event.deltaY * 0.001), 6, 36);
updateCamera();
}, { passive: false });
canvas.addEventListener("dblclick", resetCamera);
addEventListener("keydown", event => {
shiftPressed = event.shiftKey;
const panSpeed = distance * 0.025;
if (event.key === "r" || event.key === "R") resetCamera();
if (event.key === "ArrowLeft") target.x -= panSpeed;
if (event.key === "ArrowRight") target.x += panSpeed;
if (event.key === "ArrowUp") target.z -= panSpeed;
if (event.key === "ArrowDown") target.z += panSpeed;
target.x = THREE.MathUtils.clamp(target.x, -15, 15);
target.z = THREE.MathUtils.clamp(target.z, -17, 8);
updateCamera();
});
addEventListener("keyup", event => {
shiftPressed = event.shiftKey;
});
const views = {
street: {
target: new THREE.Vector3(0, 3.0, -0.5),
yaw: 0.20,
pitch: 0.22,
distance: 17.5
},
passage: {
target: new THREE.Vector3(0, 1.9, -3.1),
yaw: 0.03,
pitch: 0.075,
distance: 7.2
},
courtyard: {
target: new THREE.Vector3(-0.6, 2.5, -11.7),
yaw: -0.66,
pitch: 0.29,
distance: 12.2
}
};
document.querySelectorAll("[data-view]").forEach(button => {
button.addEventListener("click", () => {
const view = views[button.dataset.view];
target.copy(view.target);
yaw = view.yaw;
pitch = view.pitch;
distance = view.distance;
updateCamera();
});
});
addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
updateCamera();
renderer.setAnimationLoop(() => renderer.render(scene, camera));
</script>
</body>
</html>
```