Prompt specification
Build or customize the Three.js 3D scene "Street artist beside a La Boca courtyard entrance" 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: Street artist beside a La Boca courtyard entrance
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/street-artist-beside-a-la-boca-courtyard-entrance-x2722
Scene Description Prompt:
Show an original voxel street artist beside a La Boca courtyard in Buenos Aires, preserving residents’ access. Three.js from cdnjs, standalone HTML.
Working Three.js Starter (street-artist-beside-a-la-boca-courtyard-entrance-x2722):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>La Boca — A Courtyard Shared</title>
<style>
:root {
color-scheme: dark;
--cream: #fff2d5;
--ink: #15333d;
--glass: rgba(14, 36, 43, 0.76);
--line: rgba(255, 242, 213, 0.2);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #9fd3df;
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
#scene:active { cursor: grabbing; }
.hud {
position: fixed;
z-index: 5;
top: clamp(18px, 4vw, 44px);
left: clamp(18px, 4vw, 48px);
width: min(440px, calc(100vw - 36px));
padding: 22px 23px 20px;
color: var(--cream);
background:
linear-gradient(135deg, rgba(255,255,255,.08), transparent 55%),
var(--glass);
border: 1px solid var(--line);
border-radius: 20px;
box-shadow: 0 18px 55px rgba(20, 35, 39, .2);
backdrop-filter: blur(14px);
pointer-events: none;
}
.eyebrow {
margin-bottom: 8px;
color: #ffd06b;
font-size: 11px;
font-weight: 800;
letter-spacing: .17em;
text-transform: uppercase;
}
h1 {
margin: 0 0 10px;
max-width: 380px;
font-size: clamp(27px, 4vw, 42px);
line-height: .98;
letter-spacing: -.045em;
}
.hud p {
margin: 0;
color: rgba(255, 242, 213, .82);
font-size: 14px;
line-height: 1.55;
}
.chips {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin-top: 16px;
}
.chip {
padding: 7px 10px;
border: 1px solid rgba(255,255,255,.13);
border-radius: 999px;
color: rgba(255, 242, 213, .9);
background: rgba(255,255,255,.06);
font-size: 11px;
font-weight: 700;
}
.chip.access {
color: #c7f3d8;
border-color: rgba(116, 230, 161, .25);
background: rgba(41, 145, 96, .16);
}
#reset {
pointer-events: auto;
margin-top: 17px;
padding: 10px 14px;
color: var(--ink);
background: #ffd06b;
border: 0;
border-radius: 10px;
font: inherit;
font-size: 12px;
font-weight: 800;
cursor: pointer;
box-shadow: 0 6px 18px rgba(0,0,0,.16);
transition: transform .15s ease, background .15s ease;
}
#reset:hover {
transform: translateY(-1px);
background: #ffdd8c;
}
.help {
position: fixed;
z-index: 5;
right: clamp(16px, 3vw, 34px);
bottom: clamp(16px, 3vw, 28px);
padding: 10px 13px;
color: rgba(255, 242, 213, .84);
background: rgba(14, 36, 43, .64);
border: 1px solid var(--line);
border-radius: 12px;
font-size: 11px;
letter-spacing: .01em;
backdrop-filter: blur(10px);
pointer-events: none;
}
#loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
color: var(--cream);
background: #173b45;
font-size: 14px;
letter-spacing: .08em;
text-transform: uppercase;
transition: opacity .45s ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 620px) {
.hud {
padding: 17px 18px 16px;
border-radius: 16px;
}
.hud p { font-size: 12px; }
.chips { margin-top: 12px; }
.chip { font-size: 10px; }
.help { left: 18px; right: auto; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive voxel street scene in La Boca, Buenos Aires"></canvas>
<section class="hud">
<div class="eyebrow">Buenos Aires · Barrio de La Boca</div>
<h1>Between color & home</h1>
<p>
Luz, an original voxel street artist, paints beside a neighborhood
courtyard. The central walkway remains open, clearly marked, and in
daily use by residents.
</p>
<div class="chips">
<span class="chip">Original voxel character</span>
<span class="chip">La Boca courtyard</span>
<span class="chip access">Residents’ access preserved</span>
</div>
<button id="reset" type="button">Reset camera</button>
</section>
<div class="help">Drag to orbit · Shift/right-drag to pan · Scroll to zoom</div>
<div id="loading">Building La Boca…</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 resetButton = document.querySelector("#reset");
let renderer;
try {
renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
} catch (error) {
loading.textContent = "WebGL is unavailable in this browser.";
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x9fd3df);
scene.fog = new THREE.Fog(0x9fd3df, 28, 58);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemi = new THREE.HemisphereLight(0xc8ecff, 0x916447, 1.85);
scene.add(hemi);
const sunLight = new THREE.DirectionalLight(0xffd18a, 3.2);
sunLight.position.set(-9, 17, 11);
sunLight.castShadow = true;
sunLight.shadow.mapSize.set(2048, 2048);
sunLight.shadow.camera.left = -20;
sunLight.shadow.camera.right = 20;
sunLight.shadow.camera.top = 18;
sunLight.shadow.camera.bottom = -12;
sunLight.shadow.camera.near = 1;
sunLight.shadow.camera.far = 50;
sunLight.shadow.bias = -0.00035;
scene.add(sunLight);
const fillLight = new THREE.DirectionalLight(0x8ecfe3, 0.7);
fillLight.position.set(12, 8, -12);
scene.add(fillLight);
const materialCache = new Map();
function material(color) {
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0,
flatShading: true
})
);
}
return materialCache.get(color);
}
function voxel(parent, size, position, color, customMaterial = null) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
customMaterial || material(color)
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
let seed = 24051989;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function signTexture(lines, background = "#163c45") {
const signCanvas = document.createElement("canvas");
signCanvas.width = 1024;
signCanvas.height = 256;
const context = signCanvas.getContext("2d");
context.fillStyle = background;
context.fillRect(0, 0, 1024, 256);
context.strokeStyle = "rgba(255,242,213,.42)";
context.lineWidth = 9;
context.strokeRect(13, 13, 998, 230);
context.textAlign = "center";
context.textBaseline = "middle";
const total = lines.length;
lines.forEach((line, index) => {
const text = typeof line === "string" ? line : line.text;
const size = typeof line === "string"
? (total === 1 ? 82 : 56)
: line.size;
const color = typeof line === "string"
? "#fff2d5"
: line.color;
context.fillStyle = color;
context.font = `800 ${size}px system-ui, sans-serif`;
context.fillText(
text,
512,
total === 1 ? 128 : 82 + index * 100
);
});
const texture = new THREE.CanvasTexture(signCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
function addSign(parent, lines, width, height, position, background) {
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: signTexture(lines, background),
toneMapped: false
})
);
mesh.position.set(position[0], position[1], position[2]);
parent.add(mesh);
return mesh;
}
// ------------------------------------------------------------------
// Ground, pavement and street
// ------------------------------------------------------------------
voxel(scene, [44, 0.45, 34], [0, -0.28, 1], 0xa77a59);
voxel(scene, [44, 0.12, 10], [0, -0.035, 9.3], 0x596166);
voxel(scene, [44, 0.18, 6.5], [0, 0.075, 2], 0xc5aa85);
voxel(scene, [44, 0.22, 0.3], [0, 0.09, 5.35], 0xe6bd68);
const tileGeometry = new THREE.BoxGeometry(0.94, 0.08, 0.94);
const tileMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.96
});
const sidewalkTiles = new THREE.InstancedMesh(
tileGeometry,
tileMaterial,
30 * 7
);
const tileMatrix = new THREE.Matrix4();
let tileIndex = 0;
for (let row = 0; row < 7; row++) {
for (let column = 0; column < 30; column++) {
tileMatrix.makeTranslation(
-14.55 + column,
0.15,
-0.75 + row * 0.94
);
sidewalkTiles.setMatrixAt(tileIndex, tileMatrix);
const shade = 0.61 + random() * 0.12;
sidewalkTiles.setColorAt(
tileIndex,
new THREE.Color().setHSL(0.09, 0.24, shade)
);
tileIndex++;
}
}
sidewalkTiles.receiveShadow = true;
scene.add(sidewalkTiles);
const cobbleGeometry = new THREE.BoxGeometry(0.94, 0.085, 0.65);
const cobbleMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 1
});
const cobbles = new THREE.InstancedMesh(
cobbleGeometry,
cobbleMaterial,
43 * 10
);
let cobbleIndex = 0;
for (let row = 0; row < 10; row++) {
for (let column = 0; column < 43; column++) {
tileMatrix.makeTranslation(
-20.9 + column,
0.065,
5.65 + row * 0.7
);
cobbles.setMatrixAt(cobbleIndex, tileMatrix);
const shade = 0.25 + random() * 0.14;
cobbles.setColorAt(
cobbleIndex,
new THREE.Color().setHSL(0.58, 0.08, shade)
);
cobbleIndex++;
}
}
cobbles.receiveShadow = true;
scene.add(cobbles);
// The open, continuous route through the courtyard.
voxel(
scene,
[5.2, 0.12, 13.2],
[4.75, 0.205, -2.35],
0xd8b77c
);
for (let i = 0; i < 7; i++) {
voxel(
scene,
[0.24, 0.035, 0.5],
[2.4 + i * 0.78, 0.285, 0.35],
i % 2 ? 0x3b8f87 : 0xe8c85d
);
}
// ------------------------------------------------------------------
// Colorful corrugated La Boca facade
// ------------------------------------------------------------------
const facade = new THREE.Group();
scene.add(facade);
const facadeColors = [
0xe95747,
0xf0bf43,
0x299b91,
0x365d8d,
0xe8a0b5,
0x62abc8,
0xe88635,
0x6d7557
];
let panelIndex = 0;
function panelRange(start, end, centerY, height) {
let x = start;
while (x < end - 0.01) {
const width = Math.min(1.45, end - x);
const color = facadeColors[panelIndex++ % facadeColors.length];
voxel(
facade,
[width - 0.025, height, 0.28],
[x + width / 2, centerY, -1.55],
color
);
for (
let rib = x + 0.14;
rib < x + width - 0.04;
rib += 0.21
) {
voxel(
facade,
[0.045, height - 0.08, 0.055],
[rib, centerY, -1.385],
color
);
}
if (random() > 0.58) {
const streakHeight = 0.7 + random() * 2.1;
voxel(
facade,
[0.035, streakHeight, 0.018],
[x + 0.18 + random() * (width - 0.3),
centerY - height / 2 + streakHeight / 2,
-1.34],
0x7f4938
);
}
x += width;
}
}
panelRange(-11.5, 2, 4.28, 8.25);
panelRange(7.5, 11.5, 4.28, 8.25);
panelRange(2, 7.5, 6.47, 3.78);
voxel(
facade,
[0.3, 4.55, 0.5],
[2, 2.38, -1.45],
0xf1c54e
);
voxel(
facade,
[0.3, 4.55, 0.5],
[7.5, 2.38, -1.45],
0xf1c54e
);
voxel(
facade,
[5.8, 0.28, 0.52],
[4.75, 4.43, -1.43],
0x294b56
);
function addWindow(x, y, z, width, height, shutterColor, flowers = false) {
voxel(
facade,
[width + 0.2, height + 0.2, 0.16],
[x, y, z],
0x28444d
);
voxel(
facade,
[width, height, 0.07],
[x, y, z + 0.1],
0x7ab8cb
);
voxel(
facade,
[0.08, height, 0.06],
[x, y, z + 0.16],
0xf1e1bd
);
voxel(
facade,
[width, 0.08, 0.06],
[x, y, z + 0.16],
0xf1e1bd
);
for (const side of [-1, 1]) {
voxel(
facade,
[0.34, height + 0.12, 0.12],
[x + side * (width / 2 + 0.25), y, z + 0.1],
shutterColor
);
for (let slat = -height / 2 + 0.22;
slat < height / 2;
slat += 0.28) {
voxel(
facade,
[0.25, 0.035, 0.025],
[x + side * (width / 2 + 0.25), y + slat, z + 0.175],
0x455b5c
);
}
}
voxel(
facade,
[width + 0.45, 0.12, 0.35],
[x, y - height / 2 - 0.12, z + 0.08],
0xf0dfb8
);
if (flowers) {
voxel(
facade,
[width + 0.16, 0.26, 0.38],
[x, y - height / 2 - 0.28, z + 0.18],
0x9f583c
);
for (let i = 0; i < 4; i++) {
voxel(
facade,
[0.2, 0.2, 0.2],
[x - width / 2 + i * width / 3,
y - height / 2 - 0.14,
z + 0.22],
[0xe9685e, 0xf2c84b, 0xe9685e, 0xf2c84b][i]
);
}
}
}
function addDoor(x, color) {
voxel(
facade,
[1.55, 3.05, 0.17],
[x, 1.64, -1.28],
0x28444d
);
voxel(
facade,
[1.22, 2.75, 0.1],
[x, 1.58, -1.16],
color
);
for (let i = 0; i < 4; i++) {
voxel(
facade,
[0.88, 0.055, 0.025],
[x, 0.68 + i * 0.58, -1.095],
0x365e64
);
}
voxel(
facade,
[0.09, 0.09, 0.09],
[x + 0.39, 1.52, -1.04],
0xf5cf67
);
voxel(
facade,
[1.7, 0.17, 0.65],
[x, 0.2, -1.03],
0xc7b99b
);
}
addWindow(-9.25, 6.15, -1.28, 1.55, 1.7, 0x3e7c7a);
addWindow(-5.8, 6.15, -1.28, 1.55, 1.7, 0xc94d48, true);
addWindow(-2.35, 6.1, -1.28, 1.55, 1.7, 0xe4b43d);
addWindow(9.5, 6.15, -1.28, 1.55, 1.7, 0x4d708d);
addWindow(-5.8, 2.55, -1.28, 1.55, 1.55, 0x3e7c7a, true);
addWindow(9.5, 2.55, -1.28, 1.55, 1.55, 0xc94d48);
addDoor(-9.25, 0x2c8b82);
addDoor(-1.45, 0xd95648);
addDoor(9.5, 0xd5903d);
// Small balcony.
voxel(facade, [3.35, 0.16, 1.05], [-2.35, 4.28, -0.85], 0x324e55);
for (let i = 0; i < 8; i++) {
voxel(
facade,
[0.08, 1.42, 0.08],
[-3.8 + i * 0.41, 4.98, -0.34],
0x263c43
);
}
voxel(facade, [3.45, 0.1, 0.12], [-2.35, 5.68, -0.34], 0x263c43);
voxel(facade, [3.45, 0.07, 0.08], [-2.35, 4.78, -0.34], 0x263c43);
// Neighborhood labels.
voxel(
facade,
[4.65, 1.15, 0.12],
[-6.35, 3.95, -1.08],
0x173c45
);
addSign(
facade,
[
{ text: "LA BOCA", size: 76, color: "#ffd06b" },
{ text: "BUENOS AIRES", size: 38, color: "#fff2d5" }
],
4.5,
1.02,
[-6.35, 3.95, -1.005],
"#173c45"
);
voxel(
facade,
[4.9, 0.82, 0.13],
[4.75, 4.02, -1.23],
0x173c45
);
addSign(
facade,
[
{ text: "PATIO VECINAL", size: 64, color: "#ffd06b" },
{ text: "ACCESO LIBRE A VECINOS", size: 34, color: "#c7f3d8" }
],
4.72,
0.7,
[4.75, 4.02, -1.15],
"#173c45"
);
// ------------------------------------------------------------------
// Courtyard interior
// ------------------------------------------------------------------
const courtyard = new THREE.Group();
scene.add(courtyard);
voxel(courtyard, [0.22, 4.5, 7.2], [2.05, 2.38, -5.15], 0xc57b60);
voxel(courtyard, [0.22, 4.5, 7.2], [7.45, 2.38, -5.15], 0x6da6a3);
voxel(courtyard, [5.5, 4.5, 0.24], [4.75, 2.38, -8.7], 0xe0b36d);
voxel(courtyard, [5.2, 0.12, 7.3], [4.75, 0.23, -5.05], 0xcda36b);
const courtyardLight = new THREE.PointLight(0xffc66f, 17, 10, 2);
courtyardLight.position.set(4.8, 3.6, -5.5);
courtyard.add(courtyardLight);
function createPlanter(x, z, scale = 1, potColor = 0xb85f43) {
const group = new THREE.Group();
group.position.set(x, 0.23, z);
group.scale.setScalar(scale);
courtyard.add(group);
voxel(group, [0.72, 0.62, 0.72], [0, 0.31, 0], potColor);
voxel(group, [0.79, 0.12, 0.79], [0, 0.62, 0], 0xd27b58);
voxel(group, [0.55, 0.08, 0.55], [0, 0.69, 0], 0x58483a);
voxel(group, [0.12, 1.0, 0.12], [0, 1.05, 0], 0x6b5338);
const leafColors = [0x3c7952, 0x5a9b61, 0x2f6849];
for (let i = 0; i < 8; i++) {
const leaf = voxel(
group,
[0.42 + random() * 0.28, 0.42, 0.42],
[
(random() - 0.5) * 0.72,
1.0 + random() * 0.62,
(random() - 0.5) * 0.72
],
leafColors[i % leafColors.length]
);
leaf.rotation.y = random() * Math.PI;
leaf.rotation.z = (random() - 0.5) * 0.6;
}
return group;
}
createPlanter(2.75, -6.8, 1.15, 0xba6349);
createPlanter(7.0, -6.6, 0.92, 0xc88252);
createPlanter(1.65, 0.7, 0.78, 0xbb6347);
createPlanter(7.85, 0.8, 0.78, 0xbb6347);
// A modest courtyard table.
voxel(courtyard, [1.45, 0.13, 0.85], [3.55, 1.05, -7.45], 0x8e5e43);
for (const x of [-0.52, 0.52]) {
for (const z of [-0.28, 0.28]) {
voxel(
courtyard,
[0.11, 0.9, 0.11],
[3.55 + x, 0.62, -7.45 + z],
0x77503c
);
}
}
// Laundry line.
const laundryLineGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(2.7, 3.52, -6.25),
new THREE.Vector3(6.9, 3.52, -6.25)
]);
courtyard.add(
new THREE.Line(
laundryLineGeometry,
new THREE.LineBasicMaterial({ color: 0x334a4e })
)
);
const laundry = [];
const clothColors = [0xf4dfae, 0x72b6c6, 0xe17b6c, 0xe8c55b];
for (let i = 0; i < 4; i++) {
const cloth = voxel(
courtyard,
[0.58, 0.78, 0.045],
[3.3 + i * 1.03, 3.05, -6.25],
clothColors[i]
);
laundry.push(cloth);
}
// ------------------------------------------------------------------
// A resident uses the open path
// ------------------------------------------------------------------
function createWalker() {
const walker = new THREE.Group();
walker.scale.setScalar(0.86);
const skin = 0x9a6247;
const shirt = 0xe56c57;
const trousers = 0x304b68;
const legPivots = [];
for (const side of [-1, 1]) {
const leg = new THREE.Group();
leg.position.set(side * 0.16, 0.83, 0);
voxel(leg, [0.23, 0.76, 0.25], [0, -0.38, 0], trousers);
voxel(leg, [0.27, 0.18, 0.42], [0, -0.78, 0.08], 0x28363d);
walker.add(leg);
legPivots.push(leg);
}
voxel(walker, [0.72, 0.83, 0.42], [0, 1.33, 0], shirt);
voxel(walker, [0.72, 0.22, 0.43], [0, 0.98, 0], 0x31526c);
voxel(walker, [0.52, 0.56, 0.5], [0, 2.03, 0], skin);
voxel(walker, [0.57, 0.2, 0.54], [0, 2.31, 0], 0x342c2d);
for (const side of [-1, 1]) {
voxel(
walker,
[0.18, 0.64, 0.2],
[side * 0.48, 1.33, 0],
shirt
);
voxel(
walker,
[0.16, 0.15, 0.09],
[side * 0.13, 2.08, 0.265],
0x27343a
);
}
walker.userData.legs = legPivots;
return walker;
}
const walker = createWalker();
walker.position.set(5.15, 0.28, -3.8);
scene.add(walker);
// ------------------------------------------------------------------
// Luz, the original voxel street artist
// ------------------------------------------------------------------
const artist = new THREE.Group();
artist.position.set(-3.72, 0.23, 2.12);
artist.rotation.y = Math.PI / 2;
scene.add(artist);
const skin = 0xc7865c;
const denim = 0x2f7685;
const yellow = 0xf2c654;
const red = 0xd95749;
// Shoes and trousers.
for (const side of [-1, 1]) {
voxel(
artist,
[0.38, 0.22, 0.58],
[side * 0.23, 0.12, 0.12],
0x293b42
);
voxel(
artist,
[0.29, 1.04, 0.32],
[side * 0.23, 0.75, 0],
0x33475b
);
}
// Torso and overalls.
voxel(artist, [0.9, 0.9, 0.5], [0, 1.65, 0], yellow);
voxel(artist, [0.82, 0.62, 0.13], [0, 1.53, 0.29], denim);
voxel(artist, [0.16, 0.58, 0.1], [-0.22, 1.82, 0.31], denim);
voxel(artist, [0.16, 0.58, 0.1], [0.22, 1.82, 0.31], denim);
voxel(artist, [0.12, 0.12, 0.045], [0, 1.62, 0.38], yellow);
// Neck and head.
voxel(artist, [0.29, 0.19, 0.3], [0, 2.13, 0], skin);
voxel(artist, [0.68, 0.66, 0.62], [0, 2.47, 0], skin);
voxel(artist, [0.72, 0.23, 0.67], [0, 2.76, -0.015], 0x3e3030);
voxel(artist, [0.2, 0.2, 0.19], [0, 2.47, 0.39], skin);
for (const side of [-1, 1]) {
voxel(
artist,
[0.075, 0.085, 0.045],
[side * 0.15, 2.52, 0.327],
0x283338
);
}
// Red cap with a yellow band.
voxel(artist, [0.75, 0.24, 0.69], [0, 2.79, 0], red);
voxel(artist, [0.78, 0.08, 0.72], [0, 2.65, 0], yellow);
voxel(artist, [0.62, 0.08, 0.28], [0, 2.65, 0.43], red);
// Upper arm reaches toward the canvas.
voxel(
artist,
[0.24, 0.25, 0.58],
[0.49, 1.77, 0.34],
yellow
);
const paintArm = new THREE.Group();
paintArm.position.set(0.49, 1.75, 0.72);
artist.add(paintArm);
voxel(paintArm, [0.22, 0.22, 0.47], [0, 0, 0.19], yellow);
voxel(paintArm, [0.22, 0.22, 0.22], [0, 0, 0.52], skin);
voxel(paintArm, [0.075, 0.075, 0.5], [0, 0.025, 0.83], 0x73503b);
voxel(paintArm, [0.09, 0.09, 0.12], [0, 0.025, 1.11], 0x3b8f87);
// Other arm and palette.
voxel(
artist,
[0.23, 0.65, 0.25],
[-0.5, 1.56, 0.2],
yellow
);
voxel(
artist,
[0.21, 0.21, 0.22],
[-0.48, 1.33, 0.42],
skin
);
const palette = voxel(
artist,
[0.58, 0.5, 0.12],
[-0.48, 1.48, 0.55],
0xb97b4e
);
const paintColors = [0xee5b52, 0xf3ca4c, 0x358e89, 0x416a91];
paintColors.forEach((color, index) => {
voxel(
artist,
[0.13, 0.13, 0.035],
[
-0.68 + (index % 2) * 0.2,
1.58 - Math.floor(index / 2) * 0.16,
0.625
],
color
);
});
// Artist's work mat.
voxel(
scene,
[4.15, 0.035, 2.15],
[-2.55, 0.235, 2.35],
0x416b70
);
// Easel.
const easel = new THREE.Group();
easel.position.set(-1.65, 0, 2.12);
scene.add(easel);
const leftLeg = voxel(
easel,
[0.13, 2.15, 0.15],
[-0.73, 1.1, -0.12],
0x74513d
);
leftLeg.rotation.z = -0.13;
const rightLeg = voxel(
easel,
[0.13, 2.15, 0.15],
[0.73, 1.1, -0.12],
0x74513d
);
rightLeg.rotation.z = 0.13;
voxel(easel, [1.7, 0.12, 0.16], [0, 1.65, -0.13], 0x74513d);
voxel(easel, [2.34, 1.72, 0.16], [0, 1.95, 0], 0x533d32);
voxel(easel, [2.1, 1.48, 0.055], [0, 1.95, 0.105], 0xf2dfb6);
// Original pixel mural: a sunset above a cactus courtyard.
voxel(easel, [0.62, 0.62, 0.035], [0.55, 2.23, 0.15], 0xf4be45);
voxel(easel, [0.34, 0.34, 0.04], [0.55, 2.23, 0.175], 0xffda65);
const muralBlocks = [
[-0.87, 1.62, 0.43, 0.31, 0xdd5c4e],
[-0.40, 1.67, 0.53, 0.22, 0x2c8c86],
[0.08, 1.62, 0.56, 0.31, 0x3f6384],
[0.73, 1.64, 0.49, 0.27, 0xe98c42]
];
muralBlocks.forEach(block => {
voxel(
easel,
[block[2], block[3], 0.045],
[block[0], block[1], 0.16],
block[4]
);
});
voxel(easel, [0.22, 0.79, 0.055], [-0.02, 1.97, 0.17], 0x3d8752);
voxel(easel, [0.47, 0.2, 0.055], [-0.22, 2.13, 0.17], 0x3d8752);
voxel(easel, [0.47, 0.2, 0.055], [0.18, 1.8, 0.17], 0x3d8752);
addSign(
easel,
[{ text: "LUZ", size: 68, color: "#173c45" }],
0.72,
0.28,
[0, 1.29, 0.11],
"#e7bd54"
);
// Paint cans and scattered color cubes.
const canColors = [0xeb5d51, 0x3a948c, 0xf1c64e];
canColors.forEach((color, index) => {
voxel(
scene,
[0.42, 0.42, 0.42],
[-2.82 + index * 0.47, 0.48, 3.0],
color
);
voxel(
scene,
[0.46, 0.07, 0.46],
[-2.82 + index * 0.47, 0.72, 3.0],
0xd9cfb5
);
});
for (let i = 0; i < 9; i++) {
voxel(
scene,
[0.12, 0.035, 0.12],
[-3.2 + random() * 2.7, 0.275, 2.6 + random() * 1.05],
canColors[i % canColors.length]
);
}
// ------------------------------------------------------------------
// Street details
// ------------------------------------------------------------------
function createBird(x, z, scale = 1) {
const bird = new THREE.Group();
bird.position.set(x, 0.22, z);
bird.scale.setScalar(scale);
scene.add(bird);
voxel(bird, [0.28, 0.22, 0.43], [0, 0, 0], 0x707b78);
voxel(bird, [0.23, 0.24, 0.22], [0, 0.14, 0.23], 0x858d84);
voxel(bird, [0.09, 0.09, 0.16], [0, 0.13, 0.4], 0xe3b34f);
voxel(bird, [0.07, 0.07, 0.035], [-0.06, 0.18, 0.35], 0x26383d);
const wing = voxel(
bird,
[0.3, 0.09, 0.24],
[0, 0.02, -0.02],
0x525f5d
);
bird.userData.wing = wing;
bird.userData.baseY = 0.22;
return bird;
}
const birds = [
createBird(-0.8, 7.0, 1),
createBird(0.0, 7.45, 0.86),
createBird(0.62, 7.05, 0.92)
];
// Voxel lamp post.
voxel(scene, [0.2, 4.8, 0.2], [-11.25, 2.48, 3.75], 0x36545a);
voxel(scene, [0.95, 0.16, 0.25], [-11.25, 4.9, 3.75], 0x36545a);
voxel(
scene,
[0.62, 0.48, 0.55],
[-11.25, 4.67, 3.75],
0xffe3a0,
new THREE.MeshStandardMaterial({
color: 0xffe3a0,
emissive: 0xffbd55,
emissiveIntensity: 1.3,
roughness: 0.55
})
);
// Utility wires.
function addWire(points) {
const geometry = new THREE.BufferGeometry().setFromPoints(
points.map(point => new THREE.Vector3(...point))
);
scene.add(
new THREE.Line(
geometry,
new THREE.LineBasicMaterial({ color: 0x30484c })
)
);
}
addWire([
[-12, 8.1, -0.8],
[-6, 7.5, -0.7],
[0, 7.25, -0.65],
[6, 7.5, -0.7],
[12, 8.0, -0.8]
]);
addWire([
[-12, 8.55, -0.65],
[-6, 8.05, -0.55],
[0, 7.85, -0.5],
[6, 8.08, -0.55],
[12, 8.55, -0.65]
]);
// Warm sun and blocky clouds.
const sun = new THREE.Mesh(
new THREE.SphereGeometry(1.45, 16, 12),
new THREE.MeshBasicMaterial({ color: 0xffd27c })
);
sun.position.set(-13, 14.5, -19);
scene.add(sun);
const clouds = new THREE.Group();
scene.add(clouds);
[
[-8, 11.2, -17, 2.2],
[5, 12.5, -20, 2.8],
[14, 10.4, -18, 1.8]
].forEach(([x, y, z, width]) => {
voxel(clouds, [width, 0.55, 0.8], [x, y, z], 0xe7f1e9);
voxel(clouds, [width * 0.62, 0.75, 0.82], [x - 0.3, y + 0.45, z], 0xf3f5e9);
voxel(clouds, [width * 0.52, 0.6, 0.82], [x + 0.55, y + 0.3, z], 0xe7f1e9);
});
// ------------------------------------------------------------------
// Direct camera controls — no Three.js addons
// ------------------------------------------------------------------
const goal = {
theta: 0.24,
phi: 1.12,
radius: 24,
target: new THREE.Vector3(-0.3, 2.7, -0.6)
};
const current = {
theta: goal.theta,
phi: goal.phi,
radius: goal.radius,
target: goal.target.clone()
};
function updateCamera() {
const sinPhi = Math.sin(current.phi);
const cosPhi = Math.cos(current.phi);
camera.position.set(
current.target.x + current.radius * sinPhi * Math.sin(current.theta),
current.target.y + current.radius * cosPhi,
current.target.z + current.radius * sinPhi * Math.cos(current.theta)
);
camera.lookAt(current.target);
}
function clampGoal() {
goal.radius = THREE.MathUtils.clamp(goal.radius, 9, 36);
goal.phi = THREE.MathUtils.clamp(goal.phi, 0.5, 1.47);
goal.target.x = THREE.MathUtils.clamp(goal.target.x, -13, 13);
goal.target.y = THREE.MathUtils.clamp(goal.target.y, 0.7, 8);
goal.target.z = THREE.MathUtils.clamp(goal.target.z, -9, 10);
}
function panCamera(deltaX, deltaY) {
const right = new THREE.Vector3(
Math.cos(goal.theta),
0,
-Math.sin(goal.theta)
);
const forward = new THREE.Vector3(
Math.sin(goal.theta),
0,
Math.cos(goal.theta)
);
const scale = goal.radius * 0.00145;
goal.target.addScaledVector(right, -deltaX * scale);
goal.target.addScaledVector(forward, deltaY * scale);
goal.target.y += deltaY * scale * 0.45;
clampGoal();
}
const pointers = new Map();
let singleGesture = null;
let pinchDistance = 0;
let pinchCenter = { x: 0, y: 0 };
function pointerDistance() {
const points = [...pointers.values()];
return Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
function pointerCenter() {
const points = [...pointers.values()];
return {
x: (points[0].x + points[1].x) / 2,
y: (points[0].y + points[1].y) / 2
};
}
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
singleGesture = {
mode: event.shiftKey || event.button === 2 ? "pan" : "rotate"
};
} else if (pointers.size === 2) {
singleGesture = null;
pinchDistance = pointerDistance();
pinchCenter = pointerCenter();
}
});
canvas.addEventListener("pointermove", event => {
const pointer = pointers.get(event.pointerId);
if (!pointer) return;
if (pointers.size === 1 && singleGesture) {
const deltaX = event.clientX - pointer.x;
const deltaY = event.clientY - pointer.y;
if (singleGesture.mode === "rotate") {
goal.theta -= deltaX * 0.0055;
goal.phi += deltaY * 0.0045;
} else {
panCamera(deltaX, deltaY);
}
clampGoal();
} else if (pointers.size === 2) {
const newDistance = pointerDistance();
const newCenter = pointerCenter();
if (pinchDistance > 0) {
goal.radius *= pinchDistance / newDistance;
panCamera(
newCenter.x - pinchCenter.x,
newCenter.y - pinchCenter.y
);
}
pinchDistance = newDistance;
pinchCenter = newCenter;
clampGoal();
}
pointer.x = event.clientX;
pointer.y = event.clientY;
});
function endPointer(event) {
pointers.delete(event.pointerId);
if (pointers.size === 1) {
const remaining = [...pointers.values()][0];
singleGesture = { mode: "rotate" };
pinchDistance = 0;
remaining.lastX = remaining.x;
} else {
singleGesture = null;
pinchDistance = 0;
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener(
"wheel",
event => {
event.preventDefault();
goal.radius *= Math.exp(event.deltaY * 0.001);
clampGoal();
},
{ passive: false }
);
function resetCamera() {
goal.theta = 0.24;
goal.phi = 1.12;
goal.radius = 24;
goal.target.set(-0.3, 2.7, -0.6);
}
resetButton.addEventListener("click", resetCamera);
canvas.addEventListener("dblclick", resetCamera);
// ------------------------------------------------------------------
// Animation
// ------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
const delta = Math.min(clock.getDelta(), 0.05);
current.theta = THREE.MathUtils.lerp(
current.theta,
goal.theta,
1 - Math.pow(0.001, delta)
);
current.phi = THREE.MathUtils.lerp(
current.phi,
goal.phi,
1 - Math.pow(0.001, delta)
);
current.radius = THREE.MathUtils.lerp(
current.radius,
goal.radius,
1 - Math.pow(0.001, delta)
);
current.target.lerp(
goal.target,
1 - Math.pow(0.001, delta)
);
updateCamera();
// The painting arm makes a small, continuous brushstroke.
paintArm.rotation.x = -0.055 + Math.sin(elapsed * 3.1) * 0.045;
paintArm.position.y = 1.75 + Math.sin(elapsed * 3.1) * 0.025;
// The resident moves along the preserved courtyard route.
const walkPhase = elapsed * 0.34;
walker.position.z = -3.85 + (Math.sin(walkPhase) + 1) * 2.55;
const walkingDirection = Math.cos(walkPhase) >= 0 ? 0 : Math.PI;
walker.rotation.y = walkingDirection;
walker.userData.legs[0].rotation.x = Math.sin(walkPhase * 2.4) * 0.34;
walker.userData.legs[1].rotation.x = -Math.sin(walkPhase * 2.4) * 0.34;
// Gentle laundry and bird movement.
laundry.forEach((cloth, index) => {
cloth.rotation.z = Math.sin(elapsed * 0.9 + index * 0.7) * 0.035;
});
birds.forEach((bird, index) => {
bird.position.y = bird.userData.baseY + Math.sin(elapsed * 2 + index) * 0.025;
bird.userData.wing.rotation.z = Math.sin(elapsed * 5 + index) * 0.12;
bird.rotation.y = -0.3 + index * 0.16;
});
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
updateCamera();
renderer.setAnimationLoop(animate);
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 500);
});
</script>
</body>
</html>
```