Prompt specification
Build or customize the Three.js 3D scene "Dihua Street arcade column and shop threshold" 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: Dihua Street arcade column and shop threshold
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/dihua-street-arcade-column-and-shop-threshold-x3033
Scene Description Prompt:
A voxel Dihua Street shopfront in Taipei with arcade columns, recessed entrance, and sheltered public passage. Create standalone HTML using Three.js from cdnjs.
Working Three.js Starter (dihua-street-arcade-column-and-shop-threshold-x3033):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Dihua Street — Taipei</title>
<style>
:root {
color-scheme: dark;
--cream: #f5e8cf;
--gold: #d4a85f;
--glass: rgba(20, 31, 32, 0.76);
--line: rgba(245, 232, 207, 0.25);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b9d2d7;
font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
#title-card {
position: fixed;
top: 22px;
left: 22px;
z-index: 10;
width: min(360px, calc(100vw - 44px));
padding: 17px 19px 16px;
color: var(--cream);
background: var(--glass);
border: 1px solid var(--line);
border-radius: 4px;
backdrop-filter: blur(12px);
box-shadow: 0 14px 35px rgba(23, 26, 24, 0.18);
pointer-events: none;
}
#title-card .eyebrow {
margin-bottom: 7px;
color: var(--gold);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.22em;
text-transform: uppercase;
}
#title-card h1 {
margin: 0;
font-family: "Noto Serif TC", "Songti TC", Georgia, serif;
font-size: 27px;
font-weight: 500;
letter-spacing: 0.05em;
}
#title-card p {
margin: 8px 0 0;
color: rgba(245, 232, 207, 0.73);
font-size: 12px;
line-height: 1.55;
}
#controls {
position: fixed;
right: 22px;
bottom: 22px;
z-index: 10;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px;
}
button {
appearance: none;
padding: 10px 13px;
color: var(--cream);
font: inherit;
font-size: 11px;
font-weight: 600;
letter-spacing: 0.04em;
background: rgba(25, 37, 37, 0.78);
border: 1px solid rgba(245, 232, 207, 0.25);
border-radius: 3px;
backdrop-filter: blur(10px);
cursor: pointer;
transition:
background 160ms ease,
border-color 160ms ease,
transform 160ms ease;
}
button:hover,
button.active {
color: #201b16;
background: var(--gold);
border-color: var(--gold);
}
button:active {
transform: translateY(1px);
}
#hint {
position: fixed;
left: 22px;
bottom: 22px;
z-index: 9;
padding: 9px 11px;
color: rgba(255, 255, 255, 0.78);
background: rgba(30, 40, 40, 0.55);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 3px;
font-size: 10px;
letter-spacing: 0.04em;
backdrop-filter: blur(8px);
pointer-events: none;
}
#loading {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
color: #f5e8cf;
background: #263536;
font-size: 12px;
letter-spacing: 0.18em;
transition: opacity 500ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 620px) {
#title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 13px 15px;
}
#title-card h1 {
font-size: 22px;
}
#title-card p {
display: none;
}
#controls {
right: 12px;
bottom: 12px;
}
#hint {
left: 12px;
bottom: 12px;
max-width: 145px;
line-height: 1.45;
}
}
</style>
</head>
<body>
<div id="loading">BUILDING DIHUA STREET…</div>
<section id="title-card">
<div class="eyebrow">Voxel architectural study · Taipei</div>
<h1>迪化街 · Dihua Street</h1>
<p>
A shaded public arcade, red-brick shopfronts, recessed doorways,
hanging trade signs, and everyday street life.
</p>
</section>
<div id="hint">DRAG TO ORBIT · SCROLL TO ZOOM · ARROWS TO ROTATE</div>
<nav id="controls" aria-label="Camera views">
<button data-view="street" class="active">Street View</button>
<button data-view="arcade">Arcade View</button>
<button data-view="detail">Shop Detail</button>
</nav>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer and scene
// ------------------------------------------------------------
const loading = document.getElementById("loading");
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
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;
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xb9d2d7);
scene.fog = new THREE.Fog(0xb9d2d7, 24, 61);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemi = new THREE.HemisphereLight(0xd7edf2, 0x715746, 1.65);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffe1b0, 3.15);
sun.position.set(-10, 17, 15);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -21;
sun.shadow.camera.right = 21;
sun.shadow.camera.top = 20;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 50;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9cc8d6, 0.55);
fill.position.set(12, 8, -10);
scene.add(fill);
// ------------------------------------------------------------
// Geometry helpers
// ------------------------------------------------------------
const materialCache = new Map();
function standardMaterial(color) {
if (color?.isMaterial) return color;
if (!materialCache.has(color)) {
materialCache.set(
color,
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.02
})
);
}
return materialCache.get(color);
}
function box(
parent,
width,
height,
depth,
x,
y,
z,
color,
castShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
standardMaterial(color)
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const wood = new THREE.MeshStandardMaterial({
color: 0x4a3023,
roughness: 0.7
});
const darkWood = new THREE.MeshStandardMaterial({
color: 0x251b17,
roughness: 0.82
});
const stone = new THREE.MeshStandardMaterial({
color: 0xc5b99f,
roughness: 0.94
});
const glass = new THREE.MeshStandardMaterial({
color: 0x41666b,
roughness: 0.2,
metalness: 0.12,
transparent: true,
opacity: 0.68
});
const warmGlow = new THREE.MeshStandardMaterial({
color: 0xffcf79,
emissive: 0xffa83b,
emissiveIntensity: 2.2,
roughness: 0.5
});
const redLantern = new THREE.MeshStandardMaterial({
color: 0x9b302c,
emissive: 0x8d1d18,
emissiveIntensity: 0.55,
roughness: 0.7
});
// ------------------------------------------------------------
// Ground, road, curb and sidewalk
// ------------------------------------------------------------
box(scene, 44, 0.24, 34, 0, -0.16, 11, 0x586466, false);
box(scene, 42, 0.12, 17, 0, -0.005, 15.2, 0x424b4e, false);
// Road markings
for (let x = -18; x <= 18; x += 4.2) {
box(scene, 2.3, 0.025, 0.12, x, 0.065, 11.3, 0xd4c9a9, false);
}
// Zebra crossing at the left side of the street.
for (let x = -16.5; x <= -9.5; x += 1.05) {
box(scene, 0.62, 0.025, 4.2, x, 0.065, 10.3, 0xe5dcc4, false);
}
// Main sidewalk and raised arcade pavement.
box(scene, 22.5, 0.24, 3.2, 0, 0.07, 4.9, 0xbdb9aa, false);
box(scene, 20.5, 0.12, 3.48, 0, 0.19, 1.63, 0xc8c0aa, false);
box(scene, 22.6, 0.18, 0.25, 0, 0.11, 6.43, 0xd1c8b0, false);
// Tactile paving.
for (let x = -10.3; x <= 10.3; x += 0.38) {
box(scene, 0.22, 0.035, 0.38, x, 0.215, 5.93, 0xc9963f, false);
}
// Arcade paving joints.
for (let x = -9.6; x <= 9.6; x += 1.2) {
box(scene, 0.035, 0.016, 3.28, x, 0.258, 1.68, 0xaaa38f, false);
}
for (const z of [0.22, 1.28, 2.35, 3.18]) {
box(scene, 20.1, 0.016, 0.032, 0, 0.259, z, 0xaaa38f, false);
}
// Drain covers.
for (const x of [-8.2, 7.8]) {
box(scene, 0.85, 0.025, 0.55, x, 0.215, 5.85, 0x4b5251, false);
for (let i = 0; i < 5; i++) {
box(
scene,
0.65,
0.025,
0.035,
x,
0.235,
5.66 + i * 0.095,
0x252c2d,
false
);
}
}
// ------------------------------------------------------------
// Main brick building
// ------------------------------------------------------------
const building = new THREE.Group();
scene.add(building);
// Upper brick volume.
box(building, 18.25, 4.15, 3.05, 0, 6.325, -1.30, 0x94493d);
box(building, 18.65, 0.30, 3.35, 0, 8.54, -1.30, 0x3e3430);
box(building, 18.2, 0.16, 0.22, 0, 8.37, 0.23, 0x6f3c34);
// Arcade ceiling and front fascia.
box(building, 19.0, 0.29, 3.48, 0, 4.22, 1.58, 0x9b6c50);
box(building, 19.15, 0.34, 0.34, 0, 4.23, 3.28, 0xb18760);
box(building, 19.0, 0.10, 0.12, 0, 4.02, 3.47, 0x70483a);
// Lower facade walls, leaving a recessed central entrance.
box(building, 7.05, 4.02, 0.50, -5.475, 2.20, -0.26, 0xb09270);
box(building, 7.05, 4.02, 0.50, 5.475, 2.20, -0.26, 0xb09270);
// Recessed entrance returns and soffit.
box(building, 0.22, 3.85, 1.35, -1.55, 2.08, -0.68, 0xc4ae88);
box(building, 0.22, 3.85, 1.35, 1.55, 2.08, -0.68, 0xc4ae88);
box(building, 3.30, 0.24, 1.55, 0, 3.97, -0.69, 0xa98c67);
box(building, 3.05, 3.70, 0.18, 0, 2.08, -1.42, 0x191b1a);
// Interior floor and ceiling.
box(building, 3.03, 0.10, 1.45, 0, 0.29, -0.71, 0x72563e);
box(building, 3.03, 0.10, 1.45, 0, 3.86, -0.71, 0x49392c);
// Recessed doorway frame.
box(building, 0.17, 3.20, 0.18, -1.32, 1.88, -1.25, wood);
box(building, 0.17, 3.20, 0.18, 1.32, 1.88, -1.25, wood);
box(building, 2.80, 0.18, 0.18, 0, 3.48, -1.25, wood);
// Open glass door on the right side of the entrance.
box(building, 1.12, 2.78, 0.055, 0.67, 1.72, -1.19, glass, false);
box(building, 0.075, 2.88, 0.09, 1.25, 1.72, -1.15, wood);
box(building, 0.075, 2.88, 0.09, 0.10, 1.72, -1.15, wood);
box(building, 1.20, 0.075, 0.09, 0.67, 3.10, -1.15, wood);
box(building, 1.20, 0.075, 0.09, 0.67, 0.34, -1.15, wood);
box(building, 0.045, 0.45, 0.045, 1.10, 1.67, -1.07, 0xd2ae67);
// Interior counter and shelves.
box(building, 2.05, 0.78, 0.46, -0.42, 0.73, -0.77, 0x65452d);
box(building, 2.05, 0.12, 0.56, -0.42, 1.16, -0.75, 0xa97846);
for (const y of [1.62, 2.22, 2.82]) {
box(building, 2.35, 0.09, 0.33, -0.25, y, -1.18, 0x765034);
}
// Small products inside.
const packageColors = [
0xb45a3f, 0xd3a64e, 0x557a69, 0xc9b586, 0x7d3f43, 0x73919b
];
for (let row = 0; row < 3; row++) {
for (let i = 0; i < 7; i++) {
box(
building,
0.18,
0.26 + (i % 2) * 0.08,
0.14,
-1.24 + i * 0.34,
1.80 + row * 0.60,
-1.12,
packageColors[(i + row) % packageColors.length]
);
}
}
const entranceLight = new THREE.PointLight(0xffb858, 10, 7, 2);
entranceLight.position.set(0, 2.7, -0.55);
building.add(entranceLight);
// ------------------------------------------------------------
// Individual brick courses
// ------------------------------------------------------------
const brickGeometry = new THREE.BoxGeometry(0.72, 0.275, 0.12);
const brickMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.96
});
const bricks = [];
const brickColors = [
0x9f4f40, 0xaa5745, 0x8d4439, 0xb05d49, 0x93483c, 0xa05243
];
for (let row = 0; row < 13; row++) {
const y = 4.58 + row * 0.315;
const offset = row % 2 ? 0.38 : 0;
for (let col = -12; col <= 12; col++) {
const x = col * 0.755 + offset;
if (x > -9.0 && x < 9.0) {
bricks.push({ x, y, z: 0.235, ry: 0 });
}
}
}
for (let row = 0; row < 13; row++) {
const y = 4.58 + row * 0.315;
for (let col = 0; col < 4; col++) {
const z = -2.45 + col * 0.755;
bricks.push({ x: 9.205, y, z, ry: Math.PI / 2 });
}
}
const brickMesh = new THREE.InstancedMesh(
brickGeometry,
brickMaterial,
bricks.length
);
const dummy = new THREE.Object3D();
bricks.forEach((brick, index) => {
dummy.position.set(brick.x, brick.y, brick.z);
dummy.rotation.set(0, brick.ry, 0);
dummy.updateMatrix();
brickMesh.setMatrixAt(index, dummy.matrix);
brickMesh.setColorAt(
index,
new THREE.Color(brickColors[index % brickColors.length])
);
});
brickMesh.instanceMatrix.needsUpdate = true;
brickMesh.instanceColor.needsUpdate = true;
brickMesh.castShadow = true;
brickMesh.receiveShadow = true;
building.add(brickMesh);
// ------------------------------------------------------------
// Arcade columns and capitals
// ------------------------------------------------------------
const columnPositions = [-8.3, -5.65, -3.0, -1.55, 1.55, 3.0, 5.65, 8.3];
for (const x of columnPositions) {
// Square voxel column, base, stepped capital and corbel.
box(building, 0.64, 0.30, 0.64, x, 0.39, 3.17, 0x9d927c);
box(building, 0.49, 0.18, 0.49, x, 0.63, 3.17, 0xb8aa8d);
box(building, 0.34, 2.93, 0.34, x, 2.17, 3.17, stone);
box(building, 0.46, 0.18, 0.46, x, 3.70, 3.17, 0xb6a88a);
box(building, 0.61, 0.17, 0.61, x, 3.88, 3.17, 0x96866e);
box(building, 0.72, 0.14, 0.72, x, 4.01, 3.17, 0xb59f7e);
// Small stepped support under the arcade beam.
box(building, 0.76, 0.13, 0.82, x, 3.74, 2.83, 0xb29773);
box(building, 0.92, 0.13, 0.65, x, 3.62, 2.67, 0xa58b68);
}
// ------------------------------------------------------------
// Upper windows and balconies
// ------------------------------------------------------------
function upperWindow(x) {
box(building, 1.78, 2.18, 0.18, x, 6.16, 0.32, 0x352b27);
box(building, 1.47, 1.87, 0.08, x, 6.16, 0.45, 0x355760);
// Cross mullions.
box(building, 0.09, 1.92, 0.10, x, 6.16, 0.51, 0x4c3026);
box(building, 1.50, 0.09, 0.10, x, 6.16, 0.51, 0x4c3026);
// Sill and lintel.
box(building, 1.98, 0.16, 0.38, x, 4.99, 0.42, 0x694b38);
box(building, 1.96, 0.17, 0.34, x, 7.29, 0.40, 0x694b38);
// Wooden shutters.
box(building, 0.31, 1.86, 0.11, x - 0.92, 6.16, 0.43, 0x6f4933);
box(building, 0.31, 1.86, 0.11, x + 0.92, 6.16, 0.43, 0x6f4933);
}
for (const x of [-6.2, -2.5, 2.5, 6.2]) {
upperWindow(x);
}
// Small balcony for the two central bays.
for (const x of [-2.5, 2.5]) {
box(building, 2.28, 0.16, 0.80, x, 4.84, 0.62, 0x71503a);
box(building, 2.28, 0.08, 0.10, x, 5.43, 0.98, 0x3e2d25);
for (let i = 0; i < 7; i++) {
box(
building,
0.055,
0.50,
0.055,
x - 0.92 + i * 0.307,
5.17,
0.97,
0x3e2d25
);
}
}
// Side-facing upper window.
box(building, 0.12, 1.80, 1.30, 9.24, 6.12, -1.18, 0x2c2724);
box(building, 0.07, 1.52, 1.04, 9.32, 6.12, -1.18, 0x41656b);
box(building, 0.08, 1.58, 0.065, 9.37, 6.12, -1.18, 0x654433);
// ------------------------------------------------------------
// Shop windows
// ------------------------------------------------------------
function shopWindow(x, teaShop) {
box(building, 3.05, 2.25, 0.15, x, 1.77, 0.10, 0x191a18);
box(building, 2.68, 1.93, 0.055, x, 1.78, 0.22, glass, false);
// Wooden frame.
box(building, 0.16, 2.22, 0.20, x - 1.43, 1.77, 0.29, wood);
box(building, 0.16, 2.22, 0.20, x + 1.43, 1.77, 0.29, wood);
box(building, 3.02, 0.17, 0.20, x, 2.82, 0.29, wood);
box(building, 3.02, 0.17, 0.20, x, 0.71, 0.29, wood);
box(building, 0.12, 2.02, 0.15, x, 1.77, 0.30, wood);
box(building, 2.75, 0.10, 0.15, x, 1.77, 0.30, wood);
// Display ledge.
box(building, 3.18, 0.18, 0.42, x, 0.57, 0.35, 0x6a4933);
if (teaShop) {
// Cubic tea canisters.
for (let i = 0; i < 5; i++) {
const px = x - 0.92 + i * 0.46;
const h = 0.32 + (i % 3) * 0.08;
box(building, 0.27, h, 0.25, px, 0.72 + h / 2, 0.27, packageColors[i]);
box(building, 0.29, 0.06, 0.27, px, 0.74 + h, 0.27, 0xc7a052);
}
} else {
// Stacked tea packets and boxes.
for (let i = 0; i < 7; i++) {
const px = x - 1.00 + i * 0.33;
const h = 0.25 + (i % 3) * 0.10;
box(building, 0.24, h, 0.16, px, 0.75 + h / 2, 0.29, packageColors[i]);
}
}
}
shopWindow(-5.2, false);
shopWindow(5.2, true);
// ------------------------------------------------------------
// Canvas-generated signage
// ------------------------------------------------------------
function createSignTexture(main, subtitle = "", options = {}) {
const {
vertical = false,
background = "#183d38",
foreground = "#f2d79b",
border = "#c99d58"
} = options;
const canvas = document.createElement("canvas");
canvas.width = vertical ? 256 : 1024;
canvas.height = vertical ? 768 : 256;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = border;
ctx.lineWidth = vertical ? 10 : 8;
ctx.strokeRect(12, 12, canvas.width - 24, canvas.height - 24);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = foreground;
if (vertical) {
const chars = [...main];
const size = chars.length > 4 ? 72 : 86;
ctx.font = `600 ${size}px "Noto Serif TC", "Songti TC", serif`;
chars.forEach((char, i) => {
ctx.fillText(
char,
canvas.width / 2,
120 + i * (size + 23)
);
});
if (subtitle) {
ctx.font = '600 24px "Noto Sans TC", sans-serif';
ctx.fillText(subtitle, canvas.width / 2, 690);
}
} else {
ctx.font = '600 91px "Noto Serif TC", "Songti TC", serif';
ctx.fillText(main, canvas.width / 2, 102);
if (subtitle) {
ctx.font = '600 27px "Noto Sans TC", sans-serif';
ctx.fillText(subtitle, canvas.width / 2, 195);
}
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function addSign(
main,
subtitle,
width,
height,
x,
y,
z,
options = {}
) {
const texture = createSignTexture(main, subtitle, options);
const material = new THREE.MeshBasicMaterial({
map: texture,
side: THREE.DoubleSide,
toneMapped: false
});
const sign = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
material
);
sign.position.set(x, y, z);
building.add(sign);
return sign;
}
addSign(
"迪化街",
"DIHUA STREET · TAIPEI",
4.45,
1.05,
0,
7.92,
0.39,
{
background: "#1d403a",
foreground: "#f0d39b",
border: "#d2a35e"
}
);
addSign(
"永記雜貨",
"EVERGREEN GOODS",
3.15,
0.72,
-5.2,
3.38,
0.34,
{
background: "#573529",
foreground: "#ecd39e"
}
);
addSign(
"大稻埕茶行",
"DA DA CHENG TEA",
3.25,
0.72,
5.2,
3.38,
0.34,
{
background: "#233f39",
foreground: "#e7c986"
}
);
// Hanging sign under the arcade roof.
const hangingSign = addSign(
"迪化老街",
"百年商號",
2.55,
0.82,
0,
3.38,
2.58,
{
background: "#742f2b",
foreground: "#f2d18d",
border: "#c28c46"
}
);
box(building, 0.035, 0.42, 0.035, -0.88, 3.86, 2.58, 0x30251e);
box(building, 0.035, 0.42, 0.035, 0.88, 3.86, 2.58, 0x30251e);
// Vertical shop signs.
addSign(
"南北貨",
"TEA · DRIED GOODS",
0.68,
2.05,
-7.57,
2.38,
3.49,
{
vertical: true,
background: "#293f39",
foreground: "#ebce8c"
}
);
addSign(
"古早味",
"TAIPEI TEA",
0.68,
2.05,
7.58,
2.38,
3.49,
{
vertical: true,
background: "#71332c",
foreground: "#f0d49a"
}
);
// ------------------------------------------------------------
// Neighboring building fragments
// ------------------------------------------------------------
const neighborLeft = new THREE.Group();
const neighborRight = new THREE.Group();
scene.add(neighborLeft, neighborRight);
box(neighborLeft, 6.8, 7.6, 5.0, -12.95, 3.8, -1.7, 0x7f8175);
box(neighborLeft, 7.15, 0.24, 5.3, -12.95, 7.75, -1.7, 0x4b514e);
box(neighborLeft, 5.8, 2.5, 0.10, -12.95, 1.65, 0.86, 0x414b48);
box(neighborLeft, 6.8, 0.25, 3.1, -12.95, 3.65, 1.45, 0xa18d72);
box(neighborRight, 7.2, 8.4, 5.3, 13.25, 4.2, -1.9, 0x8a7467);
box(neighborRight, 7.55, 0.27, 5.55, 13.25, 8.53, -1.9, 0x494a47);
box(neighborRight, 6.1, 2.75, 0.10, 13.25, 1.73, 0.81, 0x3f4b49);
box(neighborRight, 7.2, 0.27, 3.2, 13.25, 4.02, 1.55, 0x9f866d);
for (const x of [-15.5, -12.6, -10.3]) {
box(neighborLeft, 1.35, 1.65, 0.12, x, 5.72, 0.86, 0x33474b);
box(neighborLeft, 0.07, 1.65, 0.08, x, 5.72, 0.95, 0x5a4939);
}
for (const x of [10.8, 13.4, 16.0]) {
box(neighborRight, 1.35, 1.65, 0.12, x, 6.00, 0.86, 0x35494c);
box(neighborRight, 0.07, 1.65, 0.08, x, 6.00, 0.95, 0x5a4939);
}
// ------------------------------------------------------------
// Lanterns and overhead utility wires
// ------------------------------------------------------------
const lanterns = [];
function addLantern(x, z) {
const pivot = new THREE.Group();
pivot.position.set(x, 3.96, z);
building.add(pivot);
box(pivot, 0.025, 0.42, 0.025, 0, -0.21, 0, 0x29221d);
box(pivot, 0.47, 0.56, 0.47, 0, -0.68, 0, redLantern);
box(pivot, 0.55, 0.08, 0.55, 0, -0.40, 0, 0xc0924c);
box(pivot, 0.55, 0.08, 0.55, 0, -0.96, 0, 0xc0924c);
box(pivot, 0.10, 0.20, 0.10, 0, -1.12, 0, 0xd1a654);
const light = new THREE.PointLight(0xff6338, 2.2, 3.2, 2);
light.position.set(0, -0.66, 0.15);
pivot.add(light);
lanterns.push(pivot);
}
addLantern(-3.8, 2.72);
addLantern(3.8, 2.72);
// Slightly angled wire segments crossing the street.
for (const z of [2.75, 3.05]) {
for (let i = 0; i < 8; i++) {
const segment = box(
scene,
2.35,
0.025,
0.025,
-8.2 + i * 2.35,
7.25 - Math.sin((i / 7) * Math.PI) * 0.38,
z,
0x282b29
);
segment.rotation.z = i < 4 ? -0.055 : 0.055;
}
}
// ------------------------------------------------------------
// Street furniture and voxel vegetation
// ------------------------------------------------------------
function addTree(x, z) {
const planter = new THREE.Group();
planter.position.set(x, 0, z);
scene.add(planter);
box(planter, 1.25, 0.55, 1.25, 0, 0.48, 0, 0x726a58);
box(planter, 1.05, 0.12, 1.05, 0, 0.79, 0, 0x4c4e36);
box(planter, 0.26, 1.90, 0.26, 0, 1.53, 0, 0x6e4e32);
box(planter, 1.65, 0.70, 1.15, 0, 2.75, 0, 0x466d48);
box(planter, 1.15, 0.80, 1.55, 0.30, 3.16, 0.12, 0x527d4f);
box(planter, 1.45, 0.55, 1.20, -0.35, 3.46, -0.10, 0x3e6844);
box(planter, 0.82, 0.75, 0.85, 0.15, 3.79, 0.05, 0x5e8754);
}
addTree(-10.25, 5.35);
addTree(10.25, 5.35);
function addBollard(x, z) {
box(scene, 0.22, 0.82, 0.22, x, 0.58, z, 0x3f4747);
box(scene, 0.29, 0.12, 0.29, x, 0.97, z, 0xc4a258);
box(scene, 0.31, 0.10, 0.31, x, 0.38, z, 0x303738);
}
for (const x of [-8.8, -4.4, 4.4, 8.8]) {
addBollard(x, 6.05);
}
// Waste bins and utility cabinet.
box(scene, 0.82, 1.15, 0.72, -8.65, 0.80, 4.95, 0x485653);
box(scene, 0.88, 0.10, 0.78, -8.65, 1.42, 4.95, 0x273332);
box(scene, 0.55, 0.82, 0.52, 8.55, 0.63, 5.10, 0x73786b);
box(scene, 0.08, 0.55, 0.03, 8.43, 0.68, 5.38, 0x303634);
// Stack of wooden crates beside a shop.
for (let i = 0; i < 3; i++) {
box(scene, 0.68, 0.44, 0.60, 7.05, 0.45 + i * 0.45, 2.18, 0x8a5b36);
box(scene, 0.72, 0.055, 0.64, 7.05, 0.59 + i * 0.45, 2.18, 0x513824);
}
// ------------------------------------------------------------
// Voxel pedestrians
// ------------------------------------------------------------
function addPerson(x, z, shirt, pants, skin, rotation = 0) {
const person = new THREE.Group();
person.position.set(x, 0.25, z);
person.rotation.y = rotation;
scene.add(person);
box(person, 0.19, 0.65, 0.22, -0.15, 0.34, 0, pants);
box(person, 0.19, 0.65, 0.22, 0.15, 0.34, 0, pants);
box(person, 0.53, 0.70, 0.30, 0, 1.02, 0, shirt);
box(person, 0.18, 0.68, 0.19, -0.37, 1.03, 0, shirt);
box(person, 0.18, 0.68, 0.19, 0.37, 1.03, 0, skin);
box(person, 0.39, 0.40, 0.36, 0, 1.61, 0, skin);
box(person, 0.42, 0.11, 0.38, 0, 1.83, 0, darkWood);
// A small shopping bag.
box(person, 0.30, 0.32, 0.16, 0.42, 0.70, 0.04, 0xc39d58);
}
addPerson(2.25, 2.25, 0x567a78, 0x343b3e, 0xc99770, -0.35);
addPerson(-3.55, 4.55, 0xb16d4b, 0x3c4244, 0xd3a57b, 0.70);
addPerson(8.05, 4.72, 0x626d8c, 0x2c3034, 0xbb8764, -1.10);
// ------------------------------------------------------------
// Voxel scooter parked at the curb
// ------------------------------------------------------------
const scooter = new THREE.Group();
scooter.position.set(5.75, 0.18, 7.22);
scooter.rotation.y = -0.06;
scene.add(scooter);
// Square wheels.
box(scooter, 0.20, 0.48, 0.48, -0.63, 0.33, 0, 0x242728);
box(scooter, 0.20, 0.48, 0.48, 0.68, 0.33, 0, 0x242728);
box(scooter, 0.04, 0.25, 0.25, -0.73, 0.33, 0, 0x8b8e84);
box(scooter, 0.04, 0.25, 0.25, 0.78, 0.33, 0, 0x8b8e84);
box(scooter, 1.18, 0.28, 0.48, 0.02, 0.60, 0, 0x35717b);
box(scooter, 0.52, 0.52, 0.48, -0.18, 0.89, 0, 0x32727b);
box(scooter, 0.60, 0.17, 0.52, -0.18, 1.22, 0, 0x252827);
box(scooter, 0.62, 0.16, 0.46, 0.53, 0.82, 0, 0x242728);
box(scooter, 0.08, 0.75, 0.08, 0.73, 1.13, 0, 0x777d78);
box(scooter, 0.70, 0.07, 0.07, 0.73, 1.49, 0, 0x777d78);
box(scooter, 0.21, 0.19, 0.23, 0.68, 1.40, 0, warmGlow);
// A few distant background roof blocks.
for (let i = 0; i < 9; i++) {
const height = 4.5 + (i % 3) * 1.2;
box(
scene,
3.2,
height,
3.5,
-22 + i * 5.5,
height / 2 - 0.1,
-12.5 - (i % 2) * 2,
i % 2 ? 0x71807f : 0x7c807a,
false
);
}
// ------------------------------------------------------------
// Custom camera controls — no external controls module
// ------------------------------------------------------------
const target = new THREE.Vector3(0, 3.25, 0);
let radius = 22.0;
let theta = 0.49;
let phi = 1.30;
let dragging = false;
let previousX = 0;
let previousY = 0;
function updateCamera() {
const sinPhi = Math.sin(phi);
camera.position.set(
target.x + radius * sinPhi * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * sinPhi * Math.cos(theta)
);
camera.lookAt(target);
}
function setView(name) {
if (name === "arcade") {
target.set(0, 2.20, 1.35);
radius = 11.5;
theta = 0.16;
phi = 1.36;
} else if (name === "detail") {
target.set(-0.1, 2.25, 0.3);
radius = 9.0;
theta = 0.31;
phi = 1.30;
} else {
target.set(0, 3.25, 0);
radius = 22.0;
theta = 0.49;
phi = 1.30;
}
updateCamera();
}
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
theta -= deltaX * 0.006;
phi -= deltaY * 0.005;
phi = THREE.MathUtils.clamp(phi, 0.48, 1.48);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (event?.pointerId !== undefined) {
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
radius = THREE.MathUtils.clamp(
radius * Math.exp(event.deltaY * 0.001),
5.5,
36
);
updateCamera();
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
let handled = true;
switch (event.key) {
case "ArrowLeft":
theta += 0.10;
break;
case "ArrowRight":
theta -= 0.10;
break;
case "ArrowUp":
phi = Math.max(0.48, phi - 0.07);
break;
case "ArrowDown":
phi = Math.min(1.48, phi + 0.07);
break;
default:
handled = false;
}
if (handled) {
event.preventDefault();
updateCamera();
}
});
document.querySelectorAll("[data-view]").forEach((button) => {
button.addEventListener("click", () => {
document.querySelectorAll("[data-view]").forEach((item) => {
item.classList.remove("active");
});
button.classList.add("active");
setView(button.dataset.view);
});
});
// ------------------------------------------------------------
// Resize and animation
// ------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
lanterns.forEach((lantern, index) => {
lantern.rotation.z =
Math.sin(elapsed * 0.8 + index * 1.7) * 0.025;
});
hangingSign.rotation.y =
Math.sin(elapsed * 0.55) * 0.012;
renderer.render(scene, camera);
}
updateCamera();
animate();
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 600);
});
</script>
</body>
</html>
```