Prompt specification
Build or customize the Three.js 3D scene "La Boca corrugated facade and shared balcony" 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: La Boca corrugated facade and shared balcony
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/la-boca-corrugated-facade-and-shared-balcony-x2721
Scene Description Prompt:
A voxel La Boca facade in Buenos Aires, with corrugated walls, shared balcony, and separate entrances. Three.js from cdnjs, one HTML file.
Working Three.js Starter (la-boca-corrugated-facade-and-shared-balcony-x2721):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
<title>La Boca — Caminito, Buenos Aires</title>
<style>
html,body{margin:0;height:100%;overflow:hidden;background:#0e1116;
font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:#e8eef5}
canvas{display:block}
#title{position:fixed;left:16px;top:14px;pointer-events:none;
background:rgba(10,14,20,.55);backdrop-filter:blur(6px);
border:1px solid rgba(255,255,255,.14);border-radius:10px;padding:10px 14px}
#title b{font-size:19px;letter-spacing:.18em;color:#ffd166}
#title span{display:block;font-size:11px;opacity:.75;letter-spacing:.12em;margin-top:3px}
#hint{position:fixed;right:16px;bottom:14px;pointer-events:none;font-size:11px;
letter-spacing:.08em;opacity:.8;background:rgba(10,14,20,.5);padding:8px 12px;
border:1px solid rgba(255,255,255,.12);border-radius:8px}
#tag{position:fixed;left:16px;bottom:14px;font-size:11px;letter-spacing:.08em;
opacity:.65;pointer-events:none}
</style>
</head>
<body>
<canvas id="scene"></canvas>
<div id="title"><b>LA BOCA</b><span>VOXEL CAMINITO · BUENOS AIRES</span></div>
<div id="tag">shared balconies · separate entrances · corrugated iron</div>
<div id="hint">drag = orbit · wheel = zoom · right-drag / shift-drag = pan</div>
<script type="module">
import * as THREE from 'https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js';
/* ============================================================
RENDERER / SCENE
============================================================ */
const canvas = document.getElementById('scene');
const renderer = new THREE.WebGLRenderer({canvas, antialias:true, powerPreference:'high-performance'});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.02;
renderer.outputColorSpace = THREE.SRGBColorSpace;
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(45, innerWidth/innerHeight, 0.1, 400);
/* --- sky gradient --- */
function skyTexture(){
const c = document.createElement('canvas'); c.width = 8; c.height = 256;
const g = c.getContext('2d');
const grd = g.createLinearGradient(0,0,0,256);
grd.addColorStop(0.00,'#2f6fb5');
grd.addColorStop(0.42,'#8fc4ec');
grd.addColorStop(0.72,'#e7d3b4');
grd.addColorStop(1.00,'#f0c18c');
g.fillStyle = grd; g.fillRect(0,0,8,256);
const t = new THREE.CanvasTexture(c); t.colorSpace = THREE.SRGBColorSpace; return t;
}
scene.background = skyTexture();
scene.fog = new THREE.Fog('#d9dfE6'.replace('E','e'), 48, 150);
/* --- lights --- */
scene.add(new THREE.HemisphereLight(0xbfe0ff, 0x8a7b64, 0.85));
const sun = new THREE.DirectionalLight(0xffe0ac, 2.35);
sun.position.set(-14, 20, 15);
sun.castShadow = true;
sun.shadow.mapSize.set(2048,2048);
sun.shadow.camera.left = -24; sun.shadow.camera.right = 24;
sun.shadow.camera.top = 24; sun.shadow.camera.bottom = -24;
sun.shadow.camera.near = 1; sun.shadow.camera.far = 90;
sun.shadow.bias = -0.0005; sun.shadow.normalBias = 0.03;
sun.target.position.set(-1, 3, 0);
scene.add(sun, sun.target);
const fill = new THREE.DirectionalLight(0xbcd4ff, 0.35);
fill.position.set(12, 8, -12); scene.add(fill);
/* ============================================================
MATERIAL / GEOMETRY HELPERS
============================================================ */
const matCache = new Map();
function M(color, extra){
const key = color + '|' + (extra ? JSON.stringify(extra) : '');
let m = matCache.get(key);
if(!m){ m = new THREE.MeshLambertMaterial({color}); if(extra) Object.assign(m, extra); matCache.set(key,m); }
return m;
}
const geoCache = new Map();
function G(w,h,d){
const k = w+'x'+h+'x'+d;
let g = geoCache.get(k);
if(!g){ g = new THREE.BoxGeometry(w,h,d); geoCache.set(k,g); }
return g;
}
function box(w,h,d,x,y,z,color,extra,parent){
const m = new THREE.Mesh(G(w,h,d), M(color, extra));
m.position.set(x,y,z); m.castShadow = true; m.receiveShadow = true;
(parent || scene).add(m); return m;
}
const _dummy = new THREE.Object3D();
/* --- corrugated iron panel: instanced vertical ribs --- */
function corrugated(w, h, color, x, y, z, rotY, stripeColor, rib){
rib = rib || 0.30;
const n = Math.max(2, Math.round(w / rib));
const sw = w / n;
const mesh = new THREE.InstancedMesh(new THREE.BoxGeometry(1,1,1),
new THREE.MeshLambertMaterial({color:0xffffff}), n);
mesh.castShadow = true; mesh.receiveShadow = true;
const c1 = new THREE.Color(color), c2 = stripeColor ? new THREE.Color(stripeColor) : null;
for(let i=0;i<n;i++){
const deep = (i % 2 === 0);
_dummy.position.set(-w/2 + sw*(i+0.5), 0, 0);
_dummy.scale.set(sw*0.97, h, deep ? 0.17 : 0.075);
_dummy.rotation.set(0,0,0);
_dummy.updateMatrix();
mesh.setMatrixAt(i, _dummy.matrix);
const c = (c2 && i % 2 === 1 ? c2.clone() : c1.clone());
c.offsetHSL(0, 0, (Math.random()-0.5)*0.055);
mesh.setColorAt(i, c);
}
mesh.instanceMatrix.needsUpdate = true;
if(mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
mesh.position.set(x,y,z); mesh.rotation.y = rotY || 0;
scene.add(mesh);
return mesh;
}
/* ============================================================
CANVAS TEXTURES
============================================================ */
function numTexture(n){
const c = document.createElement('canvas'); c.width = c.height = 128;
const g = c.getContext('2d');
g.fillStyle = '#f4efe2'; g.fillRect(0,0,128,128);
g.fillStyle = '#23272e'; g.font = 'bold 82px monospace';
g.textAlign = 'center'; g.textBaseline = 'middle';
g.fillText(String(n), 64, 70);
const t = new THREE.CanvasTexture(c); t.colorSpace = THREE.SRGBColorSpace; return t;
}
const numCache = new Map();
function numberPlate(n){
if(!numCache.has(n)) numCache.set(n, numTexture(n));
return numCache.get(n);
}
function signTexture(text, bg, fg){
const c = document.createElement('canvas'); c.width = 512; c.height = 128;
const g = c.getContext('2d');
g.fillStyle = bg; g.fillRect(0,0,512,128);
g.strokeStyle = fg; g.lineWidth = 6; g.strokeRect(8,8,496,112);
g.fillStyle = fg; g.font = 'bold 62px monospace';
g.textAlign = 'center'; g.textBaseline = 'middle';
g.fillText(text, 256, 68);
const t = new THREE.CanvasTexture(c); t.colorSpace = THREE.SRGBColorSpace; return t;
}
/* painted walkway with footprints */
function pavementTexture(){
const c = document.createElement('canvas'); c.width = 2048; c.height = 200;
const g = c.getContext('2d');
g.fillStyle = '#b3ab9c'; g.fillRect(0,0,2048,200);
const cols = ['#c6bda9','#b6a68a','#cdbfa2','#a8a294','#c0b9a4','#bcae94'];
for(let i=0;i<1400;i++){
g.fillStyle = cols[(Math.random()*cols.length)|0];
const x = Math.random()*2048, y = Math.random()*200;
g.globalAlpha = 0.55 + Math.random()*0.4;
g.fillRect(x, y, 12+Math.random()*26, 9+Math.random()*16);
}
g.globalAlpha = 1;
g.fillStyle = 'rgba(60,60,62,.72)';
for(let k=0;k<9;k++){
const x = 120 + k*220;
g.save(); g.translate(x, 78); g.rotate((Math.random()-0.5)*0.25);
g.beginPath(); g.ellipse(0,-16,13,20,0,0,Math.PI*2); g.fill();
g.beginPath(); g.ellipse(4,24,9,15,0,0,Math.PI*2); g.fill();
g.fillRect(-5,-2,10,10);
g.restore();
}
const t = new THREE.CanvasTexture(c); t.colorSpace = THREE.SRGBColorSpace;
t.anisotropy = renderer.capabilities.getMaxAnisotropy();
return t;
}
/* CAMINITO mural on the gable end-wall */
const PIXFONT = {
C:['.###.','#...#','#....','#....','#...#','.###.'],
A:['.###.','#...#','#...#','#####','#...#','#...#'],
M:['#...#','##.##','#.#.#','#...#','#...#','#...#'],
I:['#####','..#..','..#..','..#..','..#..','#####'],
N:['#..##','##..#','#.#.#','#..##','#...#','#...#'],
O:['.###.','#...#','#...#','#...#','#...#','.###.'],
T:['#####','..#..','..#..','..#..','..#..','..#..'],
};
function muralTexture(){
const c = document.createElement('canvas'); c.width = 1024; c.height = 600;
const g = c.getContext('2d');
g.fillStyle = '#efe6d2'; g.fillRect(0,0,1024,600);
g.fillStyle = '#9fd3ef'; g.fillRect(0,0,1024,190);
g.fillStyle = '#ffffff';
[[120,60,120,26],[300,96,90,20],[760,54,140,28]].forEach(c2=>g.fillRect(c2[0],c2[1],c2[2],c2[3]));
const cols = ['#e63946','#f9c74f','#2a9d8f','#e76f51','#4cc9f0','#f72585','#43aa8b','#264653'];
const word = 'CAMINITO';
const px = 21, sx = 26, sy = 210;
for(let li=0; li<word.length; li++){
const glyph = PIXFONT[word[li]];
g.fillStyle = cols[li % cols.length];
for(let r=0;r<glyph.length;r++)
for(let q=0;q<glyph[r].length;q++)
if(glyph[r][q] === '#') g.fillRect(sx + li*6*px + q*px, sy + r*px, px, px);
}
g.fillStyle = 'rgba(240,235,220,.75)'; g.fillRect(0,395,1024,205);
const hs = ['#e63946','#2a9d8f','#f9c74f','#4cc9f0','#e76f51','#43aa8b'];
for(let i=0;i<6;i++){ g.fillStyle = hs[i]; g.fillRect(30+i*165, 430, 120, 95); }
g.fillStyle = 'rgba(60,50,45,.55)';
for(let i=0;i<6;i++) g.fillRect(58+i*165, 452, 24, 30);
g.fillStyle = '#3a3229'; g.font = 'bold 40px monospace';
g.textAlign = 'center'; g.fillText('LA BOCA · BUENOS AIRES', 512, 570);
const t = new THREE.CanvasTexture(c); t.colorSpace = THREE.SRGBColorSpace;
t.anisotropy = renderer.capabilities.getMaxAnisotropy();
return t;
}
/* ============================================================
STREET
============================================================ */
const ROW_X0 = -13.6, ROW_W = 27.0;
box(160,0.2,160, 0,-0.42,0, '#57544f'); // road
box(ROW_W+6,0.32,2.9, -0.6,-0.16,1.35, '#9b958a'); // sidewalk slab
box(ROW_W+6,0.42,0.3, -0.6,-0.13,2.85, '#77736b'); // curb
const walk = new THREE.Mesh(new THREE.PlaneGeometry(ROW_W+4, 2.7),
new THREE.MeshLambertMaterial({map: pavementTexture()}));
walk.rotation.x = -Math.PI/2; walk.position.set(-0.6, 0.012, 1.35);
walk.receiveShadow = true; scene.add(walk);
/* background block silhouettes */
const bgCols = ['#8d94a3','#7d8798','#98a0ae','#6f7787'];
for(let i=0;i<9;i++){
const w = 4+Math.random()*6, h = 7+Math.random()*11;
const m = box(w,h,6, -34 + i*8.5 + Math.random()*2, h/2-0.4, -17-Math.random()*7,
bgCols[i%bgCols.length]);
m.castShadow = false;
}
/* ============================================================
HOUSES
============================================================ */
const HOUSES = [
{w:4.6, h:8.0, d:5.0, color:'#E63946', trim:'#F1FAEE'},
{w:4.2, h:9.2, d:5.0, color:'#2A9D8F', trim:'#F9C74F'},
{w:4.0, h:7.6, d:4.6, color:'#F9C74F', trim:'#264653'},
{w:4.8, h:10.4,d:5.2, color:'#f2efe6', trim:'#1f4e79', stripe:'#2b6cb0', rib:0.95},
{w:5.0, h:8.6, d:5.0, color:'#E76F51', trim:'#264653'},
{w:4.4, h:9.0, d:4.8, color:'#43AA8B', trim:'#F4D35E'},
];
const BALCONY_HOUSES = new Set([0,1,3,4]);
let cursor = ROW_X0;
const houseX = [];
HOUSES.forEach((s,i)=>{ houseX.push(cursor); cursor += s.w; });
/* --- window --- */
function addWindow(px, by, w, h, trim, flower){
const cy = by + h/2;
box(w,h,0.07, px, cy, 0.10, '#22303c'); // glass
box(w-0.22,h-0.22,0.05, px, cy, 0.14, '#3d5a72', {emissive:'#16232e', emissiveIntensity:0.4});
box(w+0.16,0.14,0.20, px, by+h+0.07, 0.13, trim); // lintel
box(w+0.16,0.14,0.20, px, by-0.07, 0.13, trim); // sill
box(0.10,h,0.16, px-w/2-0.05, cy, 0.13, trim); // jambs
box(0.10,h,0.16, px+w/2+0.05, cy, 0.13, trim);
box(0.07,h-0.1,0.10, px, cy, 0.17, trim); // mullion
const sh = trim;
const s1 = box(w/2-0.04, h-0.05, 0.07, px-w/2-0.10, cy, 0.30, sh);
s1.rotation.y = -0.55;
const s2 = box(w/2-0.04, h-0.05, 0.07, px+w/2+0.10, cy, 0.30, sh);
s2.rotation.y = 0.55;
if(flower){
box(w+0.10,0.16,0.30, px, by-0.14, 0.28, '#8a5a3b');
for(let i=0;i<4;i++) box(0.20,0.20,0.22, px-w/2+0.12+i*(w-0.2)/3, by-0.02, 0.30, '#3f7d3a');
for(let i=0;i<3;i++) box(0.13,0.13,0.13, px-w/2+0.2+i*(w-0.3)/2, by+0.06, 0.30, ['#e63946','#f9c74f','#f72585'][i]);
}
}
/* --- french door onto balcony --- */
function addFrenchDoor(px, by, w, h, trim){
box(w+0.22,0.16,0.22, px, by+h+0.08, 0.14, trim);
box(0.14,h+0.1,0.22, px-w/2-0.07, by+h/2, 0.14, trim);
box(0.14,h+0.1,0.22, px+w/2+0.07, by+h/2, 0.14, trim);
for(const s of [-1,1]){
const cx = px + s*w/4;
box(w/2-0.03, h, 0.08, cx, by+h/2, 0.06, trim);
box(w/2-0.28, h-0.35, 0.05, cx, by+h/2, 0.10, '#3d5a72', {emissive:'#16232e', emissiveIntensity:0.35});
}
box(w, 0.10, 0.30, px, by-0.03, 0.20, trim);
}
/* --- separate ground-floor entrance --- */
function addDoor(i, px, s){
const w = 1.16, h = 2.26, y0 = 0.30;
const doorCol = ['#2b6cb0','#e63946','#43aa8b','#f9c74f','#264653','#e76f51'][i % 6];
box(w+0.34,0.16,0.26, px, y0+h+0.08, 0.15, s.trim); // lintel
box(0.16,h+0.1,0.26, px-w/2-0.08, y0+h/2, 0.15, s.trim); // jambs
box(0.16,h+0.1,0.26, px+w/2+0.08, y0+h/2, 0.15, s.trim);
box(w, h, 0.10, px, y0+h/2, 0.03, doorCol); // door leaf
box(w-0.26, h*0.42, 0.05, px, y0+h*0.30, 0.09, shade(doorCol,-0.10));
box(w-0.26, h*0.30, 0.05, px, y0+h*0.73, 0.09, shade(doorCol,-0.10));
box(0.09,0.09,0.12, px+w/2-0.18, y0+1.05, 0.10, '#e8c46a'); // knob
// steps
box(w+0.5,0.30,0.34, px, 0.15, 0.30, '#cfc8b8');
box(w+0.7,0.18,0.34, px, 0.09, 0.62, '#c4bcaa');
box(w+0.9,0.07,0.34, px, 0.035,0.94, '#b9b1a0');
// house number
const plate = new THREE.Mesh(new THREE.PlaneGeometry(0.34,0.34),
new THREE.MeshLambertMaterial({map: numberPlate(i+1)}));
plate.position.set(px, y0+h+0.45, 0.30); scene.add(plate);
// little lamp
const lamp = box(0.26,0.20,0.22, px, y0+h+0.42, 0.36, '#fff0c2',
{emissive:'#ffca6b', emissiveIntensity:0.9});
lamp.castShadow = false;
box(0.10,0.14,0.12, px, y0+h+0.56, 0.36, '#3a3a3a');
}
function shade(hex, amt){
const c = new THREE.Color(hex); c.offsetHSL(0,0,amt); return '#'+c.getHexString();
}
/* --- shared balcony --- */
function addBalcony(x0, x1, y, dividerX){
const depth = 1.32, xm = (x0+x1)/2, w = x1-x0;
box(w+0.22, 0.18, depth, xm, y-0.09, depth/2, '#ded7c6'); // slab
box(w+0.22, 0.10, 0.12, xm, y-0.20, depth-0.02, '#c9c1b0'); // front fascia
for(let bx = x0+0.7; bx < x1-0.3; bx += 1.45){ // brackets
const b = box(0.13,1.0,0.13, bx, y-0.62, depth-0.42, '#3b3f46');
b.rotation.x = -0.62;
}
const IRON = '#23272e';
// front railing
const n = Math.max(6, Math.floor(w/0.30));
const bars = new THREE.InstancedMesh(new THREE.BoxGeometry(0.055,1.02,0.055), M(IRON), n);
bars.castShadow = true;
for(let i=0;i<n;i++){
_dummy.position.set(x0+0.16 + i*(w-0.32)/(n-1), y+0.58, depth);
_dummy.rotation.set(0,0,0); _dummy.scale.set(1,1,1); _dummy.updateMatrix();
bars.setMatrixAt(i, _dummy.matrix);
}
bars.instanceMatrix.needsUpdate = true; scene.add(bars);
box(w+0.22,0.10,0.10, xm, y+1.16, depth, IRON); // top rail
box(w+0.22,0.07,0.09, xm, y+0.14, depth, IRON); // bottom rail
box(w+0.22,0.06,0.08, xm, y+0.62, depth, IRON); // mid rail
// ornament squares on top rail
for(let ox = x0+0.45; ox < x1; ox += 0.62)
box(0.13,0.13,0.13, ox, y+1.28, depth, IRON);
// side railings
for(const sx of [x0, x1]){
const m = Math.max(3, Math.floor(depth/0.30));
const sb = new THREE.InstancedMesh(new THREE.BoxGeometry(0.055,1.02,0.055), M(IRON), m);
for(let i=0;i<m;i++){
_dummy.position.set(sx, y+0.58, 0.14 + i*(depth-0.28)/(m-1));
_dummy.rotation.set(0,0,0); _dummy.scale.set(1,1,1); _dummy.updateMatrix();
sb.setMatrixAt(i, _dummy.matrix);
}
sb.instanceMatrix.needsUpdate = true; sb.castShadow = true; scene.add(sb);
box(0.10,0.10,depth+0.12, sx, y+1.16, depth/2, IRON);
box(0.10,0.07,depth+0.12, sx, y+0.14, depth/2, IRON);
}
// divider post between the two dwellings
if(dividerX !== undefined){
box(0.11,1.30,0.11, dividerX, y+0.60, depth, IRON);
box(0.14,0.14,0.14, dividerX, y+1.30, depth, IRON);
}
// pots
for(const p of [[x0+0.7, depth-0.32], [x1-0.6, depth-0.30], [xm+0.9, depth-0.34]]){
box(0.44,0.30,0.44, p[0], y+0.24, p[1], '#b4593c');
box(0.52,0.42,0.52, p[0], y+0.58, p[1], '#3f7d3a');
box(0.28,0.30,0.28, p[0]+0.12, y+0.88, p[1]-0.05, '#4e9a44');
}
}
/* --- clothesline --- */
function clothesline(x0, x1, y, z, colors){
const n = 22, seg = (x1-x0)/n;
for(let i=0;i<n;i++){
const t = i/n, xx = x0 + seg*(i+0.5);
const yy = y - 0.30*Math.sin(Math.PI*t);
box(seg*1.05,0.035,0.035, xx, yy, z, '#3a3a3a');
}
const picks = [0.12,0.28,0.44,0.62,0.80];
picks.forEach((t,k)=>{
const xx = x0 + (x1-x0)*t;
const yy = y - 0.30*Math.sin(Math.PI*t);
const cw = 0.42 + (k%3)*0.12;
box(cw,0.62,0.07, xx, yy-0.34, z, colors[k%colors.length]);
box(cw*0.4,0.16,0.09, xx, yy-0.02, z, colors[(k+2)%colors.length]);
});
}
/* --- pots / crates / lamp post --- */
function streetLamp(x, z){
box(0.46,0.22,0.46, x, 0.11, z, '#4a4a4a');
box(0.14,3.6,0.14, x, 1.9, z, '#3d4147');
box(0.14,0.14,0.9, x, 3.66, z+0.45, '#3d4147');
box(0.46,0.26,0.46, x, 3.50, z+0.88, '#fff2c6', {emissive:'#ffc96b', emissiveIntensity:1.1});
const l = new THREE.PointLight(0xffc976, 1.1, 13, 2);
l.position.set(x, 3.3, z+0.88); scene.add(l);
}
function sidewalkPot(x, z){
box(0.56,0.5,0.56, x, 0.25, z, '#b4593c');
box(0.68,0.5,0.68, x, 0.66, z, '#3f7d3a');
box(0.36,0.34,0.36, x+0.1, 1.0, z-0.05, '#4e9a44');
}
/* ============================================================
BUILD THE ROW
============================================================ */
HOUSES.forEach((s, i) => {
const x0 = houseX[i], cx = x0 + s.w/2;
/* corrugated front facade */
corrugated(s.w, s.h, s.color, cx, s.h/2, 0, 0, s.stripe, s.rib);
/* side walls (solid plaster/iron) */
const side = shade(s.color, -0.06);
box(0.16, s.h, s.d, x0+0.08, s.h/2, -s.d/2, side);
box(0.16, s.h, s.d, x0+s.w-0.08, s.h/2, -s.d/2, side);
/* floor trim bands */
box(s.w, 0.16, 0.30, cx, 2.92, 0.14, s.trim);
box(s.w, 0.12, 0.26, cx, 5.90, 0.12, s.trim);
/* roof */
box(s.w+0.34, 0.22, s.d+0.34, cx, s.h+0.11, -s.d/2, '#8f8578');
box(s.w+0.34, 0.55, 0.16, cx, s.h+0.45, -0.08, s.trim);
box(s.w+0.34, 0.55, 0.16, cx, s.h+0.45, -s.d-0.08, s.trim);
box(0.16, 0.55, s.d+0.34, x0-0.05, s.h+0.45, -s.d/2, s.trim);
box(0.16, 0.55, s.d+0.34, x0+s.w+0.05, s.h+0.45, -s.d/2, s.trim);
/* water tanks */
if(i % 2 === 0){
box(1.05,0.85,1.05, cx+0.9, s.h+0.65, -s.d+0.9, '#3d5a80');
box(1.15,0.14,1.15, cx+0.9, s.h+1.12, -s.d+0.9, '#2c4460');
}
/* separate entrance */
const doorOff = (i % 2 === 0) ? 0.30 : 0.70;
addDoor(i, x0 + s.w*doorOff, s);
/* small ground-floor window next to the door */
const wpos = x0 + s.w*(doorOff < 0.5 ? 0.74 : 0.26);
addWindow(wpos, 0.85, 0.95, 1.15, s.trim, true);
/* upper storeys */
const rows = [3.42, 6.10, 8.80];
rows.forEach((r, ri) => {
if(r + 1.55 > s.h + 0.05) return;
if(ri === 0 && BALCONY_HOUSES.has(i)){
addFrenchDoor(cx - 0.0, r, 1.5, 2.2, s.trim);
} else {
const two = s.w >= 4.5;
const yy = r + (ri === 0 ? 0.42 : 0.75);
if(two){
addWindow(cx - s.w*0.24, yy, 1.25, 1.35, s.trim, ri === 1 && i%2===0);
addWindow(cx + s.w*0.24, yy, 1.25, 1.35, s.trim, false);
} else {
addWindow(cx, yy, 1.45, 1.4, s.trim, ri === 1);
}
}
});
/* laundry hanging out of an upper window */
if(i % 2 === 1){
box(0.06,0.06,0.9, cx+0.3, s.h-0.9, 0.55, '#555');
}
});
/* --- shared balconies (pairs of dwellings) --- */
addBalcony(houseX[0], houseX[1]+HOUSES[0].w, 3.42, houseX[1]);
addBalcony(houseX[3], houseX[4]+HOUSES[3].w, 3.42, houseX[4]);
/* --- clotheslines across the alley --- */
clothesline(houseX[1]+HOUSES[0].w-0.4, houseX[2], 5.05, 0.75,
['#f9c74f','#e63946','#4cc9f0','#f2f2f2','#2a9d8f']);
clothesline(houseX[2]+HOUSES[1].w-0.4, houseX[3]-0.2, 6.40, 0.55,
['#f72585','#ffd166','#2b6cb0','#f2f2f2','#e76f51']);
/* --- Boca flag on the striped house --- */
{
const s = HOUSES[3], x = houseX[3] + s.w - 0.7;
box(0.09, 2.6, 0.09, x, 7.6, 0.45, '#7a6a55');
box(0.55, 0.95, 0.06, x+0.30, 6.95, 0.47, '#1f5fa8');
box(0.55, 0.95, 0.06, x+0.86, 6.95, 0.47, '#ffd166');
}
/* --- Chacarita-style tower on the striped house --- */
{
const s = HOUSES[3], cx = houseX[3] + s.w/2;
box(1.7, 2.3, 1.7, cx-0.7, s.h+1.35, -s.d+1.1, '#f2efe6');
box(1.78, 0.26, 1.78, cx-0.7, s.h+2.05, -s.d+1.1, '#2b6cb0');
box(0.08, 1.7, 0.08, cx-0.7, s.h+3.1, -s.d+1.1, '#6b5b46');
box(0.55, 0.34, 0.05, cx-0.42, s.h+3.75, -s.d+1.1, '#e63946');
}
/* --- CAMINITO mural on the gable end wall --- */
{
const s = HOUSES[0];
box(0.20, s.h, s.d, houseX[0]+0.06, s.h/2, -s.d/2, '#efe3cc');
const mural = new THREE.Mesh(new THREE.PlaneGeometry(4.4, 2.6),
new THREE.MeshLambertMaterial({map: muralTexture()}));
mural.rotation.y = -Math.PI/2;
mural.position.set(houseX[0]-0.05, 5.0, -s.d/2);
mural.receiveShadow = true; scene.add(mural);
}
/* --- street sign --- */
{
const s = HOUSES[5], cx = houseX[5] + s.w/2;
const sign = new THREE.Mesh(new THREE.PlaneGeometry(1.5, 0.375),
new THREE.MeshLambertMaterial({map: signTexture('CAMINITO','#123a6b','#f2e9d8')}));
sign.position.set(cx, 1.55, 0.30); scene.add(sign);
}
/* --- street furniture --- */
streetLamp(-12.4, 3.4);
streetLamp(11.6, 3.4);
sidewalkPot(-6.4, 2.1);
sidewalkPot(6.2, 2.15);
for(let i=0;i<5;i++){
box(0.5,0.42,0.5, 2.6+i*0.55, 0.21, 2.2, i%2 ? '#c47f4a' : '#a5673c');
}
box(0.9,0.9,0.9, 14.6, 0.45, 2.2, '#4a7f52');
/* --- a little vintage Boca car --- */
{
const cx = 6.5, cz = 4.6;
box(3.2,0.75,1.5, cx, 0.72, cz, '#1f5fa8');
box(3.24,0.22,1.54, cx, 0.72, cz, '#ffd166');
box(1.7,0.70,1.35, cx-0.2, 1.42, cz, '#2a74c4');
box(1.55,0.42,1.40, cx-0.2, 1.42, cz, '#22303c');
box(0.9,0.10,1.40, cx-0.2, 1.80, cz, '#ffd166');
for(const dx of [-1.05, 1.05]) for(const dz of [-0.78, 0.78])
box(0.62,0.62,0.30, cx+dx, 0.32, cz+dz, '#1b1b1e');
box(0.22,0.14,0.10, cx+1.62, 0.85, cz-0.45, '#fff3c4');
box(0.22,0.14,0.10, cx+1.62, 0.85, cz+0.45, '#fff3c4');
}
/* ============================================================
CAMERA CONTROLS (hand rolled — no addons)
============================================================ */
const goal = { theta: 0.34, phi: 1.14, radius: 34, target: new THREE.Vector3(-0.6, 4.2, 0.0) };
const cur = { theta: 0.34, phi: 1.14, radius: 34, target: new THREE.Vector3(-0.6, 4.2, 0.0) };
let idleTime = 0;
const pointers = new Map();
let mode = null, lastX = 0, lastY = 0, pinch = 0;
function orbit(dx, dy){
goal.theta -= dx * 0.0055;
goal.phi = Math.max(0.22, Math.min(1.50, goal.phi - dy * 0.0045));
}
function pan(dx, dy){
const right = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 0);
const up = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 1);
const k = goal.radius * 0.0016;
goal.target.addScaledVector(right, -dx * k).addScaledVector(up, dy * k);
goal.target.y = Math.max(1.0, Math.min(12.0, goal.target.y));
}
function pinchDist(){
const p = [...pointers.values()];
return Math.hypot(p[0].x-p[1].x, p[0].y-p[1].y);
}
canvas.addEventListener('contextmenu', e => e.preventDefault());
canvas.addEventListener('pointerdown', e => {
canvas.setPointerCapture(e.pointerId);
pointers.set(e.pointerId, {x:e.clientX, y:e.clientY});
idleTime = 0;
if(pointers.size === 1){
mode = (e.button === 2 || e.shiftKey) ? 'pan' : 'orbit';
lastX = e.clientX; lastY = e.clientY;
} else if(pointers.size === 2){
mode = 'pinch'; pinch = pinchDist();
}
});
canvas.addEventListener('pointermove', e => {
if(!pointers.has(e.pointerId)) return;
pointers.set(e.pointerId, {x:e.clientX, y:e.clientY});
idleTime = 0;
if(mode === 'orbit'){ orbit(e.clientX-lastX, e.clientY-lastY); lastX = e.clientX; lastY = e.clientY; }
else if(mode === 'pan'){ pan(e.clientX-lastX, e.clientY-lastY); lastX = e.clientX; lastY = e.clientY; }
else if(mode === 'pinch' && pointers.size === 2){
const d = pinchDist();
goal.radius = Math.max(9, Math.min(70, goal.radius * (pinch / Math.max(d, 1))));
pinch = d;
}
});
function release(e){
pointers.delete(e.pointerId);
if(pointers.size === 0) mode = null;
else if(pointers.size === 1){ mode = 'orbit'; const p = [...pointers.values()][0]; lastX = p.x; lastY = p.y; }
}
canvas.addEventListener('pointerup', release);
canvas.addEventListener('pointercancel', release);
canvas.addEventListener('pointerleave', e => { if(!e.buttons) release(e); });
canvas.addEventListener('wheel', e => {
e.preventDefault(); idleTime = 0;
goal.radius = Math.max(9, Math.min(70, goal.radius * Math.exp(e.deltaY * 0.0011)));
}, {passive:false});
window.addEventListener('keydown', e => {
idleTime = 0;
if(e.key === 'ArrowLeft') goal.theta += 0.12;
if(e.key === 'ArrowRight') goal.theta -= 0.12;
if(e.key === 'ArrowUp') goal.phi = Math.max(0.22, goal.phi - 0.08);
if(e.key === 'ArrowDown') goal.phi = Math.min(1.50, goal.phi + 0.08);
if(e.key === '+' || e.key === '=') goal.radius = Math.max(9, goal.radius * 0.9);
if(e.key === '-' || e.key === '_') goal.radius = Math.min(70, goal.radius * 1.1);
});
function updateCamera(dt){
const k = Math.min(1, dt * 9);
cur.theta += (goal.theta - cur.theta) * k;
cur.phi += (goal.phi - cur.phi) * k;
cur.radius+= (goal.radius- cur.radius)* k;
cur.target.lerp(goal.target, k);
const sp = Math.sin(cur.phi), cp = Math.cos(cur.phi);
camera.position.set(
cur.target.x + cur.radius * sp * Math.sin(cur.theta),
cur.target.y + cur.radius * cp,
cur.target.z + cur.radius * sp * Math.cos(cur.theta)
);
camera.lookAt(cur.target);
}
/* ============================================================
LOOP
============================================================ */
window.addEventListener('resize', () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
});
const clock = new THREE.Clock();
function animate(){
requestAnimationFrame(animate);
const dt = Math.min(0.05, clock.getDelta());
idleTime += dt;
if(idleTime > 4.5) goal.theta += dt * 0.055; // slow idle drift
updateCamera(dt);
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```