Prompt specification
Build or customize the Three.js 3D scene "Getsemaní square and residential street 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: Getsemaní square and residential street fragment
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/getseman-square-and-residential-street-fragment-x2727
Scene Description Prompt:
A voxel Getsemaní square in Cartagena, with homes, a church edge, neighbors, and original murals. Three.js from cdnjs, one HTML file.
Working Three.js Starter (getseman-square-and-residential-street-fragment-x2727):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Getsemaní — Cartagena</title>
<style>
:root {
color-scheme: light;
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #8fc9d6;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
#title {
position: fixed;
z-index: 10;
top: 22px;
left: 22px;
max-width: min(410px, calc(100vw - 44px));
padding: 17px 20px 16px;
color: #17343b;
background: rgba(255, 248, 229, 0.91);
border: 1px solid rgba(80, 55, 38, 0.17);
border-radius: 14px;
box-shadow: 0 12px 35px rgba(54, 42, 30, 0.16);
backdrop-filter: blur(10px);
user-select: none;
pointer-events: none;
}
#title .eyebrow {
margin-bottom: 5px;
color: #b94e35;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
#title h1 {
margin: 0;
font-size: clamp(24px, 4vw, 38px);
line-height: 0.98;
letter-spacing: -0.04em;
}
#title p {
margin: 9px 0 0;
color: #496168;
font-size: 13px;
line-height: 1.4;
}
#controls {
position: fixed;
z-index: 10;
right: 22px;
bottom: 22px;
display: flex;
align-items: center;
gap: 12px;
padding: 10px 12px;
color: #26464d;
background: rgba(255, 248, 229, 0.91);
border: 1px solid rgba(80, 55, 38, 0.16);
border-radius: 12px;
box-shadow: 0 10px 28px rgba(54, 42, 30, 0.14);
backdrop-filter: blur(10px);
font-size: 12px;
}
#controls span {
white-space: nowrap;
}
button {
padding: 8px 12px;
color: #fff8e5;
background: #b94e35;
border: 0;
border-radius: 8px;
cursor: pointer;
font: inherit;
font-weight: 750;
}
button:hover {
background: #963b2b;
}
#swatches {
position: fixed;
z-index: 10;
bottom: 22px;
left: 22px;
display: flex;
gap: 5px;
padding: 9px;
background: rgba(255, 248, 229, 0.86);
border: 1px solid rgba(80, 55, 38, 0.13);
border-radius: 10px;
box-shadow: 0 8px 25px rgba(54, 42, 30, 0.12);
pointer-events: none;
}
#swatches i {
width: 19px;
height: 19px;
border-radius: 4px;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
@media (max-width: 700px) {
#title {
top: 12px;
left: 12px;
padding: 13px 15px;
}
#title p {
display: none;
}
#controls {
right: 12px;
bottom: 12px;
}
#controls span {
display: none;
}
#swatches {
bottom: 12px;
left: 12px;
}
}
</style>
</head>
<body>
<div id="title">
<div class="eyebrow">Cartagena de Indias · Colombia</div>
<h1>Getsemaní</h1>
<p>A colorful voxel neighborhood with original wall art, local neighbors,
palms, market stalls, and the edge of the old church.</p>
</div>
<div id="swatches" aria-hidden="true">
<i style="background:#e56b4f"></i>
<i style="background:#f2bd45"></i>
<i style="background:#4da6a1"></i>
<i style="background:#477aa1"></i>
<i style="background:#9b6a91"></i>
</div>
<div id="controls">
<span>Drag: orbit · Right-drag: pan · Scroll: zoom</span>
<button id="reset" type="button">Reset view</button>
</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(0x91c9d6);
scene.fog = new THREE.Fog(0x91c9d6, 68, 135);
const camera = new THREE.OrthographicCamera(-25, 25, 20, -20, 0.1, 200);
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;
document.body.appendChild(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xd8f2ff, 0x9a6945, 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff1ca, 3.6);
sun.position.set(-24, 36, 28);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -38;
sun.shadow.camera.right = 38;
sun.shadow.camera.top = 38;
sun.shadow.camera.bottom = -38;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 90;
sun.shadow.bias = -0.0005;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x83c7d5, 0.65);
fill.position.set(30, 12, -25);
scene.add(fill);
// -------------------------------------------------------------------------
// Small voxel construction helpers
// -------------------------------------------------------------------------
const geometryCache = new Map();
const materialCache = new Map();
function geometry(w, h, d) {
const key = `${w}|${h}|${d}`;
if (!geometryCache.has(key)) {
geometryCache.set(key, new THREE.BoxGeometry(w, h, d));
}
return geometryCache.get(key);
}
function material(color) {
const key = String(color);
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: 0.92,
metalness: 0
})
);
}
return materialCache.get(key);
}
function box(w, h, d, x, y, z, color, parent = scene, castShadow = true) {
const mesh = new THREE.Mesh(
geometry(w, h, d),
color && color.isMaterial ? color : material(color)
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
let randomSeed = 730914;
function random() {
randomSeed = (randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
const cream = 0xf3e7cc;
const dark = 0x293d43;
const roofRed = 0xb95c42;
const soil = 0x6f4b37;
// -------------------------------------------------------------------------
// Ground, streets, and plaza cobbles
// -------------------------------------------------------------------------
box(52, 0.7, 46, 0, -0.43, 0, 0xd8c49f);
box(49, 0.13, 42, 0, -0.02, 0, 0xb9aa91);
// Pale pedestrian margins around the cobbled square.
box(28.2, 0.18, 24.2, 0, 0.02, 0, 0xe2d1b2);
box(25.4, 0.18, 21.8, 0, 0.09, 0, 0xc2b394);
const cobbleGeometry = new THREE.BoxGeometry(0.93, 0.12, 0.93);
const cobbleMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 1
});
const columns = 25;
const rows = 21;
const cobbles = new THREE.InstancedMesh(
cobbleGeometry,
cobbleMaterial,
columns * rows
);
cobbles.receiveShadow = true;
const matrix = new THREE.Matrix4();
const cobbleColors = [
0xc9bca4,
0xd8c9ad,
0xb9aa92,
0xd4c2a6,
0xc0b39d,
0xddcfb5
];
let cobbleIndex = 0;
for (let z = 0; z < rows; z++) {
for (let x = 0; x < columns; x++) {
const px = (x - (columns - 1) / 2) * 1.02;
const pz = (z - (rows - 1) / 2) * 1.02;
matrix.makeTranslation(px, 0.23 + random() * 0.012, pz);
cobbles.setMatrixAt(cobbleIndex, matrix);
cobbles.setColorAt(
cobbleIndex,
new THREE.Color(cobbleColors[Math.floor(random() * cobbleColors.length)])
);
cobbleIndex++;
}
}
cobbles.instanceMatrix.needsUpdate = true;
if (cobbles.instanceColor) cobbles.instanceColor.needsUpdate = true;
scene.add(cobbles);
// -------------------------------------------------------------------------
// Procedural original murals
// -------------------------------------------------------------------------
function makeMuralTexture(index) {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.imageSmoothingEnabled = false;
if (index === 0) {
ctx.fillStyle = "#123f48";
ctx.fillRect(0, 0, 512, 256);
ctx.fillStyle = "#f4b942";
ctx.fillRect(206, 34, 100, 100);
ctx.fillStyle = "#f9db6d";
ctx.fillRect(226, 14, 60, 20);
ctx.fillRect(226, 134, 60, 20);
const cityColors = ["#e76545", "#f29d38", "#4c9b92", "#e9c56a"];
for (let i = 0; i < 7; i++) {
ctx.fillStyle = cityColors[i % cityColors.length];
ctx.fillRect(i * 73, 166 - (i % 3) * 18, 61, 90);
ctx.fillStyle = "#f9e7bc";
ctx.fillRect(i * 73 + 12, 183 - (i % 3) * 18, 9, 13);
ctx.fillRect(i * 73 + 37, 183 - (i % 3) * 18, 9, 13);
}
ctx.fillStyle = "#f6e8c9";
ctx.font = "bold 29px sans-serif";
ctx.textAlign = "center";
ctx.fillText("SOL DE BARRA", 256, 230);
} else if (index === 1) {
ctx.fillStyle = "#e56b4f";
ctx.fillRect(0, 0, 512, 256);
ctx.fillStyle = "#f5d99c";
for (let i = 0; i < 4; i++) {
const x = 70 + i * 122;
ctx.fillRect(x - 7, 86, 14, 143);
ctx.fillRect(x - 31, 115, 62, 13);
ctx.fillStyle = ["#f3bf45", "#247d78", "#f8ead0", "#6d416f"][i];
ctx.fillRect(x - 28, 53, 56, 42);
ctx.fillRect(x - 17, 42, 34, 14);
ctx.fillStyle = "#f5d99c";
}
ctx.fillStyle = "#183f45";
ctx.font = "bold 27px sans-serif";
ctx.textAlign = "center";
ctx.fillText("FLORECEN JUNTAS", 256, 35);
} else if (index === 2) {
ctx.fillStyle = "#1f7187";
ctx.fillRect(0, 0, 512, 256);
ctx.fillStyle = "#f5d58e";
ctx.fillRect(385, 31, 72, 72);
ctx.fillRect(406, 11, 30, 112);
const waveColors = ["#75b9b3", "#2d8995", "#164e68"];
for (let row = 0; row < 3; row++) {
ctx.fillStyle = waveColors[row];
for (let i = 0; i < 9; i++) {
ctx.fillRect(i * 65 - 10, 146 + row * 30, 42, 17);
}
}
ctx.fillStyle = "#f07845";
ctx.fillRect(106, 85, 82, 42);
ctx.fillRect(188, 85, 25, 42);
ctx.fillRect(97, 73, 18, 16);
ctx.fillRect(97, 122, 18, 16);
ctx.fillStyle = "#fff1cf";
ctx.font = "bold 26px sans-serif";
ctx.textAlign = "center";
ctx.fillText("MAREA VIVA", 256, 48);
} else {
ctx.fillStyle = "#f1d7a5";
ctx.fillRect(0, 0, 512, 256);
const colors = ["#d85e45", "#3f8586", "#6d4d81", "#e7ae3f"];
for (let i = 0; i < 4; i++) {
const x = 34 + i * 122;
ctx.fillStyle = colors[i];
ctx.fillRect(x, 76, 82, 112);
ctx.fillRect(x + 17, 52, 48, 24);
ctx.fillStyle = "#f5e9cf";
ctx.fillRect(x + 20, 100, 12, 12);
ctx.fillRect(x + 50, 100, 12, 12);
ctx.fillRect(x + 29, 139, 24, 9);
}
ctx.fillStyle = "#173f47";
ctx.font = "bold 28px sans-serif";
ctx.textAlign = "center";
ctx.fillText("VECINOS CON ALMA", 256, 226);
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.magFilter = THREE.NearestFilter;
texture.minFilter = THREE.NearestFilter;
texture.generateMipmaps = false;
return texture;
}
const muralTextures = Array.from({ length: 4 }, (_, i) => makeMuralTexture(i));
function muralPanel(parent, width, height, x, y, z, rotationY, textureIndex) {
const panel = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: muralTextures[textureIndex % muralTextures.length],
side: THREE.DoubleSide
})
);
panel.position.set(x, y, z);
panel.rotation.y = rotationY;
parent.add(panel);
return panel;
}
// -------------------------------------------------------------------------
// Colonial voxel houses
// -------------------------------------------------------------------------
function addWindow(parent, x, y, z, width = 1.05, height = 1.25, shutterColor) {
box(width, height, 0.10, x, y, z, dark, parent);
box(width + 0.22, 0.13, 0.16, x, y + height / 2 + 0.03, z + 0.02, cream, parent);
box(width + 0.22, 0.13, 0.16, x, y - height / 2 - 0.03, z + 0.02, cream, parent);
box(0.13, height + 0.18, 0.16, x - width / 2 - 0.04, y, z + 0.02, cream, parent);
box(0.13, height + 0.18, 0.16, x + width / 2 + 0.04, y, z + 0.02, cream, parent);
if (shutterColor !== undefined) {
box(0.23, height + 0.08, 0.13, x - width / 2 - 0.25, y, z + 0.03, shutterColor, parent);
box(0.23, height + 0.08, 0.13, x + width / 2 + 0.25, y, z + 0.03, shutterColor, parent);
}
}
function addRoofPlant(parent, x, y, z) {
box(0.55, 0.45, 0.55, x, y + 0.22, z, roofRed, parent);
box(0.12, 0.55, 0.12, x - 0.14, y + 0.67, z, 0x3f8052, parent);
box(0.12, 0.7, 0.12, x + 0.11, y + 0.73, z + 0.02, 0x568e4b, parent);
box(0.45, 0.10, 0.15, x, y + 0.73, z - 0.12, 0x3f8052, parent);
}
function makeHouse({
x,
z,
width = 5.4,
depth = 6,
height = 7.5,
color,
accent,
rotation = 0,
mural = false
}) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
scene.add(group);
box(width, height, depth, 0, height / 2, 0, color, group);
box(width + 0.12, 0.35, depth + 0.12, 0, 0.18, 0, 0xb88a69, group);
// White cornice and rooftop terrace.
box(width + 0.35, 0.28, depth + 0.35, 0, height + 0.02, 0, cream, group);
box(width + 0.10, 0.20, depth + 0.10, 0, height + 0.26, 0, accent, group);
box(width, 0.65, 0.25, 0, height + 0.55, depth / 2, accent, group);
box(width, 0.65, 0.25, 0, height + 0.55, -depth / 2, accent, group);
box(0.25, 0.65, depth, width / 2, height + 0.55, 0, accent, group);
box(0.25, 0.65, depth, -width / 2, height + 0.55, 0, accent, group);
// Door and frame.
box(1.35, 2.25, 0.13, 0, 1.12, depth / 2 + 0.08, cream, group);
box(0.92, 1.82, 0.16, 0, 0.91, depth / 2 + 0.16, accent, group);
box(0.09, 0.09, 0.08, 0.27, 0.95, depth / 2 + 0.26, 0xf4d27a, group);
// Side windows.
addWindow(group, -width * 0.28, height * 0.48, depth / 2 + 0.08, 1.0, 1.2, accent);
addWindow(group, width * 0.28, height * 0.48, depth / 2 + 0.08, 1.0, 1.2, accent);
if (mural) {
muralPanel(
group,
width * 0.61,
2.25,
0,
height * 0.72,
depth / 2 + 0.19,
0,
Math.abs(Math.round(x + z)) % muralTextures.length
);
} else {
// A shallow balcony with voxel rails.
const balconyY = height * 0.49;
box(2.1, 0.16, 0.65, 0, balconyY - 0.08, depth / 2 + 0.34, cream, group);
box(0.12, 0.85, 0.12, -0.94, balconyY + 0.35, depth / 2 + 0.62, accent, group);
box(0.12, 0.85, 0.12, 0.94, balconyY + 0.35, depth / 2 + 0.62, accent, group);
box(2.05, 0.12, 0.12, 0, balconyY + 0.74, depth / 2 + 0.62, accent, group);
}
// Rooftop details.
addRoofPlant(group, -width * 0.30, height + 0.37, depth * 0.23);
box(0.75, 0.9, 0.75, width * 0.28, height + 0.8, -depth * 0.22, 0xd7c9ac, group);
// A few colorful exposed bricks.
for (let i = 0; i < 4; i++) {
box(
0.34,
0.18,
0.05,
-width * 0.43 + i * 0.42,
0.45 + (i % 2) * 0.25,
depth / 2 + 0.025,
0xa95b45,
group
);
}
return group;
}
const northHouses = [];
northHouses.push(
makeHouse({
x: -9.6,
z: -16.3,
width: 5.4,
depth: 6.4,
height: 7.6,
color: 0xe56b4f,
accent: 0xf0c66d,
mural: true
})
);
northHouses.push(
makeHouse({
x: -3.9,
z: -16.5,
width: 5.7,
depth: 6.2,
height: 8.5,
color: 0xf0bd48,
accent: 0x3e7f79
})
);
northHouses.push(
makeHouse({
x: 2.0,
z: -16.4,
width: 5.5,
depth: 6.4,
height: 7.1,
color: 0x4b9d96,
accent: 0xf4dfb5
})
);
northHouses.push(
makeHouse({
x: 8.0,
z: -16.4,
width: 5.8,
depth: 6.4,
height: 8.2,
color: 0x4d7897,
accent: 0xe5a13c,
mural: true
})
);
// East-side neighbors, facing the plaza.
const eastPositions = [-10.0, -4.0, 2.2, 8.2];
const eastColors = [0xf0c75d, 0xb65d65, 0x6a9e87, 0xd77948];
const eastAccents = [0x2f7773, 0xf4d59f, 0xe7b13e, 0x394e68];
eastPositions.forEach((z, i) => {
makeHouse({
x: 17.0,
z,
width: 5.4,
depth: 5.9,
height: 6.4 + (i % 2) * 1.5,
color: eastColors[i],
accent: eastAccents[i],
rotation: -Math.PI / 2,
mural: i === 1
});
});
// Partial homes at the distant corners.
makeHouse({
x: -18,
z: 17.5,
width: 6,
depth: 5,
height: 5.7,
color: 0xd98555,
accent: 0x416f70,
rotation: Math.PI
});
makeHouse({
x: 18,
z: 17,
width: 6,
depth: 5,
height: 6.2,
color: 0x8d6c91,
accent: 0xf1d9a0,
rotation: Math.PI
});
// -------------------------------------------------------------------------
// Church at the western edge
// -------------------------------------------------------------------------
const church = new THREE.Group();
church.position.set(-20, 0, -1.8);
scene.add(church);
box(8, 8.4, 18, 0, 4.2, -1.5, 0xe6d9b8, church);
box(8.45, 0.45, 18.45, 0, 8.45, -1.5, cream, church);
box(8.1, 0.45, 18.1, 0, 8.78, -1.5, roofRed, church);
// East-facing entrance.
box(0.15, 2.8, 2.0, 4.08, 1.4, 0.2, 0x76503a, church);
box(0.12, 0.65, 1.35, 4.18, 3.12, 0.2, 0x76503a, church);
box(0.12, 3.4, 0.18, 4.19, 1.7, 0.2, cream, church);
box(0.12, 3.4, 0.18, 4.19, 1.7, 1.25, cream, church);
// Tall side windows.
[-7.2, -3.6, 4.1].forEach((z, i) => {
box(0.14, 2.05, 0.85, 4.08, 5.2, z, 0x334e58, church);
box(0.17, 2.2, 0.15, 4.15, 5.2, z - 0.48, cream, church);
box(0.17, 2.2, 0.15, 4.15, 5.2, z + 0.48, cream, church);
if (i === 1) {
box(0.18, 1.05, 0.85, 4.16, 6.45, z, 0x334e58, church);
}
});
// Bell tower.
box(4.8, 12.5, 4.8, 0, 6.25, 8.0, 0xe8dbb9, church);
box(5.25, 0.42, 5.25, 0, 12.65, 8, cream, church);
box(4.6, 0.55, 4.6, 0, 13.05, 8, roofRed, church);
box(3.65, 0.55, 3.65, 0, 13.58, 8, roofRed, church);
box(2.7, 0.55, 2.7, 0, 14.11, 8, roofRed, church);
box(1.8, 0.55, 1.8, 0, 14.64, 8, roofRed, church);
box(0.16, 2.0, 1.25, 2.48, 10.6, 8, 0x253e44, church);
box(0.19, 2.15, 0.16, 2.55, 10.6, 7.31, cream, church);
box(0.19, 2.15, 0.16, 2.55, 10.6, 8.69, cream, church);
box(1.0, 0.15, 1.45, 0.2, 9.3, 8, 0x6e543b, church);
// Simple voxel cross.
box(0.18, 1.65, 0.18, 0, 15.65, 8, 0x5a4938, church);
box(0.95, 0.18, 0.18, 0, 15.9, 8, 0x5a4938, church);
// -------------------------------------------------------------------------
// Dedicated mural wall beside the plaza
// -------------------------------------------------------------------------
const muralWall = new THREE.Group();
muralWall.position.set(-14.6, 0, 4.0);
scene.add(muralWall);
box(0.6, 3.7, 8.7, 0, 1.85, 0, 0xb67b59, muralWall);
box(0.16, 4.05, 9.0, 0.34, 2.02, 0, cream, muralWall);
muralPanel(muralWall, 7.8, 3.15, 0.43, 1.9, 0, Math.PI / 2, 3);
// -------------------------------------------------------------------------
// Plaza fountain
// -------------------------------------------------------------------------
const fountain = new THREE.Group();
scene.add(fountain);
box(4.8, 0.55, 4.8, 0, 0.5, 0, 0xd9c9a8, fountain);
box(4.2, 0.5, 4.2, 0, 0.77, 0, 0xb99772, fountain);
box(3.65, 0.16, 3.65, 0, 1.03, 0, 0x62aeb0, fountain);
box(1.25, 1.15, 1.25, 0, 1.58, 0, 0xe2d0ac, fountain);
box(1.85, 0.28, 1.85, 0, 2.25, 0, 0xf0dec0, fountain);
box(0.7, 0.85, 0.7, 0, 2.77, 0, 0xe9d5b0, fountain);
box(1.15, 0.22, 1.15, 0, 3.25, 0, 0xf4e4c5, fountain);
const waterDrops = [];
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
const drop = box(
0.10,
0.34,
0.10,
Math.cos(angle) * 1.3,
2.65,
Math.sin(angle) * 1.3,
0x9ad9d4,
fountain,
false
);
waterDrops.push({ mesh: drop, angle, phase: i * 0.72 });
}
// -------------------------------------------------------------------------
// Palm trees, benches, lamps, and flower boxes
// -------------------------------------------------------------------------
function makePalm(x, z, scale = 1) {
const palm = new THREE.Group();
palm.position.set(x, 0, z);
palm.scale.setScalar(scale);
scene.add(palm);
for (let i = 0; i < 7; i++) {
box(
0.48,
0.72,
0.48,
Math.sin(i * 0.5) * 0.07,
0.36 + i * 0.62,
0,
i % 2 ? 0x9b7046 : 0xa87a4d,
palm
);
}
const crownY = 4.85;
box(0.85, 0.42, 0.85, 0, crownY, 0, 0x567a3d, palm);
for (let i = 0; i < 7; i++) {
const angle = (i / 7) * Math.PI * 2;
const leaf = box(
2.5,
0.22,
0.62,
Math.cos(angle) * 1.18,
crownY + 0.12,
Math.sin(angle) * 1.18,
i % 2 ? 0x3f8150 : 0x609448,
palm
);
leaf.rotation.y = -angle;
leaf.rotation.z = i % 2 ? 0.08 : -0.08;
}
box(0.28, 0.22, 0.28, 0.35, crownY - 0.25, 0.15, 0x785032, palm);
}
makePalm(-13.2, -10.6, 0.93);
makePalm(13.5, -9.6, 1.02);
makePalm(13.2, 10.2, 0.88);
makePalm(-10.7, 10.4, 0.84);
function makeBench(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
scene.add(group);
box(2.3, 0.15, 0.62, 0, 0.75, 0, 0x8c5b3d, group);
box(2.3, 0.48, 0.13, 0, 1.12, -0.28, 0x9d6844, group);
box(0.15, 0.7, 0.5, -0.83, 0.35, 0, 0x37464a, group);
box(0.15, 0.7, 0.5, 0.83, 0.35, 0, 0x37464a, group);
}
makeBench(-5.8, 8.0, 0);
makeBench(6.2, 7.8, 0);
makeBench(8.8, 3.5, Math.PI / 2);
function makeLamp(x, z) {
const group = new THREE.Group();
group.position.set(x, 0, z);
scene.add(group);
box(0.55, 0.25, 0.55, 0, 0.18, 0, 0x4e5453, group);
box(0.16, 3.6, 0.16, 0, 1.9, 0, 0x39484b, group);
box(0.7, 0.12, 0.7, 0, 3.7, 0, 0x39484b, group);
const glow = new THREE.MeshStandardMaterial({
color: 0xffe4a4,
emissive: 0xffb84c,
emissiveIntensity: 1.6,
roughness: 0.7
});
box(0.48, 0.58, 0.48, 0, 3.34, 0, glow, group, false);
box(0.72, 0.13, 0.72, 0, 3.72, 0, 0x39484b, group);
}
makeLamp(-12.6, 7.7);
makeLamp(12.5, -4.0);
makeLamp(-7.0, -11.5);
function flowerBox(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
scene.add(group);
box(1.7, 0.48, 0.8, 0, 0.3, 0, 0xa86643, group);
box(1.5, 0.12, 0.62, 0, 0.58, 0, soil, group);
const flowerColors = [0xf3ba43, 0xe7654e, 0xf0e1b2, 0xa55a83];
for (let i = 0; i < 8; i++) {
const fx = -0.62 + (i % 4) * 0.41;
const fz = i < 4 ? -0.13 : 0.13;
box(0.12, 0.38, 0.12, fx, 0.77, fz, 0x47794d, group);
box(0.27, 0.18, 0.27, fx, 1.02, fz, flowerColors[i % flowerColors.length], group);
}
}
flowerBox(-11.6, 3.0, Math.PI / 2);
flowerBox(11.7, 6.4, Math.PI / 2);
flowerBox(2.4, -10.5, 0);
// -------------------------------------------------------------------------
// String lights over the square
// -------------------------------------------------------------------------
const bulbMaterials = [];
function makeStringLight(from, to, count) {
const points = [];
for (let i = 0; i <= count; i++) {
const t = i / count;
const point = new THREE.Vector3().lerpVectors(from, to, t);
point.y -= Math.sin(t * Math.PI) * 0.85;
points.push(point);
}
const geometryLine = new THREE.BufferGeometry().setFromPoints(points);
const line = new THREE.Line(
geometryLine,
new THREE.LineBasicMaterial({ color: 0x55483d })
);
scene.add(line);
for (let i = 1; i < count; i++) {
const t = i / count;
const point = new THREE.Vector3().lerpVectors(from, to, t);
point.y -= Math.sin(t * Math.PI) * 0.85 - 0.25;
const colors = [0xf4b942, 0xe96545, 0x58a8a0, 0x5f83a4];
const glow = new THREE.MeshStandardMaterial({
color: colors[i % colors.length],
emissive: colors[i % colors.length],
emissiveIntensity: 1.3,
roughness: 0.7
});
bulbMaterials.push(glow);
box(0.18, 0.25, 0.18, point.x, point.y, point.z, glow, scene, false);
}
}
box(0.18, 4.8, 0.18, -13, 2.4, -12.0, 0x4b5351);
box(0.18, 4.8, 0.18, 13, 2.4, -12.0, 0x4b5351);
box(0.18, 4.8, 0.18, -13, 2.4, 11.6, 0x4b5351);
box(0.18, 4.8, 0.18, 13, 2.4, 11.6, 0x4b5351);
makeStringLight(
new THREE.Vector3(-13, 4.65, -12),
new THREE.Vector3(13, 4.65, -12),
18
);
makeStringLight(
new THREE.Vector3(-13, 4.65, 11.6),
new THREE.Vector3(13, 4.65, 11.6),
18
);
// Laundry between neighboring balconies.
const laundryLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-11.8, 5.5, -12.9),
new THREE.Vector3(3.8, 5.25, -12.9)
]),
new THREE.LineBasicMaterial({ color: 0x5b5148 })
);
scene.add(laundryLine);
const laundryColors = [0xf1d36c, 0xe96a55, 0x5f9e9a, 0xf3ead3, 0x6f5b89];
for (let i = 0; i < 5; i++) {
box(
0.52,
0.78,
0.08,
-10.6 + i * 2.9,
5.12,
-12.87,
laundryColors[i],
scene
);
}
// -------------------------------------------------------------------------
// Market stalls
// -------------------------------------------------------------------------
function makeMarketStall(x, z, rotation, canopyColor) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
scene.add(group);
for (const px of [-1.35, 1.35]) {
for (const pz of [-0.95, 0.95]) {
box(0.13, 2.5, 0.13, px, 1.25, pz, 0x6f4b37, group);
}
}
box(3.1, 0.22, 2.3, 0, 2.58, 0, canopyColor, group);
box(2.65, 0.20, 2.05, 0, 2.76, 0, 0xf4e5c3, group);
box(2.05, 0.20, 1.75, 0, 2.94, 0, canopyColor, group);
box(3.35, 0.16, 0.38, 0, 2.48, 0.9, 0xf4e5c3, group);
box(2.8, 0.65, 1.15, 0, 0.52, 0.35, 0x9d7046, group);
box(2.95, 0.15, 1.25, 0, 0.89, 0.35, 0xc3955d, group);
const fruitColors = [0xe65f3f, 0xf2b632, 0x699b45, 0xc74d45];
for (let i = 0; i < 12; i++) {
box(
0.23,
0.23,
0.23,
-1.05 + (i % 6) * 0.42,
1.08,
0.05 + Math.floor(i / 6) * 0.55,
fruitColors[i % fruitColors.length],
group
);
}
}
makeMarketStall(-8.3, 6.5, 0.15, 0xe56548);
makeMarketStall(7.1, -6.5, -0.25, 0x3f8d88);
// -------------------------------------------------------------------------
// Neighbors: animated voxel people
// -------------------------------------------------------------------------
const people = [];
function makePerson(x, z, shirtColor, skinColor, rotation, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.27, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
scene.add(group);
const legLeft = box(0.17, 0.57, 0.20, -0.13, 0.31, 0, 0x354b52, group);
const legRight = box(0.17, 0.57, 0.20, 0.13, 0.31, 0, 0x354b52, group);
box(0.24, 0.13, 0.34, -0.13, 0.08, 0.05, 0x29383a, group);
box(0.24, 0.13, 0.34, 0.13, 0.08, 0.05, 0x29383a, group);
box(0.52, 0.68, 0.34, 0, 0.93, 0, shirtColor, group);
box(0.14, 0.58, 0.18, -0.34, 0.94, 0, shirtColor, group);
box(0.14, 0.58, 0.18, 0.34, 0.94, 0, shirtColor, group);
box(0.39, 0.39, 0.37, 0, 1.48, 0, skinColor, group);
box(0.42, 0.13, 0.39, 0, 1.67, -0.02, 0x3d302a, group);
box(0.08, 0.09, 0.03, -0.09, 1.49, 0.195, 0x2b3435, group);
box(0.08, 0.09, 0.03, 0.09, 1.49, 0.195, 0x2b3435, group);
if (random() > 0.5) {
box(0.54, 0.11, 0.48, 0, 1.76, 0, random() > 0.5 ? 0xe6b74e : 0xe36f51, group);
}
people.push({
group,
legLeft,
legRight,
phase: random() * Math.PI * 2,
baseY: 0.27
});
}
makePerson(-2.8, 2.4, 0xe65e45, 0x9a6247, 0.3, 1.02);
makePerson(-1.8, 3.0, 0x3f8e89, 0xc88761, -0.6, 0.92);
makePerson(4.4, -1.3, 0xe4b43d, 0x744837, 1.1, 1.07);
makePerson(5.1, -2.0, 0x6c5b8f, 0xb87754, -1.4, 0.95);
makePerson(-8.6, -5.7, 0x4e7e9d, 0x8b573d, 0.7, 1.0);
makePerson(-7.8, -6.3, 0xe7784f, 0xd59a72, 2.2, 0.9);
makePerson(8.8, 3.9, 0x5b9b70, 0x7e4d37, -0.4, 1.03);
makePerson(9.7, 4.5, 0xe6c05a, 0xc7865c, -1.2, 0.92);
makePerson(-10.7, 7.2, 0xb96076, 0x9f6749, 0.6, 0.98);
makePerson(1.5, 8.7, 0x4f8c8b, 0x744a36, 1.8, 1.04);
makePerson(2.3, 8.3, 0xe6a840, 0xca8962, -1.7, 0.91);
makePerson(10.7, -7.2, 0x537c9b, 0x82523d, 0.2, 1.0);
// -------------------------------------------------------------------------
// Small neighborhood animals and details
// -------------------------------------------------------------------------
function makeCat(x, z, color = 0x5a4740) {
const group = new THREE.Group();
group.position.set(x, 0.33, z);
group.rotation.y = 0.6;
scene.add(group);
box(0.68, 0.31, 0.37, 0, 0.17, 0, color, group);
box(0.38, 0.36, 0.35, 0.38, 0.31, 0, color, group);
box(0.12, 0.18, 0.10, 0.31, 0.56, 0, color, group);
box(0.12, 0.18, 0.10, 0.48, 0.56, 0, color, group);
box(0.07, 0.07, 0.04, 0.29, 0.34, 0.19, 0xe9b84d, group);
box(0.07, 0.07, 0.04, 0.48, 0.34, 0.19, 0xe9b84d, group);
box(0.12, 0.35, 0.12, -0.36, 0.14, 0, color, group);
box(0.12, 0.12, 0.28, 0.03, 0.18, -0.29, color, group);
box(0.12, 0.12, 0.25, 0.03, 0.38, -0.46, color, group);
}
makeCat(3.2, 10.1, 0x5c4940);
makeCat(-10.8, -5.2, 0xd8b276);
// A few distant birds.
const birds = [];
[
[-17, 13, -22],
[-12, 15, -25],
[18, 14, -21]
].forEach((position, index) => {
const bird = new THREE.Group();
bird.position.set(...position);
scene.add(bird);
box(0.65, 0.18, 0.22, 0, 0, 0, 0x31454b, bird, false);
const leftWing = box(0.55, 0.10, 0.30, -0.42, 0, 0, 0x31454b, bird, false);
const rightWing = box(0.55, 0.10, 0.30, 0.42, 0, 0, 0x31454b, bird, false);
birds.push({ leftWing, rightWing, phase: index });
});
// -------------------------------------------------------------------------
// Background skyline and voxel clouds
// -------------------------------------------------------------------------
const skylineColors = [0xb66c58, 0xd6a44f, 0x719687, 0x6d8194];
for (let i = 0; i < 7; i++) {
const height = 3.5 + random() * 3.2;
box(
4.2,
height,
4.5,
-20 + i * 6.6,
height / 2,
-23.5,
skylineColors[i % skylineColors.length]
);
}
const clouds = [];
function makeCloud(x, y, z, scale) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
scene.add(group);
const cloudMaterial = new THREE.MeshStandardMaterial({
color: 0xfff5dc,
roughness: 1
});
box(3.2, 1.2, 1.7, 0, 0, 0, cloudMaterial, group, false);
box(2.2, 1.7, 1.8, -1.4, -0.1, 0, cloudMaterial, group, false);
box(2.4, 1.8, 1.8, 1.3, -0.15, 0, cloudMaterial, group, false);
box(2.7, 1.1, 1.6, 0.1, 0.65, 0, cloudMaterial, group, false);
clouds.push(group);
}
makeCloud(-24, 18, -27, 1.15);
makeCloud(18, 20, -31, 1.45);
makeCloud(31, 16, -9, 0.85);
// -------------------------------------------------------------------------
// Direct camera controls — no addons
// -------------------------------------------------------------------------
const controls = {
target: new THREE.Vector3(0, 2.0, -0.5),
yaw: 0.68,
pitch: 0.58,
zoom: 1.08
};
function updateCamera() {
const radius = 55;
const horizontal = Math.cos(controls.pitch) * radius;
camera.position.set(
controls.target.x + Math.sin(controls.yaw) * horizontal,
controls.target.y + Math.sin(controls.pitch) * radius,
controls.target.z + Math.cos(controls.yaw) * horizontal
);
camera.lookAt(controls.target);
camera.zoom = controls.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const halfHeight = Math.max(19, 27 / aspect);
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
resize();
updateCamera();
let dragging = false;
let panning = false;
let lastX = 0;
let lastY = 0;
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
panning = event.button === 2 || event.shiftKey;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
if (panning) {
const scale = (camera.top - camera.bottom) / camera.zoom / window.innerHeight;
const right = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 0);
const forward = controls.target.clone().sub(camera.position);
forward.y = 0;
forward.normalize();
controls.target.addScaledVector(right, -dx * scale);
controls.target.addScaledVector(forward, dy * scale);
} else {
controls.yaw -= dx * 0.006;
controls.pitch = THREE.MathUtils.clamp(
controls.pitch + dy * 0.0045,
0.22,
1.18
);
}
updateCamera();
});
function endDrag(event) {
dragging = false;
panning = false;
if (event.pointerId !== undefined && 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();
controls.zoom = THREE.MathUtils.clamp(
controls.zoom * Math.exp(-event.deltaY * 0.001),
0.62,
2.65
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
function resetCamera() {
controls.target.set(0, 2.0, -0.5);
controls.yaw = 0.68;
controls.pitch = 0.58;
controls.zoom = 1.08;
updateCamera();
}
document.getElementById("reset").addEventListener("click", resetCamera);
window.addEventListener("keydown", (event) => {
const step = 0.45;
if (event.key === "ArrowLeft") controls.yaw += 0.12;
else if (event.key === "ArrowRight") controls.yaw -= 0.12;
else if (event.key === "ArrowUp") controls.pitch = Math.min(1.18, controls.pitch + 0.06);
else if (event.key === "ArrowDown") controls.pitch = Math.max(0.22, controls.pitch - 0.06);
else if (event.key === "+" || event.key === "=") controls.zoom = Math.min(2.65, controls.zoom + 0.08);
else if (event.key === "-" || event.key === "_") controls.zoom = Math.max(0.62, controls.zoom - 0.08);
else if (event.key.toLowerCase() === "r") resetCamera();
else return;
event.preventDefault();
updateCamera();
});
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
// Gentle pedestrian movement.
people.forEach((person, index) => {
const wave = Math.sin(time * 2.2 + person.phase);
person.group.position.y = person.baseY + Math.abs(wave) * 0.025;
person.legLeft.rotation.x = wave * 0.28;
person.legRight.rotation.x = -wave * 0.28;
person.group.rotation.z = Math.sin(time * 1.2 + index) * 0.008;
});
// Fountain droplets.
waterDrops.forEach((drop) => {
const cycle = (time * 0.9 + drop.phase) % 1;
drop.mesh.position.y = 3.0 - cycle * 1.75;
drop.mesh.position.x =
Math.cos(drop.angle) * (1.12 + cycle * 0.42);
drop.mesh.position.z =
Math.sin(drop.angle) * (1.12 + cycle * 0.42);
drop.mesh.scale.y = 0.75 + Math.sin(cycle * Math.PI) * 0.7;
});
// Warm bulbs gently pulse.
bulbMaterials.forEach((material, index) => {
material.emissiveIntensity =
1.05 + Math.sin(time * 2.4 + index * 0.37) * 0.28;
});
// Birds flap.
birds.forEach((bird) => {
const flap = Math.sin(time * 7 + bird.phase) * 0.45;
bird.leftWing.rotation.z = flap;
bird.rightWing.rotation.z = -flap;
});
// Almost imperceptible cloud drift.
clouds.forEach((cloud, index) => {
cloud.position.x += Math.sin(time * 0.08 + index) * 0.0025;
});
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```