Prompt specification
Build or customize the Three.js 3D scene "Resident carrying groceries between hillside levels" 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: Resident carrying groceries between hillside levels
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/resident-carrying-groceries-between-hillside-levels-x2750
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring Comuna 13's hillside connections in Medellín. Create a compact Medellín hillside vignette with an original resident, stair, escalator, and home entrance. Keep the journey connected and avoid reducing the area to stereotypes. Voxel style.
Working Three.js Starter (resident-carrying-groceries-between-hillside-levels-x2750):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Entre calles — Comuna 13, Medellín</title>
<style>
:root {
--ink: #173d3b;
--muted: #58716c;
--paper: rgba(255, 252, 244, 0.92);
--line: rgba(23, 61, 59, 0.14);
--accent: #e56f4f;
--accent-soft: #f7d8c8;
--shadow: 0 16px 44px rgba(27, 55, 50, 0.16);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce8e1;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#app,
#app canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
}
#app canvas {
display: block;
touch-action: none;
cursor: grab;
outline: none;
}
#app canvas:active {
cursor: grabbing;
}
.wash {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
background:
linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 25%),
linear-gradient(0deg, rgba(35, 70, 63, 0.08), transparent 28%);
}
.intro {
position: fixed;
z-index: 5;
top: 26px;
left: 28px;
width: min(390px, calc(100vw - 56px));
pointer-events: none;
text-shadow: 0 1px 14px rgba(255, 255, 255, 0.7);
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
color: var(--muted);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.eyebrow::before {
width: 8px;
height: 8px;
content: "";
border-radius: 2px;
background: var(--accent);
box-shadow: 0 0 0 4px rgba(229, 111, 79, 0.13);
}
h1 {
margin: 0;
font-size: clamp(36px, 5vw, 58px);
font-weight: 820;
line-height: 0.94;
letter-spacing: -0.055em;
}
.intro p {
max-width: 355px;
margin: 16px 0 0;
color: #3f625c;
font-size: 14px;
line-height: 1.58;
}
.scene-note {
display: inline-flex;
margin-top: 15px;
padding: 7px 10px;
border: 1px solid rgba(255, 255, 255, 0.68);
border-radius: 8px;
background: rgba(255, 255, 255, 0.48);
color: #4d6e67;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
backdrop-filter: blur(8px);
}
.resident {
position: fixed;
z-index: 5;
bottom: 27px;
left: 28px;
display: flex;
align-items: center;
gap: 13px;
width: 294px;
padding: 13px 15px 13px 13px;
border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 15px;
background: var(--paper);
box-shadow: var(--shadow);
pointer-events: none;
backdrop-filter: blur(12px);
}
.avatar {
position: relative;
flex: 0 0 auto;
width: 47px;
height: 47px;
overflow: hidden;
border-radius: 12px;
background: #b7d8c4;
box-shadow: inset 0 -13px 0 #7caf93;
}
.avatar::before {
position: absolute;
top: 9px;
left: 14px;
width: 20px;
height: 20px;
content: "";
border-radius: 4px;
background: #9a654a;
box-shadow: -2px -5px 0 1px #293f39;
}
.avatar::after {
position: absolute;
bottom: -8px;
left: 9px;
width: 30px;
height: 30px;
content: "";
border-radius: 5px;
background: var(--accent);
}
.resident-label {
margin: 0 0 3px;
color: var(--accent);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.resident h2 {
margin: 0;
font-size: 19px;
letter-spacing: -0.03em;
}
.resident p {
margin: 3px 0 0;
color: var(--muted);
font-size: 11px;
line-height: 1.35;
}
.journey {
position: fixed;
z-index: 6;
right: 28px;
bottom: 27px;
width: 342px;
padding: 16px;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 18px;
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(14px);
}
.journey-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.journey-head strong {
color: var(--muted);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
#reset {
padding: 5px 8px;
border: 1px solid var(--line);
border-radius: 7px;
background: transparent;
color: var(--muted);
cursor: pointer;
font-size: 10px;
font-weight: 700;
}
#reset:hover {
border-color: var(--accent);
color: var(--accent);
}
.steps {
display: grid;
gap: 6px;
}
.step {
display: grid;
grid-template-columns: 31px 1fr;
align-items: center;
gap: 9px;
width: 100%;
padding: 7px 9px;
border: 1px solid transparent;
border-radius: 10px;
background: transparent;
color: var(--ink);
text-align: left;
cursor: pointer;
transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}
.step:hover {
background: rgba(255, 255, 255, 0.64);
transform: translateX(-2px);
}
.step.active {
border-color: rgba(229, 111, 79, 0.26);
background: #fff8f2;
}
.step-number {
display: grid;
width: 29px;
height: 29px;
place-items: center;
border-radius: 8px;
background: #e7eee7;
color: #637b75;
font-size: 10px;
font-weight: 850;
}
.step.active .step-number {
background: var(--accent);
color: white;
}
.step b,
.step small {
display: block;
}
.step b {
font-size: 12px;
line-height: 1.1;
}
.step small {
margin-top: 2px;
color: var(--muted);
font-size: 10px;
}
#stop-copy {
min-height: 48px;
margin: 12px 2px 0;
padding-top: 11px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 11px;
line-height: 1.48;
}
.controls {
position: fixed;
z-index: 5;
bottom: 30px;
left: 50%;
padding: 8px 12px;
border-radius: 999px;
background: rgba(255, 255, 255, 0.62);
color: #56736c;
font-size: 10px;
font-weight: 650;
pointer-events: none;
transform: translateX(-50%);
backdrop-filter: blur(8px);
}
#pins {
position: fixed;
inset: 0;
z-index: 4;
pointer-events: none;
}
.pin {
position: absolute;
display: flex;
align-items: center;
gap: 7px;
padding: 0;
border: 0;
background: transparent;
color: var(--ink);
pointer-events: auto;
cursor: pointer;
transform: translate(-50%, calc(-100% - 10px));
}
.pin-number {
display: grid;
width: 29px;
height: 29px;
flex: 0 0 auto;
place-items: center;
border: 3px solid rgba(255, 255, 255, 0.95);
border-radius: 9px;
background: var(--ink);
color: white;
box-shadow: 0 5px 16px rgba(23, 61, 59, 0.24);
font-size: 10px;
font-weight: 850;
transition: transform 160ms ease, background 160ms ease;
}
.pin:hover .pin-number,
.pin.selected .pin-number {
background: var(--accent);
transform: translateY(-3px);
}
.pin-label {
padding: 6px 9px;
border: 1px solid rgba(255, 255, 255, 0.74);
border-radius: 8px;
background: rgba(255, 252, 244, 0.9);
box-shadow: 0 5px 16px rgba(23, 61, 59, 0.12);
font-size: 10px;
font-weight: 750;
opacity: 0;
transform: translateX(-5px);
transition: opacity 150ms ease, transform 150ms ease;
white-space: nowrap;
}
.pin:hover .pin-label,
.pin.selected .pin-label {
opacity: 1;
transform: translateX(0);
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #dce8e1;
color: var(--muted);
font-size: 12px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.done {
opacity: 0;
pointer-events: none;
}
@media (max-width: 850px) {
.intro {
top: 16px;
left: 16px;
width: calc(100vw - 32px);
}
.intro p {
max-width: 320px;
font-size: 12px;
}
.scene-note {
display: none;
}
.resident,
.controls {
display: none;
}
.journey {
right: 12px;
bottom: 12px;
left: 12px;
width: auto;
padding: 12px;
}
.steps {
grid-template-columns: repeat(4, 1fr);
}
.step {
grid-template-columns: 1fr;
justify-items: center;
gap: 5px;
padding: 6px 3px;
text-align: center;
}
.step small {
display: none;
}
.step b {
font-size: 9px;
}
#stop-copy {
min-height: 38px;
margin-top: 8px;
padding-top: 8px;
font-size: 10px;
}
.pin-label {
display: none;
}
}
@media (max-height: 680px) and (min-width: 851px) {
.resident {
display: none;
}
.intro p {
margin-top: 10px;
}
}
</style>
</head>
<body>
<div id="app"></div>
<div class="wash"></div>
<header class="intro">
<div class="eyebrow">Medellín, Colombia · Comuna 13</div>
<h1>Entre calles</h1>
<p>
A compact hillside neighborhood connected through everyday movement:
the lower street, a walkable stair, an escalator, and Alma's front door.
</p>
<div class="scene-note">Original voxel vignette · not a literal map</div>
</header>
<aside class="resident" aria-label="Resident character">
<div class="avatar" aria-hidden="true"></div>
<div>
<p class="resident-label">Original resident</p>
<h2>Alma</h2>
<p>Fictional ceramic artist and neighbor in the upper house.</p>
</div>
</aside>
<aside class="journey" aria-label="Connected route">
<div class="journey-head">
<strong>The connected route</strong>
<button id="reset" type="button">Reset view</button>
</div>
<nav class="steps">
<button class="step active" data-stop="0" type="button">
<span class="step-number">01</span>
<span><b>Calle baja</b><small>Lower street</small></span>
</button>
<button class="step" data-stop="1" type="button">
<span class="step-number">02</span>
<span><b>Escalinata</b><small>Walkable stair</small></span>
</button>
<button class="step" data-stop="2" type="button">
<span class="step-number">03</span>
<span><b>Escalera eléctrica</b><small>Inclined escalator</small></span>
</button>
<button class="step" data-stop="3" type="button">
<span class="step-number">04</span>
<span><b>Casa de Alma</b><small>Home entrance</small></span>
</button>
</nav>
<p id="stop-copy" aria-live="polite">
The route begins on the lower street, where the first homes and the foot
of the hillside stair meet.
</p>
</aside>
<div class="controls">Drag to orbit · Scroll to zoom · Keys 1–4 to travel</div>
<div id="pins" aria-label="Scene locations"></div>
<div id="loading">Building the hillside…</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 direct orbit controls
// ---------------------------------------------------------------------
const app = document.querySelector("#app");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel scene of connections through Comuna 13"
);
app.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce8e1);
scene.fog = new THREE.Fog(0xdce8e1, 34, 62);
const camera = new THREE.PerspectiveCamera(
39,
window.innerWidth / window.innerHeight,
0.1,
100
);
const overview = {
theta: 0.68,
phi: 1.01,
radius: 30,
target: new THREE.Vector3(0, 2.1, 0)
};
const desired = {
theta: overview.theta,
phi: overview.phi,
radius: overview.radius,
target: overview.target.clone()
};
const current = {
theta: overview.theta,
phi: overview.phi,
radius: overview.radius,
target: overview.target.clone()
};
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
desired.theta -= dx * 0.006;
desired.phi = THREE.MathUtils.clamp(
desired.phi - dy * 0.005,
0.55,
1.36
);
pointerX = event.clientX;
pointerY = event.clientY;
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
desired.radius = THREE.MathUtils.clamp(
desired.radius * Math.exp(event.deltaY * 0.001),
9,
43
);
},
{ passive: false }
);
// ---------------------------------------------------------------------
// Lighting
// ---------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xf7fbf4, 0x8f765c, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff0d2, 3.25);
sun.position.set(-12, 19, 12);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x8db9c0, 0.7);
fill.position.set(13, 9, -14);
scene.add(fill);
// ---------------------------------------------------------------------
// Geometry helpers
// ---------------------------------------------------------------------
const materials = new Map();
function material(color) {
if (color && color.isMaterial) return color;
if (!materials.has(color)) {
materials.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0,
flatShading: true
})
);
}
return materials.get(color);
}
function cube(
parent,
width,
height,
depth,
x,
y,
z,
color,
castShadow = true,
receiveShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material(color)
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = receiveShadow;
parent.add(mesh);
return mesh;
}
function beam(parent, a, b, thickness, color) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const mesh = cube(
parent,
thickness,
length,
thickness,
0,
0,
0,
color
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return mesh;
}
function tiledPath(a, b, count, width, color, height = 0.1) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = Math.hypot(direction.x, direction.z);
const angle = -Math.atan2(direction.z, direction.x);
const tileLength = length / count;
for (let i = 0; i < count; i++) {
const t = (i + 0.5) / count;
const point = start.clone().lerp(end, t);
const tile = cube(
scene,
tileLength * 0.82,
height,
width,
point.x,
point.y,
point.z,
color,
false,
true
);
tile.rotation.y = angle;
}
}
function addHouse({
x,
y,
z,
width,
height,
depth,
body,
accent = 0xf1dfc1,
doorX = 0,
awning = false
}) {
const group = new THREE.Group();
group.position.set(x, y, z);
scene.add(group);
cube(group, width, height, depth, 0, height / 2, 0, body);
cube(
group,
width + 0.18,
0.2,
depth + 0.18,
0,
height + 0.1,
0,
0x59655e
);
cube(
group,
width + 0.25,
0.16,
depth + 0.25,
0,
height + 0.25,
0,
accent
);
// Front trim.
cube(
group,
0.13,
height,
0.1,
-width / 2 + 0.18,
height / 2,
depth / 2 + 0.04,
accent
);
// Door and frame.
cube(
group,
0.93,
1.78,
0.1,
doorX,
0.89,
depth / 2 + 0.07,
0xf2dfc2
);
cube(
group,
0.72,
1.57,
0.11,
doorX,
0.785,
depth / 2 + 0.13,
0x304a49
);
cube(
group,
0.055,
0.055,
0.045,
doorX + 0.22,
0.78,
depth / 2 + 0.2,
0xe8b85c
);
// Window frames and panes.
const windowPositions = width > 3 ? [-width * 0.28] : [-width * 0.25, width * 0.25];
windowPositions.forEach((windowX, index) => {
if (index === 1 && Math.abs(windowX - doorX) < 0.8) return;
cube(
group,
0.86,
0.84,
0.11,
windowX,
height * 0.59,
depth / 2 + 0.08,
0xf4e6cc
);
cube(
group,
0.67,
0.65,
0.13,
windowX,
height * 0.59,
depth / 2 + 0.15,
index === 0 && height > 3 ? 0xf4c66a : 0x456c73
);
cube(
group,
0.045,
0.67,
0.04,
windowX,
height * 0.59,
depth / 2 + 0.225,
0xe6d4b5
);
});
// Small upper sill.
cube(
group,
width * 0.23,
0.12,
0.3,
-width * 0.25,
height * 0.59 - 0.49,
depth / 2 + 0.18,
accent
);
if (awning) {
cube(
group,
1.55,
0.13,
0.86,
doorX,
1.95,
depth / 2 + 0.43,
0x4f8c83
);
cube(
group,
0.1,
1.65,
0.1,
doorX - 0.68,
0.85,
depth / 2 + 0.72,
0x4f8c83
);
cube(
group,
0.1,
1.65,
0.1,
doorX + 0.68,
0.85,
depth / 2 + 0.72,
0x4f8c83
);
}
return group;
}
function addTree(x, y, z, scale = 1) {
const tree = new THREE.Group();
tree.position.set(x, y, z);
tree.scale.setScalar(scale);
scene.add(tree);
cube(tree, 0.3, 1.7, 0.3, 0, 0.85, 0, 0x795942);
cube(tree, 1.35, 1.05, 1.25, 0, 2.02, 0, 0x6f9b67);
cube(tree, 0.92, 0.82, 0.92, 0.5, 2.48, -0.12, 0x82aa70);
cube(tree, 0.86, 0.74, 0.86, -0.48, 2.38, 0.18, 0x769f65);
cube(tree, 0.72, 0.65, 0.72, 0.08, 3.02, 0.1, 0x93b77b);
}
function addRoofTank(x, y, z) {
const group = new THREE.Group();
group.position.set(x, y, z);
scene.add(group);
cube(group, 0.12, 0.55, 0.12, -0.4, 0.27, -0.25, 0x5f6963);
cube(group, 0.12, 0.55, 0.12, 0.4, 0.27, -0.25, 0x5f6963);
cube(group, 0.12, 0.55, 0.12, -0.4, 0.27, 0.25, 0x5f6963);
cube(group, 0.12, 0.55, 0.12, 0.4, 0.27, 0.25, 0x5f6963);
cube(group, 0.95, 0.62, 0.78, 0, 0.85, 0, 0xc5d1c8);
cube(group, 1.02, 0.1, 0.85, 0, 1.2, 0, 0x6c7b74);
}
// ---------------------------------------------------------------------
// Terraced hillside
// ---------------------------------------------------------------------
const colors = {
earth: 0xb78b67,
earthLight: 0xc59b76,
grass: 0x8eb577,
grassLight: 0xa2c485,
paving: 0xe4d0aa,
pavingCool: 0xc8d1bd,
road: 0x5e6d68,
curb: 0xd9d1b9,
coral: 0xe7795c,
teal: 0x579a91,
yellow: 0xedc357,
blue: 0x648fc0,
lilac: 0xa486b5,
roof: 0x5e675f,
glass: 0x416a70
};
// Studio floor.
cube(scene, 100, 0.12, 100, 0, -1.29, 0, 0xdce8e1, false, true);
// Main plinth and lower grass.
cube(scene, 22, 1.2, 18, 0, -0.6, 0.5, colors.earth);
cube(scene, 22, 0.18, 18, 0, 0.09, 0.5, colors.grass, false, true);
// Middle terrace.
cube(scene, 5, 1.6, 6, -0.5, 0.98, 1, colors.earthLight);
cube(scene, 5, 0.12, 6, -0.5, 1.72, 1, colors.grassLight, false, true);
// Upper terrace.
cube(scene, 8, 3.4, 7, 6, 1.88, -3.5, colors.earth);
cube(scene, 8, 0.12, 7, 6, 3.52, -3.5, colors.grassLight, false, true);
// Retaining-wall brick pattern.
const brickColors = [0xbd8b65, 0xc5966f, 0xb9805d, 0xcda078];
for (let row = 0; row < 4; row++) {
for (let col = 0; col < 8; col++) {
cube(
scene,
0.51,
0.28,
0.09,
-2.65 + col * 0.61,
0.47 + row * 0.36,
4.04,
brickColors[(row + col) % brickColors.length],
false
);
}
}
for (let row = 0; row < 8; row++) {
for (let col = 0; col < 12; col++) {
cube(
scene,
0.51,
0.3,
0.09,
2.3 + col * 0.61,
0.47 + row * 0.39,
0.04,
brickColors[(row * 2 + col) % brickColors.length],
false
);
}
}
// Lower street.
cube(scene, 20, 0.07, 2.25, 0, 0.215, 7.25, colors.road, false, true);
cube(scene, 20, 0.12, 0.78, 0, 0.22, 5.78, colors.curb, false, true);
// Street center marks, all rectangular.
for (let x = -8.5; x <= 8.5; x += 2.1) {
cube(scene, 0.9, 0.025, 0.1, x, 0.263, 7.25, 0xe9d9aa, false, false);
}
// ---------------------------------------------------------------------
// Connected route: lower street → stair → escalator → home
// ---------------------------------------------------------------------
tiledPath(
[-10, 0.31, 6.15],
[-7.1, 0.31, 6.15],
6,
1.15,
colors.paving
);
tiledPath(
[-7.1, 0.31, 6.15],
[-7.1, 0.31, 2.5],
7,
1.15,
colors.paving
);
// Stair: ten real voxel steps.
const stairStartX = -7;
const stairZ = 2.5;
const stairTread = 0.4;
const stairRise = 0.16;
for (let i = 0; i < 10; i++) {
const top = 0.18 + (i + 1) * stairRise;
const bottom = 0.18;
const x = stairStartX + (i + 0.5) * stairTread;
cube(
scene,
stairTread,
top - bottom,
1.45,
x,
(top + bottom) / 2,
stairZ,
i % 2 ? 0xd9c5a1 : 0xe5d2ad
);
cube(
scene,
stairTread * 0.94,
0.045,
0.08,
x,
top + 0.025,
stairZ + 0.7,
0xe9b650,
false,
false
);
}
// Stair handrails.
for (const side of [-1, 1]) {
const railZ = stairZ + side * 0.79;
beam(
scene,
[stairStartX, 1.24, railZ],
[-3, 2.68, railZ],
0.09,
0x3f716e
);
for (let i = 0; i <= 5; i++) {
const t = i / 5;
const x = THREE.MathUtils.lerp(stairStartX, -3, t);
const y = THREE.MathUtils.lerp(0.35, 1.95, t);
cube(
scene,
0.075,
0.88,
0.075,
x,
y,
railZ,
0x3f716e
);
}
}
// Landing connects the stair and escalator.
tiledPath(
[-3, 1.86, 2.5],
[-3, 1.86, 1],
4,
1.35,
colors.paving
);
cube(scene, 1, 0.1, 1.5, -2.85, 1.83, 2.5, colors.paving);
// Inclined escalator.
const escalator = new THREE.Group();
escalator.position.set(-3, 1.78, 1);
escalator.rotation.y = -Math.atan2(-2, 5);
scene.add(escalator);
const escalatorLength = Math.hypot(5, 2);
const escalatorRise = 1.8;
const escalatorSlope = escalatorRise / escalatorLength;
const treadCount = 13;
const treadSpacing = escalatorLength / treadCount;
const movingTreads = [];
for (let i = 0; i < treadCount; i++) {
const x = (i + 0.5) * treadSpacing;
const tread = cube(
escalator,
treadSpacing * 0.88,
0.16,
1.16,
x,
escalatorSlope * x + 0.09,
0,
0x71858a
);
cube(
tread,
treadSpacing * 0.86,
0.035,
0.055,
0,
0.095,
0.49,
0xe5b653,
false,
false
);
movingTreads.push(tread);
}
for (const side of [-1, 1]) {
const z = side * 0.68;
beam(
escalator,
[0, 0.12, z],
[escalatorLength, escalatorRise + 0.12, z],
0.27,
0x4f7f87
);
beam(
escalator,
[0, 1.02, z],
[escalatorLength, escalatorRise + 1.02, z],
0.1,
0x263f43
);
for (let i = 0; i <= 6; i++) {
const x = (i / 6) * escalatorLength;
const y = escalatorSlope * x;
cube(
escalator,
0.075,
0.9,
0.075,
x,
y + 0.58,
z,
0x38585c
);
}
}
// Upper path to the home.
tiledPath(
[2, 3.66, -1],
[4.2, 3.66, -2],
5,
1.2,
colors.pavingCool
);
tiledPath(
[4.2, 3.66, -2],
[6.95, 3.66, -2.88],
6,
1.2,
colors.pavingCool
);
// ---------------------------------------------------------------------
// Homes, street details, and neighborhood greenery
// ---------------------------------------------------------------------
const lowerHome = addHouse({
x: -9,
y: 0.18,
z: 3.8,
width: 3.1,
height: 2.75,
depth: 2.6,
body: colors.yellow,
accent: 0xe7a96e
});
addHouse({
x: -6.3,
y: 0.18,
z: -3.4,
width: 3.3,
height: 2.65,
depth: 2.8,
body: 0xc8785f,
accent: 0xf0d6b0
});
addHouse({
x: -0.25,
y: 1.78,
z: 2.45,
width: 3.05,
height: 2.8,
depth: 2.65,
body: colors.blue,
accent: 0xf0d7ad,
doorX: -0.35
});
addHouse({
x: 8,
y: 0.18,
z: 4.15,
width: 3.2,
height: 2.9,
depth: 2.7,
body: colors.lilac,
accent: 0xead8b9
});
addHouse({
x: 2.92,
y: 3.58,
z: -5.25,
width: 2.15,
height: 2.55,
depth: 2.25,
body: colors.teal,
accent: 0xf0ddba
});
const almaHouse = addHouse({
x: 6.3,
y: 3.58,
z: -4.8,
width: 4.3,
height: 3.4,
depth: 3.5,
body: colors.coral,
accent: 0xf1d8b9,
doorX: 0.65,
awning: true
});
addHouse({
x: 9.16,
y: 3.58,
z: -4.9,
width: 1.55,
height: 2.8,
depth: 2.25,
body: colors.yellow,
accent: 0xe4bf7c
});
// Main doorstep and a warm square of light.
cube(almaHouse, 1.25, 0.14, 0.7, 0.65, 0.07, 2.0, 0xd7c4a3);
cube(almaHouse, 0.72, 0.08, 0.12, 0.65, 1.81, 1.84, 0xf3c76e, false, false);
const doorLight = new THREE.PointLight(0xffc978, 2.4, 5, 2);
doorLight.position.set(6.95, 5.55, -2.65);
scene.add(doorLight);
// Roof details.
addRoofTank(-9.25, 3.13, 3.55);
addRoofTank(8.1, 3.28, 4.15);
// Small balcony on Alma's house.
cube(almaHouse, 1.5, 0.13, 0.7, -1.05, 1.25, 1.98, 0xf0d6af);
cube(almaHouse, 1.5, 0.08, 0.08, -1.05, 1.77, 2.3, 0x496d69);
cube(almaHouse, 0.08, 0.55, 0.08, -1.77, 1.5, 2.3, 0x496d69);
cube(almaHouse, 0.08, 0.55, 0.08, -0.33, 1.5, 2.3, 0x496d69);
// Trees and shrubs.
addTree(-10.2, 0.18, -2.3, 0.95);
addTree(-5.2, 0.18, -5.4, 1.1);
addTree(-3.8, 0.18, 5.6, 0.8);
addTree(4.6, 0.18, 5.7, 1.05);
addTree(9.2, 0.18, -6.5, 0.92);
addTree(-1.7, 1.78, -1.25, 0.7);
addTree(9.65, 3.58, -1.55, 0.72);
// Small planted cubes.
function planter(x, y, z, color = 0xb9684f) {
cube(scene, 0.48, 0.42, 0.48, x, y + 0.21, z, color);
cube(scene, 0.32, 0.3, 0.32, x, y + 0.55, z, 0x6e9b68);
cube(scene, 0.2, 0.18, 0.2, x + 0.12, y + 0.75, z, 0x8caf70);
}
planter(5.25, 3.58, -2.65, 0xba6a4f);
planter(7.7, 3.58, -2.58, 0xc9865c);
planter(-2.0, 1.78, 3.65, 0x8f765d);
// Bench on the lower street.
cube(scene, 1.8, 0.14, 0.48, -3.5, 0.65, 5.55, 0x9c7050);
cube(scene, 1.8, 0.55, 0.12, -3.5, 0.98, 5.3, 0x9c7050);
cube(scene, 0.13, 0.52, 0.4, -4.2, 0.38, 5.55, 0x4f5b55);
cube(scene, 0.13, 0.52, 0.4, -2.8, 0.38, 5.55, 0x4f5b55);
// Compact voxel car.
const car = new THREE.Group();
car.position.set(3.8, 0.28, 7.25);
scene.add(car);
cube(car, 1.7, 0.42, 0.85, 0, 0.31, 0, 0xd87958);
cube(car, 0.88, 0.38, 0.73, -0.08, 0.68, 0, 0x486970);
cube(car, 0.72, 0.25, 0.76, -0.08, 0.69, 0, 0x9ec0be);
cube(car, 0.24, 0.24, 0.22, -0.55, 0.34, 0.45, 0x293a39);
cube(car, 0.24, 0.24, 0.22, -0.55, 0.34, -0.45, 0x293a39);
cube(car, 0.24, 0.24, 0.22, 0.58, 0.34, 0.45, 0x293a39);
cube(car, 0.24, 0.24, 0.22, 0.58, 0.34, -0.45, 0x293a39);
// ---------------------------------------------------------------------
// Alma: original resident character
// ---------------------------------------------------------------------
const alma = new THREE.Group();
alma.position.set(5.9, 3.67, -2.47);
alma.rotation.y = -0.1;
scene.add(alma);
cube(alma, 0.22, 0.47, 0.26, -0.16, 0.27, 0, 0x344d58);
cube(alma, 0.22, 0.47, 0.26, 0.16, 0.27, 0, 0x344d58);
cube(alma, 0.25, 0.12, 0.34, -0.16, 0.06, 0.04, 0x243637);
cube(alma, 0.25, 0.12, 0.34, 0.16, 0.06, 0.04, 0x243637);
cube(alma, 0.56, 0.65, 0.34, 0, 0.78, 0, 0xe5775d);
cube(alma, 0.6, 0.12, 0.37, 0, 0.6, 0, 0xf0bd62);
cube(alma, 0.37, 0.39, 0.37, 0, 1.28, 0, 0x9a654a);
cube(alma, 0.42, 0.13, 0.42, 0, 1.49, -0.01, 0x2f4038);
cube(alma, 0.09, 0.08, 0.08, 0, 1.27, 0.21, 0x8b523d);
cube(alma, 0.045, 0.045, 0.025, -0.09, 1.32, 0.195, 0x253c3a);
cube(alma, 0.045, 0.045, 0.025, 0.09, 1.32, 0.195, 0x253c3a);
// Left arm.
cube(alma, 0.17, 0.55, 0.2, -0.38, 0.75, 0, 0xe5775d);
cube(alma, 0.16, 0.15, 0.17, -0.38, 0.46, 0, 0x9a654a);
// Waving right arm.
const waveArm = new THREE.Group();
waveArm.position.set(0.39, 1.02, 0);
waveArm.rotation.z = 2.48;
alma.add(waveArm);
cube(waveArm, 0.17, 0.52, 0.2, 0, -0.23, 0, 0xe5775d);
cube(waveArm, 0.16, 0.15, 0.17, 0, -0.51, 0, 0x9a654a);
// A small tote, avoiding cultural shorthand.
cube(alma, 0.3, 0.33, 0.15, -0.43, 0.42, 0.08, 0xe7c86f);
cube(alma, 0.15, 0.08, 0.17, -0.43, 0.61, 0.08, 0xbc9454);
// ---------------------------------------------------------------------
// Route markers and interactive HTML pins
// ---------------------------------------------------------------------
const markers = [];
function addMarker(position, size = 0.78) {
const group = new THREE.Group();
group.position.copy(position);
scene.add(group);
const markerMaterial = new THREE.MeshBasicMaterial({
color: 0xffffff,
transparent: true,
opacity: 0.4,
depthWrite: false
});
cube(group, size + 0.12, 0.035, 0.075, 0, 0, size / 2, markerMaterial, false, false);
cube(group, size + 0.12, 0.035, 0.075, 0, 0, -size / 2, markerMaterial, false, false);
cube(group, 0.075, 0.035, size, size / 2, 0, 0, markerMaterial, false, false);
cube(group, 0.075, 0.035, size, -size / 2, 0, 0, markerMaterial, false, false);
group.userData.markerMaterial = markerMaterial;
markers.push(group);
return group;
}
addMarker(new THREE.Vector3(-9.7, 0.39, 6.15));
addMarker(new THREE.Vector3(-3.05, 1.94, 2.5));
addMarker(new THREE.Vector3(2.05, 3.75, -1));
addMarker(new THREE.Vector3(6.95, 3.75, -2.55));
const stops = [
{
title: "Calle baja",
pin: "Lower street",
world: new THREE.Vector3(-9.7, 0.8, 6.15),
camera: {
theta: 0.72,
phi: 1.08,
radius: 11.5,
target: new THREE.Vector3(-7.3, 0.8, 5.0)
},
copy:
"The route begins on the lower street, where the first homes and the foot of the hillside stair meet."
},
{
title: "Escalinata",
pin: "Walkable stair",
world: new THREE.Vector3(-5.1, 1.55, 2.5),
camera: {
theta: 0.78,
phi: 1.05,
radius: 9.2,
target: new THREE.Vector3(-5.0, 1.15, 2.3)
},
copy:
"A short run of voxel steps turns the slope into a walkable route and leads to a shared middle landing."
},
{
title: "Escalera eléctrica",
pin: "Inclined escalator",
world: new THREE.Vector3(-0.4, 2.9, 0.1),
camera: {
theta: 0.66,
phi: 1.08,
radius: 10.8,
target: new THREE.Vector3(-0.5, 2.45, 0.1)
},
copy:
"The inclined escalator carries the route across the steepest terrace, physically joining the middle landing to the upper path."
},
{
title: "Casa de Alma",
pin: "Home entrance",
world: new THREE.Vector3(6.95, 5.75, -2.7),
camera: {
theta: 0.58,
phi: 1.08,
radius: 10.2,
target: new THREE.Vector3(6.2, 4.7, -3.1)
},
copy:
"The final paved segment reaches Alma's lit doorway. A small terrace, household plants, and a waving neighbor complete the journey."
}
];
const pinContainer = document.querySelector("#pins");
const stepButtons = [...document.querySelectorAll(".step")];
const stopCopy = document.querySelector("#stop-copy");
const pinElements = [];
stops.forEach((stop, index) => {
const button = document.createElement("button");
button.className = "pin";
button.type = "button";
button.setAttribute("aria-label", `Visit ${stop.title}`);
button.innerHTML = `
<span class="pin-number">${String(index + 1).padStart(2, "0")}</span>
<span class="pin-label">${stop.pin}</span>
`;
button.addEventListener("click", () => selectStop(index, true));
pinContainer.appendChild(button);
pinElements.push(button);
});
let activeStop = 0;
function selectStop(index, moveCamera = true) {
activeStop = index;
const stop = stops[index];
stepButtons.forEach((button, buttonIndex) => {
button.classList.toggle("active", buttonIndex === index);
});
pinElements.forEach((button, buttonIndex) => {
button.classList.toggle("selected", buttonIndex === index);
});
markers.forEach((marker, markerIndex) => {
const selected = markerIndex === index;
marker.userData.markerMaterial.color.setHex(
selected ? 0xe56f4f : 0xffffff
);
marker.userData.markerMaterial.opacity = selected ? 0.95 : 0.3;
marker.scale.setScalar(selected ? 1.12 : 1);
});
stopCopy.textContent = stop.copy;
if (moveCamera) {
desired.theta = stop.camera.theta;
desired.phi = stop.camera.phi;
desired.radius = stop.camera.radius;
desired.target.copy(stop.camera.target);
}
}
stepButtons.forEach((button, index) => {
button.addEventListener("click", () => selectStop(index, true));
});
document.querySelector("#reset").addEventListener("click", () => {
desired.theta = overview.theta;
desired.phi = overview.phi;
desired.radius = overview.radius;
desired.target.copy(overview.target);
});
window.addEventListener("keydown", event => {
if (event.key >= "1" && event.key <= "4") {
selectStop(Number(event.key) - 1, true);
return;
}
if (event.key === "ArrowLeft") desired.theta -= 0.13;
if (event.key === "ArrowRight") desired.theta += 0.13;
if (event.key === "ArrowUp") desired.phi = Math.max(0.55, desired.phi - 0.08);
if (event.key === "ArrowDown") desired.phi = Math.min(1.36, desired.phi + 0.08);
if (event.key === "Home") {
desired.theta = overview.theta;
desired.phi = overview.phi;
desired.radius = overview.radius;
desired.target.copy(overview.target);
}
});
selectStop(0, false);
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
const cameraSpherical = new THREE.Spherical();
const projected = new THREE.Vector3();
function updateCamera() {
current.theta = THREE.MathUtils.lerp(current.theta, desired.theta, 0.085);
current.phi = THREE.MathUtils.lerp(current.phi, desired.phi, 0.085);
current.radius = THREE.MathUtils.lerp(current.radius, desired.radius, 0.085);
current.target.lerp(desired.target, 0.085);
cameraSpherical.set(current.radius, current.phi, current.theta);
camera.position.setFromSpherical(cameraSpherical).add(current.target);
camera.lookAt(current.target);
}
function updatePins() {
const width = window.innerWidth;
const height = window.innerHeight;
pinElements.forEach((button, index) => {
projected.copy(stops[index].world).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.15 &&
Math.abs(projected.y) < 1.15;
button.style.display = visible ? "flex" : "none";
if (visible) {
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
button.style.left = `${x}px`;
button.style.top = `${y}px`;
}
});
}
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
updateCamera();
// Escalator treads travel continuously up the incline.
const travel = (elapsed * 0.78) % escalatorLength;
movingTreads.forEach((tread, index) => {
let x = (index * treadSpacing + travel) % escalatorLength;
if (x < 0.12) x += escalatorLength;
tread.position.x = x;
tread.position.y = escalatorSlope * x + 0.09;
});
// Alma's quiet wave.
waveArm.rotation.z = 2.42 + Math.sin(elapsed * 2.8) * 0.16;
alma.position.y = 3.67 + Math.sin(elapsed * 1.8) * 0.012;
updatePins();
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
animate();
requestAnimationFrame(() => {
document.querySelector("#loading").classList.add("done");
});
</script>
</body>
</html>
```