Prompt specification
Build or customize the Three.js 3D scene "Laundry line above an Alfama pedestrian stair" 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: Laundry line above an Alfama pedestrian stair
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/laundry-line-above-an-alfama-pedestrian-stair-x2838
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows Alfama's stair lanes in Lisbon. Create a compact residential vignette with stairs, shuttered windows, and a laundry line overhead. Keep the public route clear and represent everyday household use respectfully. Voxel style.
Working Three.js Starter (laundry-line-above-an-alfama-pedestrian-stair-x2838):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#b9d1cb" />
<title>Alfama Stair Lane — A Voxel Neighborhood Vignette</title>
<style>
:root {
--ink: #173c3b;
--paper: rgba(248, 241, 220, 0.9);
--paper-strong: #f7efd8;
--accent: #bd693f;
--line: rgba(23, 60, 59, 0.18);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b9d1cb;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#scene {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 50% 45%, transparent 48%, rgba(28, 48, 43, 0.13) 120%),
linear-gradient(to bottom, rgba(255, 247, 220, 0.06), transparent 28%);
}
.intro {
position: fixed;
top: 24px;
left: 24px;
width: min(390px, calc(100vw - 48px));
padding: 20px 22px 18px;
border: 1px solid rgba(255, 255, 255, 0.58);
border-radius: 18px;
background: var(--paper);
box-shadow: 0 18px 50px rgba(42, 54, 45, 0.16);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
color: var(--accent);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 22px;
height: 2px;
background: currentColor;
content: "";
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 4vw, 43px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.intro p {
max-width: 330px;
margin: 13px 0 16px;
color: rgba(23, 60, 59, 0.75);
font-size: 13px;
line-height: 1.55;
}
.clear-route {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 7px 10px;
border: 1px solid rgba(189, 105, 63, 0.26);
border-radius: 999px;
background: rgba(189, 105, 63, 0.08);
color: #7d4933;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.02em;
}
.clear-route::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 4px rgba(189, 105, 63, 0.12);
content: "";
}
.controls {
position: fixed;
right: 24px;
bottom: 24px;
display: flex;
gap: 8px;
padding: 7px;
border: 1px solid rgba(255, 255, 255, 0.6);
border-radius: 14px;
background: var(--paper);
box-shadow: 0 14px 38px rgba(42, 54, 45, 0.16);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.controls button {
display: inline-flex;
align-items: center;
gap: 8px;
min-height: 40px;
padding: 0 13px;
border: 1px solid transparent;
border-radius: 9px;
background: transparent;
color: var(--ink);
font-size: 12px;
font-weight: 750;
cursor: pointer;
transition:
background 160ms ease,
color 160ms ease,
transform 160ms ease;
}
.controls button:hover {
background: rgba(23, 60, 59, 0.07);
}
.controls button:active {
transform: translateY(1px);
}
.controls button:focus-visible {
outline: 3px solid rgba(189, 105, 63, 0.28);
outline-offset: 2px;
}
.controls button.active {
background: var(--ink);
color: var(--paper-strong);
}
.button-icon {
font-size: 16px;
line-height: 1;
}
.hint {
position: fixed;
left: 24px;
bottom: 25px;
padding: 9px 12px;
border-radius: 10px;
background: rgba(248, 241, 220, 0.72);
color: rgba(23, 60, 59, 0.68);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.055em;
text-transform: uppercase;
pointer-events: none;
backdrop-filter: blur(8px);
}
#loading {
position: fixed;
inset: 0;
z-index: 10;
display: grid;
place-items: center;
background: #b9d1cb;
color: var(--ink);
transition: opacity 500ms ease;
}
#loading.done {
opacity: 0;
pointer-events: none;
}
.loading-mark {
display: grid;
gap: 12px;
justify-items: center;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.loading-stairs {
display: flex;
align-items: flex-end;
gap: 4px;
height: 30px;
}
.loading-stairs i {
display: block;
width: 12px;
background: var(--ink);
animation: rise 1.2s ease-in-out infinite alternate;
}
.loading-stairs i:nth-child(1) { height: 10px; animation-delay: -0.2s; }
.loading-stairs i:nth-child(2) { height: 18px; animation-delay: -0.4s; }
.loading-stairs i:nth-child(3) { height: 26px; animation-delay: -0.6s; }
.loading-stairs i:nth-child(4) { height: 16px; animation-delay: -0.8s; }
@keyframes rise {
to { transform: translateY(-5px); opacity: 0.55; }
}
@media (max-width: 700px) {
.intro {
top: 14px;
left: 14px;
width: min(350px, calc(100vw - 28px));
padding: 16px 18px;
}
.intro p {
margin: 10px 0 12px;
font-size: 12px;
}
.controls {
right: 14px;
bottom: 14px;
}
.controls button {
padding: 0 11px;
}
.controls .button-text {
display: none;
}
.hint {
left: 14px;
bottom: 72px;
max-width: calc(100vw - 28px);
}
}
</style>
</head>
<body>
<canvas
id="scene"
tabindex="0"
aria-label="Interactive voxel view of a residential stair lane in Alfama, Lisbon"
></canvas>
<div class="vignette"></div>
<header class="intro">
<div class="eyebrow">Lisboa · Alfama</div>
<h1>Between the<br />blue hours</h1>
<p>
A compact study of Lisbon’s everyday domestic landscape: stepped lanes,
painted shutters, window gardens, and a shared clothesline.
</p>
<div class="clear-route">Shared stairway · central route kept clear</div>
</header>
<nav class="controls" aria-label="Scene controls">
<button id="routeToggle" type="button" aria-pressed="false">
<span class="button-icon" aria-hidden="true">⌁</span>
<span class="button-text">Show public route</span>
</button>
<button id="resetView" type="button">
<span class="button-icon" aria-hidden="true">↺</span>
<span class="button-text">Reset view</span>
</button>
</nav>
<div class="hint">Drag to orbit · Scroll to zoom · Shift-drag to pan</div>
<div id="loading" aria-live="polite">
<div class="loading-mark">
<div class="loading-stairs" aria-hidden="true"><i></i><i></i><i></i><i></i></div>
Building Alfama
</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const loading = document.querySelector("#loading");
const routeToggle = document.querySelector("#routeToggle");
const resetViewButton = document.querySelector("#resetView");
const renderer = new THREE.WebGLRenderer({
canvas,
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;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#b9d1cb");
scene.fog = new THREE.Fog("#b9d1cb", 28, 58);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function material(color, roughness = 0.86) {
const key = `${color}-${roughness}`;
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness,
metalness: 0
})
);
}
return materialCache.get(key);
}
function addBox(parent, width, height, depth, color, x = 0, y = 0, z = 0, cast = true) {
const mesh = new THREE.Mesh(unitBox, material(color));
mesh.position.set(x, y, z);
mesh.scale.set(width, height, depth);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinderBetween(parent, a, b, radius, color, segments = 10) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const geometry = new THREE.CylinderGeometry(radius, radius, length, segments);
const mesh = new THREE.Mesh(geometry, material(color, 0.65));
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const hemisphere = new THREE.HemisphereLight("#d9eee5", "#80644f", 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight("#ffe1ad", 3.15);
sun.position.set(-9, 17, 12);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -18;
sun.shadow.camera.right = 18;
sun.shadow.camera.top = 20;
sun.shadow.camera.bottom = -14;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 55;
sun.shadow.normalBias = 0.025;
sun.target.position.set(0, 3, -1);
scene.add(sun, sun.target);
const fill = new THREE.DirectionalLight("#8fb9c1", 0.65);
fill.position.set(10, 8, -12);
scene.add(fill);
// The scene is presented as a small architectural model on a stone plinth.
addBox(scene, 14.4, 1.15, 24.2, "#b9aa8d", 0, -0.76, -0.2);
addBox(scene, 13.9, 0.16, 23.7, "#d1c2a4", 0, -0.11, -0.2);
addBox(scene, 7.6, 0.22, 4.4, "#d8cdb2", 0, -0.12, 10.6);
const STEP_COUNT = 9;
const STEP_DEPTH = 2.1;
const FIRST_Z = 8.5;
const STEP_RISE = 0.48;
function stepTop(index) {
return (index + 1) * STEP_RISE;
}
function stepZ(index) {
return FIRST_Z - index * STEP_DEPTH;
}
const routeGroup = new THREE.Group();
routeGroup.visible = false;
scene.add(routeGroup);
const routeMaterial = new THREE.MeshBasicMaterial({
color: "#eeb86c",
transparent: true,
opacity: 0.16,
depthWrite: false,
side: THREE.DoubleSide
});
const routeEdgeMaterial = new THREE.MeshBasicMaterial({
color: "#f3c474",
transparent: true,
opacity: 0.72,
depthWrite: false,
side: THREE.DoubleSide
});
const tileTransforms = [];
for (let i = 0; i < STEP_COUNT; i++) {
const z = stepZ(i);
const top = stepTop(i);
// Solid riser mass and pale stone tread.
const supportHeight = top + 0.32;
addBox(
scene,
4.72,
supportHeight,
STEP_DEPTH + 0.02,
i % 2 ? "#a99c84" : "#b2a68f",
0,
(top - 0.32) * 0.5,
z
);
addBox(
scene,
4.76,
0.18,
STEP_DEPTH + 0.04,
i % 2 ? "#d7c8a9" : "#e0d2b4",
0,
top - 0.09,
z
);
// A restrained line of joints makes the risers read as cut stone.
addBox(scene, 4.35, 0.035, 0.035, "#817967", 0, top - 0.2, z + STEP_DEPTH / 2 + 0.025);
for (let joint = -2; joint <= 2; joint++) {
addBox(
scene,
0.025,
0.29,
0.028,
"#8c806b",
joint * 0.84,
top - 0.27,
z + STEP_DEPTH / 2 + 0.026
);
}
// Low stepped side walls frame the route without narrowing it.
addBox(scene, 0.28, 0.42, STEP_DEPTH - 0.02, "#c8b99b", -2.15, top + 0.21, z);
addBox(scene, 0.28, 0.42, STEP_DEPTH - 0.02, "#c8b99b", 2.15, top + 0.21, z);
// Portuguese-style calçada mosaic, built from instanced voxel tiles.
for (let row = 0; row < 4; row++) {
for (let col = 0; col < 12; col++) {
const x = -1.77 + col * 0.322;
const tileZ = z - 0.69 + row * 0.46;
const pattern = (col * 3 + row * 5 + i * 2) % 11;
const color =
pattern === 0
? "#526968"
: pattern === 1
? "#6f817d"
: pattern === 7
? "#b7ad98"
: "#e9dec6";
tileTransforms.push({ x, y: top + 0.025, z: tileZ, color });
}
}
// Optional overlay identifying the unobstructed public stair route.
const routePlane = new THREE.Mesh(new THREE.PlaneGeometry(3.0, 1.86), routeMaterial);
routePlane.rotation.x = -Math.PI / 2;
routePlane.position.set(0, top + 0.061, z);
routeGroup.add(routePlane);
for (const edgeX of [-1.5, 1.5]) {
const edge = new THREE.Mesh(new THREE.PlaneGeometry(0.045, 1.86), routeEdgeMaterial);
edge.rotation.x = -Math.PI / 2;
edge.position.set(edgeX, top + 0.066, z);
routeGroup.add(edge);
}
}
const mosaic = new THREE.InstancedMesh(
unitBox,
material("#ffffff"),
tileTransforms.length
);
const dummy = new THREE.Object3D();
tileTransforms.forEach((tile, index) => {
dummy.position.set(tile.x, tile.y, tile.z);
dummy.scale.set(0.298, 0.035, 0.414);
dummy.updateMatrix();
mosaic.setMatrixAt(index, dummy.matrix);
mosaic.setColorAt(index, new THREE.Color(tile.color));
});
mosaic.instanceMatrix.needsUpdate = true;
if (mosaic.instanceColor) mosaic.instanceColor.needsUpdate = true;
mosaic.receiveShadow = true;
scene.add(mosaic);
function addWindow(x, z, centerY, shutterColor, withPlanter = false, side = -1) {
const frameColor = "#efe3c8";
addBox(scene, 0.085, 1.14, 0.84, "#294a4c", x, centerY, z);
addBox(scene, 0.12, 1.28, 0.075, frameColor, x, centerY, z - 0.48);
addBox(scene, 0.12, 1.28, 0.075, frameColor, x, centerY, z + 0.48);
addBox(scene, 0.12, 0.075, 1.03, frameColor, x, centerY - 0.60, z);
addBox(scene, 0.12, 0.075, 1.03, frameColor, x, centerY + 0.60, z);
for (const shutterZ of [z - 0.66, z + 0.66]) {
for (let slat = 0; slat < 5; slat++) {
addBox(
scene,
0.13,
0.045,
0.38,
shutterColor,
x - side * 0.025,
centerY - 0.48 + slat * 0.24,
shutterZ
);
}
addBox(
scene,
0.15,
1.22,
0.035,
shutterColor,
x - side * 0.045,
centerY,
shutterZ + (shutterZ < z ? -0.19 : 0.19)
);
}
addBox(scene, 0.3, 0.11, 1.08, "#d8c8a8", x - side * 0.1, centerY - 0.67, z);
if (withPlanter) {
addPlant(scene, x - side * 0.16, centerY - 0.58, z, 0.72);
}
}
function addPlant(parent, x, y, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
parent.add(group);
addBox(group, 0.29, 0.27, 0.29, "#b96843", 0, 0.135, 0);
addBox(group, 0.31, 0.055, 0.31, "#d78a58", 0, 0.28, 0);
addBox(group, 0.055, 0.34, 0.055, "#4e714b", 0, 0.43, 0);
addBox(group, 0.23, 0.16, 0.20, "#547b50", -0.08, 0.56, 0);
addBox(group, 0.18, 0.17, 0.19, "#6f9258", 0.11, 0.60, 0.03);
addBox(group, 0.15, 0.13, 0.16, "#436b49", 0.02, 0.72, -0.03);
return group;
}
function addDoor(side, z, baseY) {
const innerX = side * 2.295;
const x = innerX - side * 0.055;
const doorColor = side < 0 ? "#315b59" : "#784f42";
addBox(scene, 0.11, 1.72, 0.88, "#e4d4b2", x, baseY + 0.9, z);
addBox(scene, 0.13, 1.58, 0.76, doorColor, x - side * 0.025, baseY + 0.83, z);
addBox(scene, 0.14, 0.10, 0.82, "#bd9f75", x - side * 0.04, baseY + 1.55, z);
addBox(scene, 0.13, 0.05, 0.72, "#203f40", x - side * 0.055, baseY + 0.42, z);
addBox(scene, 0.09, 0.08, 0.08, "#d8b66d", x - side * 0.11, baseY + 0.86, z + 0.24);
// Small blue-and-cream azulejo panel.
addBox(scene, 0.07, 0.55, 0.55, "#3f7890", x - side * 0.12, baseY + 1.12, z + 0.65);
addBox(scene, 0.08, 0.07, 0.30, "#e7d9b8", x - side * 0.15, baseY + 1.15, z + 0.65);
addBox(scene, 0.08, 0.28, 0.07, "#e7d9b8", x - side * 0.15, baseY + 1.15, z + 0.65);
// Doorstep remains outside the central public route.
addBox(
scene,
0.62,
0.18,
0.98,
"#cabb9e",
innerX - side * 0.32,
baseY + 0.09,
z
);
}
function addLamp(x, y, z) {
addBox(scene, 0.34, 0.05, 0.06, "#273f3d", x + 0.17, y + 0.18, z);
addBox(scene, 0.08, 0.22, 0.08, "#273f3d", x + 0.30, y + 0.07, z);
addBox(scene, 0.22, 0.28, 0.22, "#304441", x + 0.30, y - 0.13, z);
const glowMaterial = new THREE.MeshStandardMaterial({
color: "#ffe7ad",
emissive: "#ffb64d",
emissiveIntensity: 2.2,
roughness: 0.55
});
const glow = new THREE.Mesh(unitBox, glowMaterial);
glow.position.set(x + 0.30, y - 0.13, z);
glow.scale.set(0.15, 0.17, 0.15);
scene.add(glow);
const light = new THREE.PointLight("#ffc875", 4.5, 4.2, 2);
light.position.set(x + 0.36, y - 0.15, z);
scene.add(light);
}
const facadeColors = [
"#d98562",
"#e8bd75",
"#efd8a7",
"#c97561",
"#b6c1ae",
"#e4a77c",
"#d9b783",
"#bd7760",
"#e5c997"
];
const shutterColors = ["#426f70", "#7f4c42", "#55766b", "#b56d48", "#47677d"];
function buildBuilding(side, index) {
const z = stepZ(index);
const baseY = stepTop(index) - 0.02;
const height = 4.15 + (index % 3) * 0.38;
const centerX = side * 4.52;
const innerX = side * 2.295;
const outerX = side * 6.745;
const facade = facadeColors[index % facadeColors.length];
const shutters = shutterColors[(index + (side > 0 ? 2 : 0)) % shutterColors.length];
const hasDoor = side < 0 ? index === 3 || index === 6 : index === 5;
addBox(scene, 4.45, height, 1.95, facade, centerX, baseY + height / 2, z);
// Slightly projecting base and cornice give the plaster depth.
addBox(
scene,
0.09,
0.42,
1.98,
side < 0 ? "#b96750" : "#9d7d60",
innerX - side * 0.025,
baseY + 0.25,
z
);
addBox(
scene,
0.11,
0.14,
2.02,
"#e8d7b6",
innerX - side * 0.03,
baseY + height - 0.06,
z
);
if (hasDoor) {
addDoor(side, z, baseY);
} else {
addWindow(
innerX - side * 0.055,
z,
baseY + 1.35,
shutters,
index % 2 === 0,
side
);
}
addWindow(
innerX - side * 0.055,
z,
baseY + 3.02,
shutters,
index % 3 === 0,
side
);
// Outer elevations remain visible when orbiting around the model.
addWindow(
outerX + side * 0.045,
z + 0.06,
baseY + 2.15,
shutters,
false,
side
);
// Flat Lisbon roof with parapet, chimney, and a small roof garden.
addBox(scene, 4.58, 0.18, 2.08, "#eadcbf", centerX, baseY + height + 0.09, z);
addBox(
scene,
0.16,
0.52,
2.06,
"#d9c9aa",
outerX - side * 0.02,
baseY + height + 0.40,
z
);
addBox(
scene,
4.5,
0.48,
0.14,
"#d9c9aa",
centerX,
baseY + height + 0.38,
z - 0.96
);
addBox(
scene,
0.42,
0.72,
0.42,
"#a9694e",
centerX + side * 0.7,
baseY + height + 0.53,
z - 0.38
);
addBox(
scene,
0.49,
0.12,
0.49,
"#c78a63",
centerX + side * 0.7,
baseY + height + 0.93,
z - 0.38
);
if (index % 2 === 0) {
addPlant(scene, centerX - side * 0.55, baseY + height + 0.19, z + 0.55, 0.8);
}
}
for (let i = 0; i < STEP_COUNT; i++) {
buildBuilding(-1, i);
if (i >= 2) buildBuilding(1, i);
}
// A slim handrail follows the stair edge while keeping the route open.
for (let i = 2; i < STEP_COUNT; i++) {
const z = stepZ(i);
const top = stepTop(i);
addBox(scene, 0.065, 0.66, 0.065, "#314d48", 1.96, top + 0.33, z);
if (i < STEP_COUNT - 1) {
addCylinderBetween(
scene,
new THREE.Vector3(1.96, top + 0.64, z),
new THREE.Vector3(1.96, top + STEP_RISE + 0.64, z - STEP_DEPTH),
0.035,
"#314d48",
8
);
}
}
addLamp(-2.12, stepTop(3) + 2.35, stepZ(3) + 0.73);
addLamp(-2.12, stepTop(6) + 2.35, stepZ(6) - 0.70);
// Household details are recessed against the walls, never in the public lane.
addPlant(scene, -1.86, stepTop(3), stepZ(3) + 0.62, 1.08);
addPlant(scene, 1.86, stepTop(5), stepZ(5) + 0.45, 0.92);
addBox(scene, 0.42, 0.58, 0.42, "#46615b", 1.88, stepTop(5) + 0.29, stepZ(5) - 0.52);
addBox(scene, 0.46, 0.08, 0.46, "#304b47", 1.88, stepTop(5) + 0.62, stepZ(5) - 0.52);
// A resident stands at the edge of a doorway with a small shopping basket.
const resident = new THREE.Group();
resident.position.set(-1.93, stepTop(3), stepZ(3) + 0.53);
scene.add(resident);
addBox(resident, 0.27, 0.56, 0.34, "#d49a55", 0, 0.78, 0);
addBox(resident, 0.25, 0.25, 0.25, "#b77b58", 0, 1.20, 0);
addBox(resident, 0.27, 0.10, 0.27, "#43342e", -0.01, 1.34, 0);
addBox(resident, 0.18, 0.45, 0.13, "#334f54", 0, 0.28, -0.11);
addBox(resident, 0.18, 0.45, 0.13, "#334f54", 0, 0.28, 0.11);
addBox(resident, 0.19, 0.13, 0.19, "#56453b", 0.04, 0.055, -0.11);
addBox(resident, 0.19, 0.13, 0.19, "#56453b", 0.04, 0.055, 0.11);
addBox(resident, 0.16, 0.42, 0.12, "#d49a55", 0.18, 0.75, -0.21);
addBox(resident, 0.25, 0.27, 0.26, "#b88b54", 0.28, 0.49, 0.22);
addBox(resident, 0.18, 0.05, 0.18, "#9e7547", 0.28, 0.65, 0.22);
// Overhead laundry line, safely above head height.
const laundryZ = stepZ(6);
const laundryY = 7.34;
addCylinderBetween(
scene,
new THREE.Vector3(-2.28, laundryY, laundryZ),
new THREE.Vector3(2.28, laundryY, laundryZ),
0.016,
"#354541",
8
);
const laundry = [];
function addLaundryItem(x, type, color, phase) {
const pivot = new THREE.Group();
pivot.position.set(x, laundryY, laundryZ);
pivot.userData.baseRotation = 0;
pivot.userData.phase = phase;
scene.add(pivot);
if (type === "shirt") {
addBox(pivot, 0.60, 0.72, 0.055, color, 0, -0.48, 0);
addBox(pivot, 0.23, 0.27, 0.055, color, -0.39, -0.29, 0);
addBox(pivot, 0.23, 0.27, 0.055, color, 0.39, -0.29, 0);
} else if (type === "towel") {
addBox(pivot, 0.52, 0.94, 0.05, color, 0, -0.58, 0);
addBox(pivot, 0.54, 0.09, 0.055, "#e7dcc4", 0, -0.91, 0.002);
} else {
addBox(pivot, 0.76, 1.02, 0.045, color, 0, -0.62, 0);
addBox(pivot, 0.78, 0.08, 0.05, "#d9cba9", 0, -0.99, 0.002);
}
addBox(pivot, 0.045, 0.15, 0.05, "#d5b16c", -0.16, -0.06, 0);
addBox(pivot, 0.045, 0.15, 0.05, "#d5b16c", 0.16, -0.06, 0);
laundry.push(pivot);
}
addLaundryItem(-1.48, "shirt", "#e8dfc8", 0.2);
addLaundryItem(-0.68, "towel", "#bd6b50", 1.3);
addLaundryItem(0.14, "shirt", "#66889b", 2.1);
addLaundryItem(1.00, "sheet", "#eee3c9", 3.2);
// A small painted facade detail in the distance suggests the river district.
addBox(scene, 5.8, 1.8, 0.25, "#7ba6ad", 0, 3.1, -11.4);
addBox(scene, 5.9, 0.18, 0.30, "#e1d4b4", 0, 4.05, -11.4);
// Custom orbit/pan/zoom controls; no addons are used.
const initialView = {
theta: 0.35,
phi: 1.08,
radius: 22.5,
target: new THREE.Vector3(0, 3.15, -0.65)
};
const desired = {
theta: initialView.theta,
phi: initialView.phi,
radius: initialView.radius,
target: initialView.target.clone()
};
const current = {
theta: initialView.theta,
phi: initialView.phi,
radius: initialView.radius,
target: initialView.target.clone()
};
const pointers = new Map();
let activePointerId = null;
let dragMode = "orbit";
let lastPointer = { x: 0, y: 0 };
let lastPinchDistance = 0;
function resetView() {
desired.theta = initialView.theta;
desired.phi = initialView.phi;
desired.radius = initialView.radius;
desired.target.copy(initialView.target);
}
function clampTarget() {
desired.target.x = THREE.MathUtils.clamp(desired.target.x, -2.5, 2.5);
desired.target.y = THREE.MathUtils.clamp(desired.target.y, 1.0, 6.2);
desired.target.z = THREE.MathUtils.clamp(desired.target.z, -7.0, 7.0);
}
function pointerDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
lastPinchDistance = pointerDistance();
activePointerId = null;
return;
}
activePointerId = event.pointerId;
dragMode = event.button === 2 || event.shiftKey ? "pan" : "orbit";
lastPointer = { x: event.clientX, y: event.clientY };
});
canvas.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
const distance = pointerDistance();
if (distance > 0 && lastPinchDistance > 0) {
desired.radius = THREE.MathUtils.clamp(
desired.radius * (lastPinchDistance / distance),
11,
34
);
}
lastPinchDistance = distance;
return;
}
if (event.pointerId !== activePointerId) return;
const dx = event.clientX - lastPointer.x;
const dy = event.clientY - lastPointer.y;
lastPointer = { x: event.clientX, y: event.clientY };
if (dragMode === "orbit") {
desired.theta -= dx * 0.0052;
desired.phi = THREE.MathUtils.clamp(desired.phi - dy * 0.0044, 0.62, 1.38);
} else {
const right = new THREE.Vector3().setFromMatrixColumn(camera.matrixWorld, 0);
const up = new THREE.Vector3().setFromMatrixColumn(camera.matrixWorld, 1);
const scale = current.radius * 0.00135;
desired.target.addScaledVector(right, -dx * scale);
desired.target.addScaledVector(up, dy * scale);
clampTarget();
}
});
function endPointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) lastPinchDistance = 0;
if (event.pointerId === activePointerId) activePointerId = null;
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desired.radius = THREE.MathUtils.clamp(
desired.radius * Math.exp(event.deltaY * 0.001),
11,
34
);
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
if (event.target instanceof HTMLButtonElement) return;
if (event.key === "ArrowLeft") desired.theta -= 0.12;
if (event.key === "ArrowRight") desired.theta += 0.12;
if (event.key === "ArrowUp") desired.phi = THREE.MathUtils.clamp(desired.phi - 0.08, 0.62, 1.38);
if (event.key === "ArrowDown") desired.phi = THREE.MathUtils.clamp(desired.phi + 0.08, 0.62, 1.38);
if (event.key === "+" || event.key === "=") desired.radius = Math.max(11, desired.radius - 1);
if (event.key === "-" || event.key === "_") desired.radius = Math.min(34, desired.radius + 1);
if (event.key.toLowerCase() === "r") resetView();
});
routeToggle.addEventListener("click", () => {
routeGroup.visible = !routeGroup.visible;
routeToggle.classList.toggle("active", routeGroup.visible);
routeToggle.setAttribute("aria-pressed", String(routeGroup.visible));
routeToggle.querySelector(".button-text").textContent = routeGroup.visible
? "Hide public route"
: "Show public route";
});
resetViewButton.addEventListener("click", resetView);
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
function updateCamera() {
current.theta = THREE.MathUtils.lerp(current.theta, desired.theta, 0.10);
current.phi = THREE.MathUtils.lerp(current.phi, desired.phi, 0.10);
current.radius = THREE.MathUtils.lerp(current.radius, desired.radius, 0.10);
current.target.lerp(desired.target, 0.10);
const sinPhi = Math.sin(current.phi);
camera.position.set(
current.target.x + current.radius * sinPhi * Math.sin(current.theta),
current.target.y + current.radius * Math.cos(current.phi),
current.target.z + current.radius * sinPhi * Math.cos(current.theta)
);
camera.lookAt(current.target);
}
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
laundry.forEach((item) => {
item.rotation.z =
item.userData.baseRotation +
Math.sin(elapsed * 0.68 + item.userData.phase) * 0.026;
});
updateCamera();
renderer.render(scene, camera);
}
resize();
updateCamera();
animate();
requestAnimationFrame(() => {
loading.classList.add("done");
setTimeout(() => loading.remove(), 600);
});
</script>
</body>
</html>
```