Prompt specification
Build or customize the Three.js 3D scene "Coffee-service corner beside an Addis street" 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: Coffee-service corner beside an Addis street
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/coffee-service-corner-beside-an-addis-street-x2886
Scene Description Prompt:
A voxel coffee-service corner beside an Addis Ababa Piazza street, with customers and passing pedestrians. Build one HTML file using Three.js from cdnjs.
Working Three.js Starter (coffee-service-corner-beside-an-addis-street-x2886):
```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>Voxel Coffee Corner — Piazza, Addis Ababa</title>
<style>
html,body{margin:0;height:100%;background:#0d1116;overflow:hidden;
font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;}
#app{position:fixed;inset:0}
canvas{display:block;touch-action:none}
.panel{
position:fixed;left:14px;top:14px;width:288px;color:#f3efe6;
background:rgba(16,20,26,.74);backdrop-filter:blur(8px);
border:1px solid rgba(255,255,255,.13);border-radius:14px;overflow:hidden;
box-shadow:0 10px 30px rgba(0,0,0,.35);pointer-events:auto;
}
.flagbar{height:6px;background:linear-gradient(90deg,#0f7a3d 0 33%,#f4d03f 33% 66%,#d0342c 66% 100%)}
.inner{padding:13px 15px 14px}
h1{margin:0 0 2px;font-size:15px;letter-spacing:.2px}
.sub{font-size:11.5px;color:#a9b6c4;margin-bottom:10px}
.amharic{font-size:13px;color:#f4d03f;margin-bottom:9px}
.btns{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:10px}
button{
flex:1 1 auto;min-width:84px;padding:7px 8px;font-size:11.5px;color:#f3efe6;
background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.16);
border-radius:8px;cursor:pointer;transition:.15s}
button:hover{background:rgba(244,208,63,.18);border-color:#f4d03f}
button.on{background:#f4d03f;color:#1a1a1a;border-color:#f4d03f;font-weight:600}
.hint{font-size:11px;color:#8e9bab;line-height:1.55;border-top:1px solid rgba(255,255,255,.1);padding-top:9px}
kbd{background:rgba(255,255,255,.12);border-radius:4px;padding:1px 5px;font-size:10.5px}
#legend{position:fixed;right:14px;bottom:14px;font-size:11px;color:#b9c4d0;
background:rgba(16,20,26,.6);backdrop-filter:blur(6px);padding:9px 12px;border-radius:10px;
border:1px solid rgba(255,255,255,.1);line-height:1.6;text-align:right}
#legend b{color:#f4d03f;font-weight:600}
</style>
</head>
<body>
<div id="app"></div>
<div class="panel">
<div class="flagbar"></div>
<div class="inner">
<h1>☕ Voxel Coffee Corner</h1>
<div class="sub">Piazza corner · Addis Ababa · Ethiopia</div>
<div class="amharic">ቡና ጉራር — ባህር ብር</div>
<div class="btns">
<button id="btnNight">🌙 Evening</button>
<button id="btnOrbit" class="on">🔄 Auto orbit</button>
<button id="btnReset">⌂ Reset view</button>
</div>
<div class="hint">
<kbd>Drag</kbd> orbit <kbd>Wheel</kbd> zoom <kbd>Shift+drag</kbd> / right-drag pan<br>
<kbd>←→</kbd> keys rotate <kbd>+ / −</kbd> keys zoom
</div>
</div>
</div>
<div id="legend"><b>Blue & white minibus</b> · coffee ceremony · jacaranda trees<br>Piazza Hotel · Trinity dome · ብር exchange</div>
<script type="module">
import * as THREE from 'https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js';
/* ============================================================
0. Core setup
============================================================ */
const app = document.getElementById('app');
const renderer = new THREE.WebGLRenderer({ antialias:true, powerPreference:'high-performance' });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
app.appendChild(renderer.domElement);
const scene = new THREE.Scene();
const DAY_BG = new THREE.Color('#bcd9ef');
const NIGHT_BG = new THREE.Color('#101a2c');
scene.background = DAY_BG.clone();
scene.fog = new THREE.Fog(DAY_BG.clone(), 70, 235);
const camera = new THREE.PerspectiveCamera(48, innerWidth/innerHeight, 0.1, 500);
scene.add(camera);
const hemi = new THREE.HemisphereLight(0xbfe3ff, 0x8d8467, 1.0);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff2d0, 2.3);
sun.position.set(42, 58, -34);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -70; sun.shadow.camera.right = 70;
sun.shadow.camera.top = 70; sun.shadow.camera.bottom = -70;
sun.shadow.camera.near = 1; sun.shadow.camera.far = 220;
sun.shadow.bias = -0.0006;
sun.shadow.normalBias = 0.03;
scene.add(sun);
/* ============================================================
1. Voxel helpers
============================================================ */
const UNIT = new THREE.BoxGeometry(1,1,1);
const matCache = new Map();
function mat(color, extra={}){
const key = color + JSON.stringify(extra);
if(!matCache.has(key)) matCache.set(key, new THREE.MeshLambertMaterial({ color, ...extra }));
return matCache.get(key);
}
function box(parent, w,h,d, color, x,y,z, o={}){
let m;
if(o.basic) m = new THREE.Mesh(UNIT, new THREE.MeshBasicMaterial({ color, transparent:!!o.transparent, opacity:o.opacity??1 }));
else m = new THREE.Mesh(UNIT, mat(color, o.mat||{}));
m.scale.set(w,h,d);
m.position.set(x,y,z);
if(o.rot) m.rotation.set(o.rot[0]||0, o.rot[1]||0, o.rot[2]||0);
m.castShadow = o.cast !== false;
m.receiveShadow = o.recv !== false;
(parent||scene).add(m);
return m;
}
function instanced(items, material, parent){
const im = new THREE.InstancedMesh(UNIT, material, items.length);
const m4 = new THREE.Matrix4(), q = new THREE.Quaternion(), s = new THREE.Vector3(), p = new THREE.Vector3();
const e = new THREE.Euler();
items.forEach((it,i)=>{
p.set(it.x, it.y, it.z);
s.set(it.w, it.h, it.d);
e.set(it.rx||0, it.ry||0, it.rz||0); q.setFromEuler(e);
m4.compose(p,q,s); im.setMatrixAt(i,m4);
if(it.c){ im.setColorAt(i, new THREE.Color(it.c)); }
});
im.castShadow = true; im.receiveShadow = true;
im.instanceMatrix.needsUpdate = true;
if(im.instanceColor) im.instanceColor.needsUpdate = true;
(parent||scene).add(im);
return im;
}
function pave(x0,x1,z0,z1,step,base,top=0.30){
const items=[];
for(let x=x0;x<x1-0.01;x+=step)
for(let z=z0;z<z1-0.01;z+=step){
const c = new THREE.Color(base).offsetHSL((Math.random()-.5)*.02,(Math.random()-.5)*.04,(Math.random()-.5)*.07);
items.push({x:x+step/2, y:top+0.03, z:z+step/2, w:step-0.07, h:0.06, d:step-0.07, c});
}
return instanced(items, mat('#ffffff'));
}
function canvasTex(w,h,draw){
const c=document.createElement('canvas'); c.width=w; c.height=h;
draw(c.getContext('2d'),w,h);
const t=new THREE.CanvasTexture(c);
t.colorSpace = THREE.SRGBColorSpace;
t.anisotropy = 4;
return t;
}
function signPlane(parent, o){
const tex = canvasTex(o.wpx||512, o.hpx||128, (ctx,w,h)=>{
ctx.fillStyle = o.bg||'#1d2b23'; ctx.fillRect(0,0,w,h);
if(o.border){ ctx.strokeStyle=o.border; ctx.lineWidth=6; ctx.strokeRect(4,4,w-8,h-8); }
ctx.fillStyle = o.fg||'#f4d03f';
ctx.textAlign='center'; ctx.textBaseline='middle';
ctx.font = `bold ${o.font||44}px ui-monospace, Menlo, Consolas, monospace`;
ctx.fillText(o.text, w/2, o.sub ? h*0.38 : h/2);
if(o.sub){ ctx.font=`${Math.round((o.font||44)*0.42)}px ui-monospace, monospace`; ctx.fillStyle=o.subFg||'#e8e3d5'; ctx.fillText(o.sub, w/2, h*0.72); }
});
const m = new THREE.Mesh(new THREE.PlaneGeometry(o.w,o.h), new THREE.MeshBasicMaterial({map:tex}));
m.position.set(o.x||0,o.y||0,o.z||0);
m.rotation.y = o.ry||0;
parent.add(m);
return m;
}
/* ============================================================
2. Terrain, streets, pavements
============================================================ */
box(scene, 220,0.4,220, '#7d8b63', 0,-0.25,15); // earth
box(scene, 170,0.14,10, '#494a53', 0,-0.05,-8); // Piazza street asphalt
box(scene, 170,0.32,6, '#cdc5b4', 0,0.14,0); // main sidewalk
box(scene, 61,0.32,42, '#c6bda9', 16.5,0.14,24); // plaza square
box(scene, 6,0.32,24, '#cdc5b4', -17,0.14,15); // corner sidewalk (side st.)
box(scene, 5,0.32,24, '#cdc5b4', -32.5,0.14,15); // west sidewalk
box(scene, 10,0.14,30, '#494a53', -25,-0.05,12); // side street asphalt
// paving detail
pave(-70,70,-3,3,2.4,'#cdc5b4');
pave(-14,47,3,45,2.6,'#c6bda9');
pave(-20,-14,3,27,2.0,'#cdc5b4');
pave(-35,-30,3,27,2.0,'#cdc5b4');
// curbs
box(scene,170,0.34,0.3,'#e3dccb',0,0.13,-3.0);
box(scene,170,0.34,0.3,'#e3dccb',0,0.13,-13.0);
box(scene,0.3,0.34,30,'#e3dccb',-30.0,0.13,12);
box(scene,0.3,0.34,30,'#e3dccb',-20.0,0.13,12);
// road markings
const dashes=[]; for(let x=-80;x<80;x+=6) dashes.push({x, y:0.035, z:-8, w:3, h:0.03, d:0.28});
instanced(dashes, mat('#e8e6dd'));
// crosswalk at the corner
const cw=[]; for(let z=-12.4;z<-3.4;z+=1.3) cw.push({x:-25, y:0.035, z, w:5.4, h:0.03, d:0.7});
instanced(cw, mat('#f0eee6'));
/* ============================================================
3. Buildings around the piazza
============================================================ */
// --- Piazza Hotel ---
const hotel = new THREE.Group(); hotel.position.set(-8,0,-21); scene.add(hotel);
box(hotel,21,1.1,17,'#b9a884',0,0.55,0);
box(hotel,20,13,16,'#d9c9a8',0,7.0,0);
box(hotel,21.4,0.8,17.4,'#c4ab83',0,13.8,0);
box(hotel,20.6,0.5,16.6,'#efe2c4',0,13.2,0);
const winMat = new THREE.MeshLambertMaterial({color:'#33404f', emissive:'#ffb95e', emissiveIntensity:0});
const winItems=[];
for(let r=0;r<4;r++) for(let i=0;i<7;i++){
const x=-8.4+i*2.8, y=2.6+r*2.9;
winItems.push({x, y, z:8.05, w:1.5, h:2.0, d:0.35});
winItems.push({x, y:y+1.15, z:8.05, w:1.0, h:0.45, d:0.35});
}
instanced(winItems, winMat, hotel);
// balconies
for(let r=1;r<4;r+=2){
box(hotel,19.6,0.28,1.4,'#efe2c4',0,1.9+r*2.9,8.4);
const rail=[]; for(let i=0;i<26;i++) rail.push({x:-9.4+i*0.75,y:2.5+r*2.9,z:9.05,w:0.09,h:1.0,d:0.09});
instanced(rail, mat('#b6a481'), hotel);
}
signPlane(hotel,{text:'PIAZZA HOTEL', sub:'መሐል እድሪ', w:9,h:2.0,x:0,y:12.0,z:8.3, bg:'#20302a', fg:'#f4d03f', font:52});
// --- shop row ---
const shops = [
{x:12, w:12, h:8.5, c:'#c96f4a', sign:'SHIRTA', sub:'ሻርታ'},
{x:25, w:12, h:10.5,c:'#7aa7a0', sign:'BIRR FX', sub:'ብር ልውዋጥ'},
{x:38, w:12, h:9, c:'#e0b355', sign:'JUICE BAR', sub:'ሻይዝ'},
];
for(const s of shops){
const g=new THREE.Group(); g.position.set(s.x,0,-19); scene.add(g);
box(g,s.w,s.h,13,s.c,0,s.h/2,0);
box(g,s.w+0.6,0.6,13.6,'#7b6a58',0,s.h+0.2,0);
const wi=[]; for(let r=0;r<2;r++) for(let i=0;i<4;i++) wi.push({x:-s.w/2+1.7+i*2.9,y:4.6+r*3.0,z:6.55,w:1.5,h:1.9,d:0.3});
instanced(wi, winMat, g);
// storefront
box(g,s.w-1.2,2.6,0.3,'#2e3a44',0,1.6,6.6);
// striped awning
for(let i=0;i<12;i++){
const col = i%2 ? '#f3eee0' : (s.sign==='BIRR FX'?'#2f6fa0':'#2f7a4d');
box(g,s.w/12,0.16,1.5,col,-s.w/2+s.w/24+i*(s.w/12),3.3,7.2,{rot:[-0.22,0,0]});
}
signPlane(g,{text:s.sign, sub:s.sub, w:s.w-2,h:1.5,x:0,y:4.4,z:6.75,bg:'#1b2430',fg:'#f4d03f',font:44});
}
// --- west block along the side street ---
for(let i=0;i<3;i++){
const g=new THREE.Group(); g.position.set(-40,0,2+i*9); scene.add(g);
const cols=['#b98f68','#8e9c7a','#a9685a'];
box(g,10,9+i*1.5,8,cols[i],0,(9+i*1.5)/2,0);
box(g,10.6,0.5,8.6,'#6e5f50',0,9+i*1.5+0.2,0);
const wi=[]; for(let r=0;r<3;r++) for(let j=0;j<3;j++) wi.push({x:-2.6+j*2.6,y:2.2+r*2.7,z:4.05,w:1.2,h:1.6,d:0.3});
instanced(wi, winMat, g);
}
/* ============================================================
4. Piazza square: cathedral, monument, trees, benches
============================================================ */
// --- Holy Trinity style cathedral ---
const cath=new THREE.Group(); cath.position.set(22,0,35); scene.add(cath);
box(cath,17,9,12,'#efe8d8',0,4.5,0);
box(cath,18,0.7,13,'#d9d0bb',0,9.2,0);
box(cath,9,12,9,'#efe8d8',0,6,1.5);
box(cath,10,0.7,10,'#d9d0bb',0,12.2,1.5);
// stepped dome
for(let i=0;i<6;i++) box(cath,9-i*1.35,0.75,9-i*1.35,i%2?'#3f6f8f':'#4b7d9c',0,12.6+i*0.72,1.5);
box(cath,0.5,2.4,0.5,'#e8c96a',0,17.6,1.5);
box(cath,1.6,0.45,0.45,'#e8c96a',0,17.8,1.5);
const cw2=[]; for(let i=-3;i<=3;i++) if(i!==0) cw2.push({x:i*2.1,y:3.4,z:6.05,w:1.3,h:3.6,d:0.4});
instanced(cw2, winMat, cath);
box(cath,3.2,4.2,0.5,'#5a4634',0,2.1,6.1);
box(cath,17.2,0.8,12.2,'#cfc5ae',0,0.4,0);
signPlane(cath,{text:'ቅዱስ ትርናት እግአና', w:11,h:1.6,x:0,y:8.3,z:6.35,bg:'#2a3f55',fg:'#f4d03f',font:40});
// --- monument ---
const mon=new THREE.Group(); mon.position.set(0,0.3,17); scene.add(mon);
box(mon,5.2,0.4,5.2,'#b9b1a0',0,0.2,0);
box(mon,4.2,0.4,4.2,'#c7bfae',0,0.6,0);
box(mon,1.5,5.6,1.5,'#cfc7b4',0,3.4,0);
box(mon,1.9,0.45,1.9,'#8d8676',0,6.3,0);
// little statue
box(mon,0.9,1.3,0.6,'#5d7f8e',0,7.3,0);
box(mon,0.55,0.55,0.55,'#8d5524',0,8.2,0);
box(mon,0.3,1.1,0.3,'#5d7f8e',0.5,7.2,0,{rot:[0,0,-0.5]});
// flower beds
for(const s of [-1,1]){
box(mon,1.6,0.35,4.4,'#8a6a4a',s*3.6,0.18,0);
for(let i=0;i<7;i++) box(mon,0.45,0.35,0.45,['#d94f4f','#e8b13a','#c76fb0'][i%3],s*3.6,0.45,-1.8+i*0.6);
}
// --- jacaranda trees ---
function tree(x,z,s=1){
const g=new THREE.Group(); g.position.set(x,0.3,z); scene.add(g);
box(g,0.75*s,3.4*s,0.75*s,'#6b4f37',0,1.7*s,0);
box(g,0.45*s,1.6*s,0.45*s,'#6b4f37',0.7*s,3.2*s,0,{rot:[0,0,-0.5]});
box(g,0.45*s,1.6*s,0.45*s,'#6b4f37',-0.7*s,3.1*s,0.3,{rot:[0,0,0.5]});
const blobs=[[0,4.4,0,3.2],[1.4,3.9,0.5,2.4],[-1.3,4.0,-0.6,2.4],[0.3,5.4,0.4,2.1],[-0.7,4.7,-0.9,1.8]];
const purples=['#9b7bc0','#8e6bb5','#a98ccb','#7f5ea8'];
blobs.forEach((b,i)=>box(g,b[3]*s,b[2]*s,b[3]*s,purples[i%4],b[0]*s,b[1]*s,b[2]*s));
return g;
}
[[ -8,9,1.1],[7,8,1.0],[15,17,1.2],[-9,25,1.15],[30,26,1.05],[2,31,0.95],[38,12,1.0],[-3,38,1.1]].forEach(t=>tree(t[0],t[1],t[2]));
// benches + bins
function bench(x,z,ry=0){
const g=new THREE.Group(); g.position.set(x,0.3,z); g.rotation.y=ry; scene.add(g);
box(g,2.2,0.14,0.6,'#8a6a45',0,0.5,0);
box(g,2.2,0.6,0.12,'#8a6a45',0,0.85,-0.25,{rot:[-0.18,0,0]});
box(g,0.14,0.5,0.55,'#5c4630',-0.9,0.25,0); box(g,0.14,0.5,0.55,'#5c4630',0.9,0.25,0);
}
bench(-5,12,0.2); bench(12,9,-0.3); bench(-12,20,1.6); bench(25,20,3.0);
[[ -3,13],[16,11],[-11,27]].forEach(b=>{
box(scene,0.6,0.9,0.6,'#4d5a4a',b[0],0.75,b[1]);
box(scene,0.7,0.12,0.7,'#3f4a3c',b[0],1.25,b[1]);
});
// plaza lamp posts
const bulbMat = new THREE.MeshLambertMaterial({color:'#fff3c8', emissive:'#ffd98a', emissiveIntensity:0});
const lampLights=[];
function lampPost(x,z,ry=0){
const g=new THREE.Group(); g.position.set(x,0.3,z); g.rotation.y=ry; scene.add(g);
box(g,0.18,4.4,0.18,'#3c4149',0,2.2,0);
box(g,0.9,0.16,0.16,'#3c4149',0,4.35,0);
box(g,0.55,0.4,0.55,bulbMat,0,4.05,0);
const pl=new THREE.PointLight(0xffcf88,0,16,2); pl.position.set(0,4.0,0); g.add(pl); lampLights.push(pl);
}
lampPost(-4,7.5); lampPost(9,14); lampPost(33,16); lampPost(-16,6);
/* ============================================================
5. The coffee-service corner (hero)
============================================================ */
const KIOSK = new THREE.Group(); KIOSK.position.set(-17,0.3,0.5); scene.add(KIOSK);
// back wall + counter
box(KIOSK,5.4,2.8,0.28,'#6d4f36',0,1.4,-1.6);
box(KIOSK,5.4,0.3,0.5,'#8a6a45',0,2.6,-1.45);
box(KIOSK,4.2,1.0,1.0,'#8a6a45',0,0.5,0); // counter
box(KIOSK,4.4,0.12,1.15,'#5c4630',0,1.03,0); // counter top
for(let i=0;i<5;i++) box(KIOSK,0.5,0.06,0.1,'#e6dcc6',-1.6+i*0.8,1.12,-0.48);
// shelf with cups & jars
box(KIOSK,4.6,0.12,0.6,'#6d4f36',0,2.1,-1.2);
for(let i=0;i<8;i++) box(KIOSK,0.22,0.3,0.22,'#f3efe3',-1.9+i*0.55,2.35,-1.2);
// posts
box(KIOSK,0.16,2.6,0.16,'#5c4630',-2.2,1.3,-1.0);
box(KIOSK,0.16,2.6,0.16,'#5c4630', 2.2,1.3,-1.0);
box(KIOSK,0.16,2.6,0.16,'#5c4630',-2.2,1.3, 0.7);
box(KIOSK,0.16,2.6,0.16,'#5c4630', 2.2,1.3, 0.7);
// striped awning
for(let i=0;i<11;i++){
const col = i%2 ? '#f3eee0' : '#1f7a4d';
box(KIOSK,0.48,0.14,2.4,col,-2.4+i*0.48,2.62,-0.45,{rot:[-0.20,0,0]});
}
for(let i=0;i<11;i++){
const col = i%2 ? '#f3eee0' : '#1f7a4d';
box(KIOSK,0.48,0.34,0.12,col,-2.4+i*0.48,2.28,-1.62);
}
// espresso machine
box(KIOSK,1.3,0.85,0.75,'#b9c2c8',-1.2,1.5,-0.05);
box(KIOSK,1.35,0.12,0.8,'#8e979d',-1.2,1.96,-0.05);
box(KIOSK,0.22,0.3,0.25,'#3c4149',-1.2,1.32,0.34);
box(KIOSK,0.12,0.1,0.4,'#6b7278',-1.2,1.22,0.45);
box(KIOSK,0.35,0.1,0.5,'#5a6167',-0.6,1.3,0.3);
// coffee ceremony brazier + jebena
box(KIOSK,0.7,0.18,0.7,'#3b3128',0.9,1.15,-0.15);
for(let i=0;i<6;i++) box(KIOSK,0.18,0.12,0.18,'#ff7a2a',0.66+(i%3)*0.22,1.26,-0.35+Math.floor(i/3)*0.3,{basic:true});
box(KIOSK,0.52,0.42,0.52,'#cbb277',0.9,1.55,-0.15);
box(KIOSK,0.3,0.22,0.3,'#cbb277',0.9,1.85,-0.15);
box(KIOSK,0.1,0.32,0.1,'#cbb277',0.9,2.05,-0.15,{rot:[0,0,0.25]});
// glasses of coffee
for(let i=0;i<4;i++) box(KIOSK,0.16,0.14,0.16,'#f5f1e6',1.9+(i%2)*0.3,1.17,-0.1+Math.floor(i/2)*0.25);
// menu board
signPlane(KIOSK,{text:'BUNA 15', sub:'TEA 5 · JEBENA 20 · ቡና', w:3.6,h:1.5,x:0,y:2.95,z:-1.75,ry:Math.PI,bg:'#20302a',fg:'#f4d03f',font:46});
// Ethiopian flag on a pole
box(KIOSK,0.12,3.6,0.12,'#8a6a45',2.55,1.8,0.6);
const flagStrips=[];
['#0f7a3d','#f4d03f','#d0342c'].forEach((c,i)=>{
const m=box(KIOSK,0.36,0.85,0.05,c,2.75+i*0.36,3.25,0.6); flagStrips.push(m);
});
// hanging string of bulbs
const stringBulbs=[];
for(let i=0;i<9;i++){
const t=i/8;
const bx=-1.5+t*3.0, bz=-1.8-Math.sin(Math.PI*t)*0.0;
const by=2.45-Math.sin(Math.PI*t)*0.45;
box(KIOSK,0.09,0.09,0.09,'#4a4f57',bx,by+0.12,bz);
const b=box(KIOSK,0.13,0.17,0.13,bulbMat,bx,by,bz); stringBulbs.push(b);
}
// warm light over the counter
const kioskLight=new THREE.PointLight(0xffd08a,0,14,2); kioskLight.position.set(0,2.2,-0.4); KIOSK.add(kioskLight);
// --- tables, stools, cups ---
function table(x,z,top=1.06){
const g=new THREE.Group(); g.position.set(x,0.3,z); scene.add(g);
box(g,0.18,0.72,0.18,'#6d4f36',0,0.36,0);
box(g,1.15,0.1,1.15,'#8a6a45',0,0.72,0);
box(g,1.22,0.05,1.22,'#5c4630',0,0.79,0);
return g;
}
function stool(x,z){
const g=new THREE.Group(); g.position.set(x,0.3,z); scene.add(g);
box(g,0.52,0.1,0.52,'#8a6a45',0,0.48,0);
for(const sx of [-1,1]) for(const sz of [-1,1]) box(g,0.08,0.44,0.08,'#5c4630',sx*0.19,0.22,sz*0.19);
return g;
}
function cup(x,y,z){
box(scene,0.15,0.15,0.15,'#f7f3e8',x,y+0.075,z);
box(scene,0.13,0.03,0.13,'#5b3a1e',x,y+0.155,z);
box(scene,0.05,0.05,0.05,'#f7f3e8',x+0.10,y+0.08,z);
}
const TABLES=[[-18.7,-1.9],[-15.3,-1.9],[-11.4,-1.4]];
TABLES.forEach(t=>{ table(t[0],t[1]); cup(t[0]-0.3,t[1],1.06); cup(t[0]+0.35,t[1],1.06); });
// stools around tables
[[-19.9,-1.9],[-17.5,-1.9],[-16.5,-1.9],[-14.1,-1.9],[-13.0,-1.9],[-10.2,-1.4],[-12.6,-1.4]].forEach(s=>stool(s[0],s[1]));
// laptop on third table
box(scene,0.55,0.04,0.4,'#3c4149',-11.9,1.10,-1.45,{rot:[0,0.4,0]});
box(scene,0.55,0.38,0.05,'#59606a',-11.9,1.28,-1.28,{rot:[-0.35,0.4,0]});
// second kiosk sign on the corner post
signPlane(KIOSK,{text:'ቡና', w:1.0,h:1.0,x:-2.2,y:2.05,z:-1.75,ry:Math.PI,bg:'#d0342c',fg:'#ffffff',font:70});
/* ============================================================
6. Steam particles
============================================================ */
const steams=[];
function steamAt(x,y,z,n=4,scale=1){
for(let i=0;i<n;i++){
const m=box(scene,0.08*scale,0.08*scale,0.08*scale,'#ffffff',x,y,z,{basic:true,transparent:true,opacity:0.5,cast:false,recv:false});
steams.push({m, x, y, z, off:Math.random(), sp:0.22+Math.random()*0.16, sc:scale});
}
}
steamAt(-18.9,1.1,-1.9); steamAt(-15.1,1.1,-1.9); steamAt(-17.4,2.1,-0.15,6,1.3);
/* ============================================================
7. People (voxel)
============================================================ */
function makePerson(o={}){
const g=new THREE.Group();
const skin=o.skin||'#8d5524', shirt=o.shirt||'#2f6f8f', pants=o.pants||'#3c4450';
const simple=!!o.simple;
const legs=[], arms=[];
for(const s of [-1,1]){
const hip=new THREE.Group(); hip.position.set(s*0.15,0.86,0); g.add(hip);
box(hip,0.18,0.42,0.2,pants,0,-0.21,0);
const knee=new THREE.Group(); knee.position.set(0,-0.42,0); hip.add(knee);
box(knee,0.16,0.38,0.18,pants,0,-0.19,0);
if(!simple) box(knee,0.2,0.11,0.29,'#2b2b2b',0,-0.4,0.05);
legs.push({hip,knee});
}
box(g,0.54,0.68,0.32,shirt,0,1.19,0);
box(g,0.52,0.2,0.32,pants,0,0.92,0);
box(g,0.39,0.39,0.37,skin,0,1.69,0);
if(!simple){
box(g,0.41,0.12,0.39,o.hair||'#1d120c',0,1.85,-0.01);
box(g,0.05,0.05,0.02,'#151515',-0.09,1.71,0.195,{cast:false});
box(g,0.05,0.05,0.02,'#151515', 0.09,1.71,0.195,{cast:false});
}
for(const s of [-1,1]){
const sh=new THREE.Group(); sh.position.set(s*0.34,1.46,0); g.add(sh);
box(sh,0.14,0.5,0.16,shirt,0,-0.25,0);
box(sh,0.13,0.2,0.15,skin,0,-0.58,0);
arms.push(sh);
}
if(o.basket){
box(g,0.62,0.3,0.62,'#e0b64f',0,2.05,0);
box(g,0.72,0.12,0.72,'#c99a35',0,1.93,0);
box(g,0.5,0.25,0.5,'#d8c07a',0,2.2,0);
}
if(o.cap) box(g,0.44,0.12,0.42,o.cap,0,1.9,0.03);
if(o.bag) box(g,0.3,0.42,0.18,'#8a4b3a',0.38,0.95,0.12);
g.scale.setScalar(o.scale||1);
return {g, legs, arms};
}
function animateWalker(p, phase, speed){
const s=Math.sin(phase), c=Math.cos(phase);
p.legs[0].hip.rotation.x = s*0.55;
p.legs[1].hip.rotation.x = -s*0.55;
p.legs[0].knee.rotation.x = Math.max(0,-Math.sin(phase+0.8))*0.85;
p.legs[1].knee.rotation.x = Math.max(0,-Math.sin(phase+0.8+Math.PI))*0.85;
p.arms[0].rotation.x = -s*0.45;
p.arms[1].rotation.x = s*0.45;
p.arms[0].rotation.z = 0.12; p.arms[1].rotation.z = -0.12;
p.g.position.y = p.baseY + Math.abs(c)*0.045;
}
const walkers=[];
function walker(o){
const p=makePerson(o);
p.baseY=o.y; p.g.position.set(o.x, o.y, o.z);
p.g.rotation.y=o.ry||0;
scene.add(p.g);
const w={p, x0:o.x, z0:o.z, x1:o.x1, z1:o.z1, t:Math.random(), dir:o.dir||1, sp:o.sp||1.2, phase:Math.random()*6.28};
walkers.push(w); return w;
}
const SKIN=['#8d5524','#c68642','#e0ac69','#7a4a2b','#a9714b'];
const SHIRT=['#d94f4f','#2f7a9e','#e0b355','#5b8c5a','#8e5aa8','#e07a3c','#3f6f8f'];
const PANTS=['#3c4450','#5a4630','#2e3440','#6b6257'];
function rand(a){ return a[Math.floor(Math.random()*a.length)]; }
// main street lanes
for(let i=0;i<3;i++) walker({x:-60+i*22, z:1.1, x1:70, z1:1.1, y:0.30, dir:1, sp:1.15+Math.random()*0.35,
shirt:rand(SHIRT), pants:rand(PANTS), skin:rand(SKIN), simple:true, hair:rand(['#1d120c','#3a2415','#0f0f0f'])});
for(let i=0;i<3;i++) walker({x:60-i*26, z:2.2, x1:-70, z1:2.2, y:0.30, dir:1, sp:1.05+Math.random()*0.4,
shirt:rand(SHIRT), pants:rand(PANTS), skin:rand(SKIN), simple:true});
// plaza lanes
for(let i=0;i<3;i++) walker({x:-12+i*16, z:7.2, x1:46, z1:7.2, y:0.30, dir:1, sp:1.0+Math.random()*0.4,
shirt:rand(SHIRT), pants:rand(PANTS), skin:rand(SKIN), simple:true});
walker({x:40, z:30, x1:-12, z1:30, y:0.30, dir:1, sp:1.1, shirt:'#3f6f8f', pants:'#3c4450', skin:rand(SKIN)});
walker({x:-17, z:5, x1:-17, z1:26, y:0.30, dir:1, sp:1.0, shirt:'#d94f4f', pants:'#5a4630', skin:rand(SKIN), basket:true});
walker({x:-21.8, z:0, x1:-21.8, z1:26, y:0.02, dir:1, sp:1.25, shirt:'#e0b355', pants:'#2e3440', skin:rand(SKIN), simple:true});
// crossing pedestrians
walker({x:-25.6, z:-12.2, x1:-25.6, z1:-3.6, y:0.04, dir:1, sp:1.35, shirt:'#5b8c5a', pants:'#3c4450', skin:rand(SKIN)});
walker({x:-24.4, z:-3.8, x1:-24.4, z1:-12.4, y:0.04, dir:1, sp:1.25, shirt:'#8e5aa8', pants:'#5a4630', skin:rand(SKIN), bag:true});
// --- customers ---
function sitPerson(x,z,ry,shirt){
const p=makePerson({shirt, pants:rand(PANTS), skin:rand(SKIN), hair:rand(['#1d120c','#3a2415'])});
p.g.position.set(x, -0.02, z); p.g.rotation.y=ry; scene.add(p.g);
p.legs[0].hip.rotation.x=-1.45; p.legs[1].hip.rotation.x=-1.45;
p.legs[0].knee.rotation.x=1.5; p.legs[1].knee.rotation.x=1.5;
p.arms[0].rotation.x=-0.9; p.arms[1].rotation.x=-1.0;
return p;
}
const sitters=[
sitPerson(-19.85,-1.9, Math.PI/2, '#d94f4f'),
sitPerson(-17.55,-1.9,-Math.PI/2, '#2f7a9e'),
sitPerson(-16.4,-1.9, Math.PI/2, '#5b8c5a'),
sitPerson(-13.0,-1.4,-Math.PI/2, '#e0b355'),
sitPerson(-11.4,-1.9, Math.PI/2, '#8e5aa8'),
];
// standing customers at the counter
function standPerson(x,z,ry,shirt,armPose){
const p=makePerson({shirt, pants:rand(PANTS), skin:rand(SKIN)});
p.g.position.set(x,0.30,z); p.g.rotation.y=ry; scene.add(p.g);
if(armPose==='drink'){ p.arms[1].rotation.x=-1.35; }
if(armPose==='wave'){ p.arms[1].rotation.x=-2.1; p.arms[1].rotation.z=-0.6; }
if(armPose==='reach'){ p.arms[0].rotation.x=-1.1; p.arms[1].rotation.x=-1.1; }
return p;
}
standPerson(-18.4,-0.45,0,'#3f6f8f','reach');
standPerson(-16.1,-0.45,0,'#e07a3c','drink');
// vendor behind the counter
const vendor = standPerson(-17.4,-0.95,Math.PI,'#f3eee0','reach');
box(vendor.g,0.55,0.5,0.05,'#7a3f3f',0,1.1,0.28); // apron
// minibus tout waving by the road
const tout = standPerson(-22.6,-2.6,Math.PI*0.55,'#e0b355','wave');
/* ============================================================
8. Vehicles: blue-and-white minibus + bajaj
============================================================ */
function minibus(){
const g=new THREE.Group(); scene.add(g);
box(g,4.8,0.55,2.1,'#1f4f9c',0,0.72,0); // blue lower band
box(g,4.8,1.35,2.05,'#f3f2ec',0,1.66,0); // white body
box(g,4.5,0.18,2.0,'#1f4f9c',0,2.28,0); // blue roof stripe
box(g,4.9,0.16,2.15,'#dcdad2',0,2.44,0); // roof rack base
for(let i=0;i<4;i++) box(g,0.12,0.5,0.12,'#8a8f94',-1.8+i*1.2,2.75,0);
// windows
for(const s of [-1,1]) box(g,3.5,0.85,0.12,'#2b3d52',-0.1,1.78,s*1.02);
box(g,0.15,0.9,1.85,'#2b3d52',2.35,1.8,0); // windshield
box(g,0.15,0.85,1.85,'#2b3d52',-2.35,1.8,0); // rear glass
// doors + stripe
box(g,0.9,1.2,0.14,'#c9c7bf',1.0,1.5,1.03);
// lights
const headMat=new THREE.MeshLambertMaterial({color:'#fff3c8', emissive:'#fff0b0', emissiveIntensity:0});
box(g,0.12,0.3,0.35,headMat,2.44,0.95,0.7);
box(g,0.12,0.3,0.35,headMat,2.44,0.95,-0.7);
box(g,0.1,0.25,0.3,'#d0342c',-2.44,0.95,0.7);
box(g,0.1,0.25,0.3,'#d0342c',-2.44,0.95,-0.7);
// wheels
const wheels=[];
for(const x of [-1.6,1.6]) for(const z of [-1.05,1.05]){
const w=box(g,0.78,0.78,0.34,'#23242a',x,0.42,z); wheels.push(w);
box(g,0.3,0.3,0.37,'#9aa0a6',x,0.42,z);
}
signPlane(g,{text:'አዲስ', sub:'ADDIS', w:1.5,h:0.55,x:2.47,y:2.18,z:0,ry:Math.PI/2,bg:'#101820',fg:'#f4d03f',font:60});
signPlane(g,{text:'አዲስ', sub:'ADDIS', w:1.5,h:0.55,x:-2.47,y:2.18,z:0,ry:-Math.PI/2,bg:'#101820',fg:'#f4d03f',font:60});
g.position.set(-40,0,-6.6);
return {g,wheels,headMat, speed:9, dir:1, x:-40};
}
const bus=minibus();
function bajaj(){
const g=new THREE.Group(); scene.add(g);
box(g,2.0,0.9,1.4,'#f0efe8',-0.2,0.75,0);
box(g,1.6,0.55,1.35,'#2f5f9e',-0.3,1.4,0);
box(g,1.3,0.6,1.2,'#2b3d52',-0.3,1.55,0);
box(g,1.4,0.45,1.3,'#c85a3a',0.95,0.7,0);
box(g,0.12,0.12,0.9,'#6b7278',0.6,1.35,0);
for(const z of [-0.78,0.78]) box(g,0.5,0.5,0.24,'#23242a',0.4,0.32,z);
box(g,0.5,0.5,0.24,'#23242a',-0.9,0.32,0);
g.position.set(30,0,-9.6);
return {g, speed:-7.5, x:30};
}
const trike=bajaj();
/* ============================================================
9. Day / night lighting
============================================================ */
let nightTarget=0, nightAmt=0;
const sunDay=new THREE.Color('#fff2d0'), sunNight=new THREE.Color('#ff9d5c');
const hemiDay=new THREE.Color('#bfe3ff'), hemiNight=new THREE.Color('#2b3a58');
const groundDay=new THREE.Color('#8d8467'), groundNight=new THREE.Color('#141821');
function updateLights(dt){
nightAmt += (nightTarget-nightAmt)*Math.min(1,dt*2.2);
const t=nightAmt;
sun.intensity = THREE.MathUtils.lerp(2.3,0.22,t);
sun.color.lerpColors(sunDay,sunNight,t);
hemi.intensity = THREE.MathUtils.lerp(1.0,0.30,t);
hemi.color.lerpColors(hemiDay,hemiNight,t);
hemi.groundColor.lerpColors(groundDay,groundNight,t);
scene.background.lerpColors(DAY_BG,NIGHT_BG,t);
scene.fog.color.copy(scene.background);
winMat.emissiveIntensity = t*1.6;
bulbMat.emissiveIntensity = t*2.2;
bus.headMat.emissiveIntensity = t*2.5;
kioskLight.intensity = t*9;
lampLights.forEach(l=>l.intensity=t*7);
renderer.toneMappingExposure = THREE.MathUtils.lerp(1.08,1.25,t);
}
/* ============================================================
10. Custom camera controls (no addons)
============================================================ */
const cam = {
target:new THREE.Vector3(-15.5,1.9,-0.6),
radius:24, theta:0.95, phi:1.12,
minR:6, maxR:95, auto:true, autoSpeed:0.045,
dragging:false, lastX:0, lastY:0, panning:false,
pointers:new Map(), pinch:0, idle:0
};
function applyCam(){
const s=new THREE.Vector3().setFromSphericalCoords(cam.radius, cam.phi, cam.theta);
camera.position.copy(cam.target).add(s);
camera.lookAt(cam.target);
}
const dom=renderer.domElement;
dom.addEventListener('contextmenu', e=>e.preventDefault());
dom.addEventListener('pointerdown', e=>{
dom.setPointerCapture(e.pointerId);
cam.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});
if(cam.pointers.size===1){
cam.dragging=true; cam.panning = e.shiftKey || e.button===2;
cam.lastX=e.clientX; cam.lastY=e.clientY; cam.idle=0;
} else if(cam.pointers.size===2){
const p=[...cam.pointers.values()];
cam.pinch=Math.hypot(p[0].x-p[1].x,p[0].y-p[1].y); cam.dragging=false;
}
});
dom.addEventListener('pointermove', e=>{
if(!cam.pointers.has(e.pointerId)) return;
cam.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});
cam.idle=0;
if(cam.pointers.size===2){
const p=[...cam.pointers.values()];
const d=Math.hypot(p[0].x-p[1].x,p[0].y-p[1].y);
if(cam.pinch){ cam.radius = THREE.MathUtils.clamp(cam.radius*(cam.pinch/Math.max(d,1)),cam.minR,cam.maxR); }
cam.pinch=d; applyCam(); return;
}
if(!cam.dragging) return;
const dx=e.clientX-cam.lastX, dy=e.clientY-cam.lastY;
cam.lastX=e.clientX; cam.lastY=e.clientY;
if(cam.panning){
const right=new THREE.Vector3().setFromMatrixColumn(camera.matrix,0);
const up=new THREE.Vector3().setFromMatrixColumn(camera.matrix,1);
const k=cam.radius*0.0016;
cam.target.addScaledVector(right,-dx*k).addScaledVector(up,dy*k);
cam.target.x=THREE.MathUtils.clamp(cam.target.x,-60,60);
cam.target.z=THREE.MathUtils.clamp(cam.target.z,-40,50);
cam.target.y=THREE.MathUtils.clamp(cam.target.y,0,14);
}else{
cam.theta -= dx*0.005;
cam.phi = THREE.MathUtils.clamp(cam.phi - dy*0.004, 0.12, 1.50);
}
applyCam();
});
const endPointer=e=>{
cam.pointers.delete(e.pointerId);
if(cam.pointers.size<2) cam.pinch=0;
if(cam.pointers.size===0){ cam.dragging=false; cam.panning=false; }
};
dom.addEventListener('pointerup', endPointer);
dom.addEventListener('pointercancel', endPointer);
dom.addEventListener('wheel', e=>{
e.preventDefault();
cam.radius = THREE.MathUtils.clamp(cam.radius*(1+Math.sign(e.deltaY)*0.09), cam.minR, cam.maxR);
cam.idle=0; applyCam();
},{passive:false});
addEventListener('keydown', e=>{
if(e.key==='ArrowLeft') cam.theta+=0.09;
else if(e.key==='ArrowRight') cam.theta-=0.09;
else if(e.key==='+'||e.key==='=') cam.radius=Math.max(cam.minR,cam.radius*0.92);
else if(e.key==='-'||e.key==='_') cam.radius=Math.min(cam.maxR,cam.radius*1.08);
else return;
cam.idle=0; applyCam();
});
function resetCam(){
cam.target.set(-15.5,1.9,-0.6); cam.radius=24; cam.theta=0.95; cam.phi=1.12; applyCam();
}
document.getElementById('btnReset').onclick=resetCam;
const btnOrbit=document.getElementById('btnOrbit');
btnOrbit.onclick=()=>{ cam.auto=!cam.auto; btnOrbit.classList.toggle('on',cam.auto); };
const btnNight=document.getElementById('btnNight');
btnNight.onclick=()=>{
nightTarget = nightTarget>0.5?0:1;
btnNight.textContent = nightTarget>0.5?'☀️ Day':'🌙 Evening';
btnNight.classList.toggle('on',nightTarget>0.5);
};
applyCam();
/* ============================================================
11. Animation loop
============================================================ */
const clock=new THREE.Clock();
let t=0;
function animate(){
const dt=Math.min(clock.getDelta(),0.05); t+=dt;
// walkers
for(const w of walkers){
const len=Math.hypot(w.x1-w.x0, w.z1-w.z0);
w.t += w.dir*w.sp*dt/len;
if(w.t>1) w.t-=1; if(w.t<0) w.t+=1;
const x=THREE.MathUtils.lerp(w.x0,w.x1,w.t);
const z=THREE.MathUtils.lerp(w.z0,w.z1,w.t);
const dx=(w.x1-w.x0)/len, dz=(w.z1-w.z0)/len;
w.p.g.position.x=x; w.p.g.position.z=z;
w.p.g.rotation.y=Math.atan2(dx*w.dir, dz*w.dir);
w.phase += dt*w.sp*2.6;
animateWalker(w.p, w.phase, w.sp);
}
// seated customers: gentle idle
sitters.forEach((p,i)=>{
p.arms[1].rotation.x=-1.0+Math.sin(t*1.2+i)*0.12;
p.arms[0].rotation.x=-0.9+Math.cos(t*1.1+i*2)*0.1;
p.g.position.y=-0.02+Math.sin(t*1.6+i)*0.012;
});
// tout waves
tout.arms[1].rotation.x=-2.1+Math.sin(t*4.2)*0.5;
tout.arms[1].rotation.z=-0.5+Math.sin(t*4.2)*0.25;
// vendor working
vendor.arms[0].rotation.x=-1.1+Math.sin(t*2.2)*0.18;
vendor.arms[1].rotation.x=-1.0+Math.cos(t*2.4)*0.15;
vendor.g.position.y=0.3+Math.sin(t*1.5)*0.01;
// steam
for(const s of steams){
const u=(t*s.sp+s.off)%1;
s.m.position.set(s.x+Math.sin(u*6+s.off*9)*0.05, s.y+u*1.1, s.z+Math.cos(u*5+s.off*7)*0.05);
s.m.scale.setScalar((0.07+u*0.16)*s.sc);
s.m.material.opacity=0.55*(1-u);
}
// flag flutter
flagStrips.forEach((m,i)=>{ m.rotation.y=Math.sin(t*3+i*0.9)*0.22; m.rotation.z=Math.sin(t*2.4+i)*0.05; });
// string lights sway
stringBulbs.forEach((b,i)=>{ b.rotation.z=Math.sin(t*1.6+i*0.5)*0.35; });
// minibus drive
bus.x += bus.speed*dt;
if(bus.x>70) bus.x=-70;
bus.g.position.x=bus.x;
bus.wheels.forEach(w=>w.rotation.z -= bus.speed*dt/0.39);
trike.x += trike.speed*dt;
if(trike.x<-70) trike.x=70;
trike.g.position.x=trike.x;
updateLights(dt);
// camera auto orbit with idle resume
cam.idle+=dt;
if(cam.auto && cam.idle>5){ cam.theta += cam.autoSpeed*dt; applyCam(); }
renderer.render(scene,camera);
}
renderer.setAnimationLoop(animate);
addEventListener('resize',()=>{
camera.aspect=innerWidth/innerHeight; camera.updateProjectionMatrix();
renderer.setSize(innerWidth,innerHeight);
});
</script>
</body>
</html>
```