Prompt specification
Build or customize the Three.js 3D scene "Jogger passing a reused Shanghai warehouse" 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: Jogger passing a reused Shanghai warehouse
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/jogger-passing-a-reused-shanghai-warehouse-x3022
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing Suzhou Creek's waterfront in Shanghai. Create a compact referenced creek-side vignette with public path, reused building entrance, and jogger. Keep the route continuous past the building without assuming every warehouse has the same use. Voxel style.
Working Three.js Starter (jogger-passing-a-reused-shanghai-warehouse-x3022):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Suzhou Creek — Adaptive Waterfront</title>
<style>
:root {
--ink: #18353b;
--muted: #587177;
--paper: rgba(249, 246, 235, 0.92);
--line: rgba(24, 53, 59, 0.16);
--accent: #e66b45;
--teal: #348d8b;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d8dfd7;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid var(--line);
background: var(--paper);
box-shadow: 0 14px 40px rgba(32, 53, 51, 0.12);
backdrop-filter: blur(10px);
}
.title-card {
top: 20px;
left: 20px;
width: min(390px, calc(100vw - 40px));
padding: 18px 20px 17px;
border-radius: 4px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
color: var(--teal);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
width: 22px;
height: 3px;
background: var(--accent);
content: "";
}
h1 {
margin: 0;
font-size: clamp(25px, 4vw, 39px);
font-weight: 760;
line-height: 1;
letter-spacing: -0.045em;
}
.subtitle {
margin-top: 9px;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.uses {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 14px;
}
.uses span {
padding: 5px 8px;
border: 1px solid rgba(52, 141, 139, 0.25);
border-radius: 999px;
background: rgba(52, 141, 139, 0.08);
color: #326f6e;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.controls {
right: 20px;
bottom: 20px;
display: flex;
gap: 8px;
padding: 8px;
border-radius: 4px;
}
button {
min-height: 38px;
padding: 0 13px;
border: 1px solid var(--line);
border-radius: 2px;
background: rgba(255, 255, 255, 0.72);
color: var(--ink);
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
}
button:hover {
border-color: rgba(52, 141, 139, 0.5);
background: white;
}
button:focus-visible {
outline: 2px solid var(--teal);
outline-offset: 2px;
}
.reference {
left: 20px;
bottom: 20px;
max-width: 350px;
padding: 13px 15px;
border-radius: 4px;
color: var(--muted);
font-size: 11px;
line-height: 1.55;
}
.reference strong {
display: block;
margin-bottom: 3px;
color: var(--ink);
font-size: 10px;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.legend-dot {
display: inline-block;
width: 7px;
height: 7px;
margin-right: 4px;
border-radius: 50%;
vertical-align: 1px;
}
#loading {
position: fixed;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
background: #d8dfd7;
color: var(--ink);
font-size: 12px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: opacity 0.35s ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 720px) {
.title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 14px 16px;
}
.subtitle {
max-width: 290px;
}
.uses {
margin-top: 10px;
}
.reference {
display: none;
}
.controls {
right: 12px;
bottom: 12px;
}
}
</style>
</head>
<body>
<div id="loading">Building Suzhou Creek…</div>
<section class="panel title-card" aria-label="Scene title">
<div class="eyebrow">Shanghai · 31.246° N</div>
<h1>Suzhou Creek</h1>
<p class="subtitle">
A compact voxel waterfront where an uninterrupted public path passes
industrial reuse, small businesses and everyday river life.
</p>
<div class="uses" aria-label="Different building uses">
<span>Café</span>
<span>Gallery</span>
<span>Maker space</span>
<span>Design studios</span>
</div>
</section>
<section class="panel reference" aria-label="Scene notes">
<strong>Place references</strong>
<span class="legend-dot" style="background:#b44f3d"></span>
Red-brick warehouse fabric ·
<span class="legend-dot" style="background:#253a3e"></span>
steel truss ·
<span class="legend-dot" style="background:#e66b45"></span>
active public edge
</section>
<nav class="panel controls" aria-label="Camera controls">
<button id="reset" type="button">Reset view</button>
<button id="top" type="button">Plan view</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 scene = new THREE.Scene();
scene.background = new THREE.Color(0xd8dfd7);
scene.fog = new THREE.Fog(0xd8dfd7, 58, 95);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
document.body.prepend(renderer.domElement);
const camera = new THREE.OrthographicCamera(
-20, 20, 13, -13, 0.1, 150
);
const hemi = new THREE.HemisphereLight(0xf7f1dc, 0x60756a, 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff0cf, 3.25);
sun.position.set(-18, 32, -20);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -30;
sun.shadow.camera.right = 30;
sun.shadow.camera.top = 25;
sun.shadow.camera.bottom = -25;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 80;
sun.shadow.bias = -0.00025;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9ec9d0, 0.85);
fill.position.set(22, 12, 18);
scene.add(fill);
// -------------------------------------------------------------------------
// Materials and geometry helpers
// -------------------------------------------------------------------------
const standard = (color, roughness = 0.88, metalness = 0) =>
new THREE.MeshStandardMaterial({ color, roughness, metalness });
const MAT = {
base: standard(0xb9b6a4),
ground: standard(0xc8c8b5),
paving: standard(0xd9c9a6),
pavingEdge: standard(0xa99c84),
cream: standard(0xe8ddc3),
pale: standard(0xd8d3bf),
brick: standard(0xa94f3d),
brickDark: standard(0x783b34),
brickLight: standard(0xc36d50),
mortar: standard(0xd0a487),
steel: standard(0x25383b, 0.55, 0.25),
darkSteel: standard(0x172b2e, 0.52, 0.35),
glass: standard(0x477f83, 0.28, 0.18),
glassLight: standard(0x7ea7a4, 0.34, 0.12),
wood: standard(0x8f6747),
woodDark: standard(0x533d30),
green: standard(0x50785b),
leaf: standard(0x668d5d),
leafLight: standard(0x82a56d),
leafDark: standard(0x426a50),
water: new THREE.MeshStandardMaterial({
color: 0x4f8e8a,
roughness: 0.36,
metalness: 0.08,
transparent: true,
opacity: 0.91
}),
ripple: new THREE.MeshBasicMaterial({
color: 0xb9d7c9,
transparent: true,
opacity: 0.54,
depthWrite: false
}),
orange: standard(0xe66b45),
navy: standard(0x244b59),
skin: standard(0xd4a27f),
white: standard(0xf3ebd7),
route: standard(0x2f9c99),
tactile: standard(0xd9a53d),
concrete: standard(0xaaa99c),
metalRoof: standard(0x718083, 0.7, 0.12)
};
function box(
width, height, depth, material,
x = 0, y = 0, z = 0,
parent = scene,
castShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function beamBetween(a, b, thickness, material, parent = scene) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(thickness, length, thickness),
material
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeFacadeSign(
title,
subtitle,
x, y, z,
width = 4.8,
height = 1.1,
background = "#20383a",
foreground = "#f5ead3"
) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = foreground;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = '700 68px "Microsoft YaHei", "Noto Sans SC", sans-serif';
ctx.fillText(title, 512, 91);
ctx.globalAlpha = 0.76;
ctx.font = '600 30px system-ui, sans-serif';
ctx.fillText(subtitle, 512, 177);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8, renderer.capabilities.getMaxAnisotropy()
);
const sign = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: texture,
side: THREE.DoubleSide,
toneMapped: false
})
);
sign.position.set(x, y, z);
sign.rotation.y = Math.PI;
scene.add(sign);
return sign;
}
// -------------------------------------------------------------------------
// Diorama base, creek and banks
// -------------------------------------------------------------------------
box(43, 0.8, 29, MAT.base, 0, -0.55, 2.3);
box(40, 0.48, 15.3, MAT.ground, 0, 0.02, 7.65);
// Creek surface.
box(40, 0.22, 10.8, MAT.water, 0, -0.03, -5.25, scene, false);
// North retaining wall and opposite bank.
box(40, 0.9, 0.42, MAT.brickDark, 0, 0.28, 0.08);
box(40, 0.45, 1.35, MAT.concrete, 0, -0.02, -11.15);
box(40, 0.8, 0.35, MAT.concrete, 0, 0.12, -10.55);
// A broad shadow-catching floor beyond the miniature.
box(
120, 0.1, 120, standard(0xd8dfd7),
0, -1.02, 0, scene, false
);
// -------------------------------------------------------------------------
// Continuous public path
// -------------------------------------------------------------------------
box(40, 0.16, 3.25, MAT.paving, 0, 0.35, 1.95);
box(40, 0.1, 0.22, MAT.pavingEdge, 0, 0.38, 0.4);
box(40, 0.1, 0.22, MAT.pavingEdge, 0, 0.38, 3.48);
// Paving joints.
for (let x = -19; x <= 19; x += 2.15) {
box(
0.045, 0.025, 3.0, MAT.pavingEdge,
x, 0.455, 1.95, scene, false
);
}
// The colored line makes the route visibly continuous past every entrance.
for (let x = -19.4; x < 20; x += 1.55) {
box(
0.83, 0.035, 0.1, MAT.route,
x, 0.475, 2.02, scene, false
);
}
// Waterfront railing.
for (let x = -19.5; x <= 19.5; x += 1.95) {
box(0.1, 1.18, 0.1, MAT.steel, x, 1.02, 0.5);
}
box(40, 0.1, 0.12, MAT.steel, 0, 1.57, 0.5);
box(40, 0.07, 0.09, MAT.steel, 0, 1.12, 0.5);
// Path marker.
box(0.12, 2.35, 0.12, MAT.steel, -18.4, 1.45, 3.7);
makeFacadeSign(
"苏州河滨水步道",
"PUBLIC CREEK WALK →",
-18.4, 2.45, 3.61,
3.25, 0.82,
"#d9c9a6",
"#18353b"
);
// -------------------------------------------------------------------------
// Buildings: distinct uses, shared industrial context
// -------------------------------------------------------------------------
function tallWindow(x, y, z, width = 1.05, height = 1.5, arched = false) {
box(
width + 0.18, height + 0.18, 0.13, MAT.darkSteel,
x, y, z
);
box(
width, height, 0.15,
Math.random() > 0.72 ? MAT.glassLight : MAT.glass,
x, y, z - 0.035,
scene,
false
);
box(
0.065, height, 0.17, MAT.darkSteel,
x, y, z - 0.055
);
if (arched) {
box(
width * 0.72, 0.24, 0.15, MAT.glass,
x, y + height * 0.58, z - 0.035,
scene,
false
);
box(
width * 0.4, 0.2, 0.15, MAT.glass,
x, y + height * 0.74, z - 0.035,
scene,
false
);
}
}
// Riverside café: older brick shell adapted with a green awning.
const cafeX = -10.3;
const cafeZ = 8.65;
const cafeW = 8.8;
const cafeD = 6.5;
const cafeH = 5.15;
const cafeFront = cafeZ - cafeD / 2;
box(cafeW, cafeH, cafeD, MAT.brick, cafeX, cafeH / 2 + 0.45, cafeZ);
box(cafeW + 0.35, 0.34, cafeD + 0.35, MAT.brickDark, cafeX, cafeH + 0.57, cafeZ);
box(cafeW - 0.45, 0.08, cafeD - 0.4, MAT.metalRoof, cafeX, cafeH + 0.76, cafeZ);
for (const dx of [-4.05, 4.05]) {
box(0.32, cafeH, 0.2, MAT.brickLight, cafeX + dx, cafeH / 2 + 0.45, cafeFront - 0.02);
}
[-3.15, -1.9, 1.9, 3.15].forEach((dx, index) => {
tallWindow(
cafeX + dx,
index % 2 === 0 ? 2.25 : 4.02,
cafeFront - 0.05,
1.05,
1.42,
true
);
});
// Café entrance and green folding awning.
box(1.55, 2.45, 0.14, MAT.darkSteel, cafeX + 0.35, 1.67, cafeFront - 0.08);
box(1.25, 2.18, 0.16, MAT.glass, cafeX + 0.35, 1.62, cafeFront - 0.17);
box(0.08, 2.18, 0.18, MAT.steel, cafeX + 0.35, 1.62, cafeFront - 0.18);
for (let i = 0; i < 5; i++) {
box(
1.02, 0.11, 1.05,
i % 2 === 0 ? MAT.green : MAT.leafDark,
cafeX - 2.45 + i * 1.02,
3.45,
cafeFront - 0.55
);
}
box(
5.35, 0.16, 1.15, MAT.green,
cafeX - 0.25, 3.36, cafeFront - 0.55
);
makeFacadeSign(
"河岸咖啡",
"RIVERSIDE CAFE",
cafeX - 0.25, 4.55, cafeFront - 0.14,
4.65, 0.94,
"#315c4b",
"#f2e7cb"
);
// Small café tables stay on the building apron, not on the public path.
for (const dx of [-2.55, 2.25]) {
box(0.75, 0.1, 0.75, MAT.wood, cafeX + dx, 0.88, cafeFront - 0.9);
box(0.12, 0.6, 0.12, MAT.steel, cafeX + dx, 0.56, cafeFront - 0.9);
box(0.48, 0.12, 0.48, MAT.green, cafeX + dx, 1.02, cafeFront - 0.9);
}
// Main warehouse: retained brick shell with a reused loading-hall entrance.
const hallX = 3.25;
const hallZ = 8.72;
const hallW = 9.25;
const hallD = 6.75;
const hallH = 6.25;
const hallFront = hallZ - hallD / 2;
box(hallW, hallH, hallD, MAT.brick, hallX, hallH / 2 + 0.45, hallZ);
box(hallW + 0.42, 0.38, hallD + 0.4, MAT.brickDark, hallX, hallH + 0.64, hallZ);
box(hallW - 0.5, 0.09, hallD - 0.5, MAT.metalRoof, hallX, hallH + 0.86, hallZ);
// Brick banding and pilasters retain the warehouse rhythm.
box(hallW, 0.2, 0.16, MAT.brickLight, hallX, 3.55, hallFront - 0.05);
box(hallW, 0.18, 0.15, MAT.brickLight, hallX, 5.67, hallFront - 0.05);
for (const dx of [-4.25, -2.85, 2.85, 4.25]) {
box(0.3, hallH, 0.18, MAT.brickLight, hallX + dx, hallH / 2 + 0.45, hallFront - 0.03);
}
[-3.2, -1.45, 1.45, 3.2].forEach((dx, index) => {
tallWindow(
hallX + dx,
index % 2 === 0 ? 2.15 : 4.42,
hallFront - 0.08,
1.1,
1.48,
true
);
});
// Reused entrance: retained structural portal with a new glazed insertion.
box(2.7, 3.38, 1.35, MAT.brickLight, hallX, 2.12, hallFront - 0.63);
box(2.25, 2.9, 0.12, MAT.darkSteel, hallX, 1.86, hallFront - 1.34);
box(1.92, 2.58, 0.16, MAT.glass, hallX, 1.77, hallFront - 1.43);
box(0.09, 2.58, 0.19, MAT.steel, hallX, 1.77, hallFront - 1.46);
box(2.38, 0.22, 0.18, MAT.woodDark, hallX, 3.4, hallFront - 1.36);
box(0.25, 3.05, 0.25, MAT.woodDark, hallX - 1.16, 1.92, hallFront - 1.34);
box(0.25, 3.05, 0.25, MAT.woodDark, hallX + 1.16, 1.92, hallFront - 1.34);
// Tactile landing and a short connection to the continuous promenade.
box(2.2, 0.1, 1.18, MAT.pavingEdge, hallX, 0.48, hallFront - 1.82);
box(2.0, 0.05, 0.32, MAT.tactile, hallX, 0.55, hallFront - 2.02);
makeFacadeSign(
"1932 仓库",
"GALLERY + MAKER SPACE",
hallX, 4.7, hallFront - 0.16,
5.05, 1.04,
"#25383b",
"#f3e7cc"
);
// Existing loading number retained beside the new entrance.
makeFacadeSign(
"03",
"REUSE",
hallX + 2.05, 2.15, hallFront - 0.18,
0.82, 1.12,
"#6f3d33",
"#e8d6b9"
);
// Rooftop industrial details.
box(0.75, 2.1, 0.75, MAT.brickDark, hallX + 2.6, hallH + 1.75, hallZ + 1.5);
box(0.86, 0.25, 0.86, MAT.cream, hallX + 2.6, hallH + 2.28, hallZ + 1.5);
box(1.65, 0.7, 1.35, MAT.metalRoof, hallX - 2.4, hallH + 1.12, hallZ + 0.8);
// Design studios: a lighter, renovated building with a distinct entrance.
const studioX = 15.05;
const studioZ = 8.7;
const studioW = 8.05;
const studioD = 6.5;
const studioH = 5.7;
const studioFront = studioZ - studioD / 2;
box(studioW, studioH, studioD, MAT.pale, studioX, studioH / 2 + 0.45, studioZ);
box(studioW + 0.32, 0.35, studioD + 0.34, MAT.concrete, studioX, studioH + 0.61, studioZ);
for (let row = 0; row < 2; row++) {
for (let col = 0; col < 4; col++) {
box(
1.16, 1.32, 0.13, MAT.steel,
studioX - 2.8 + col * 1.87,
2.05 + row * 2.25,
studioFront - 0.05
);
box(
0.96, 1.12, 0.16, MAT.glassLight,
studioX - 2.8 + col * 1.87,
2.05 + row * 2.25,
studioFront - 0.14,
scene,
false
);
}
}
box(2.1, 2.8, 0.9, MAT.steel, studioX, 1.82, studioFront - 0.38);
box(1.78, 2.5, 0.15, MAT.glass, studioX, 1.73, studioFront - 0.9);
box(1.45, 0.08, 1.2, MAT.pavingEdge, studioX, 0.48, studioFront - 1.15);
makeFacadeSign(
"沿岸设计",
"DESIGN STUDIOS",
studioX, 4.92, studioFront - 0.13,
4.45, 0.95,
"#e5dcc5",
"#23474b"
);
// A vertical studio marker distinguishes this use from the other sheds.
box(0.13, 3.0, 0.65, MAT.orange, studioX + 3.55, 2.65, studioFront - 0.25);
for (let i = 0; i < 6; i++) {
box(
0.15, 0.12, 0.7, MAT.cream,
studioX + 3.55, 1.55 + i * 0.4, studioFront - 0.25
);
}
// -------------------------------------------------------------------------
// Trees, benches, lamps and bollards
// -------------------------------------------------------------------------
function makeTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.42, z);
group.scale.setScalar(scale);
scene.add(group);
box(1.25, 0.3, 1.25, MAT.concrete, 0, 0.12, 0, group);
box(0.28, 2.5, 0.28, MAT.wood, 0, 1.45, 0, group);
box(0.56, 0.18, 0.5, MAT.leafDark, 0.23, 2.55, 0, group);
box(1.65, 1.25, 1.5, MAT.leaf, 0, 3.1, 0, group);
box(1.25, 1.2, 1.2, MAT.leafLight, -0.6, 3.75, 0.12, group);
box(1.2, 1.15, 1.1, MAT.leafDark, 0.7, 3.7, -0.15, group);
box(0.95, 0.95, 0.95, MAT.leaf, 0.15, 4.35, 0.05, group);
}
makeTree(-16.0, 4.25, 0.95);
makeTree(-5.2, 4.35, 0.82);
makeTree(10.45, 4.3, 0.86);
makeTree(19.0, 4.35, 0.9);
function makeBench(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.44, z);
group.rotation.y = rotation;
scene.add(group);
box(1.8, 0.13, 0.5, MAT.wood, 0, 0.55, 0, group);
box(1.8, 0.65, 0.11, MAT.wood, 0, 0.92, 0.23, group);
box(0.12, 0.48, 0.42, MAT.steel, -0.68, 0.25, 0, group);
box(0.12, 0.48, 0.42, MAT.steel, 0.68, 0.25, 0, group);
}
makeBench(-7.7, 4.0, Math.PI);
makeBench(9.0, 4.05, Math.PI);
makeBench(-15.8, 4.0, Math.PI);
function makeLamp(x, z) {
box(0.12, 3.25, 0.12, MAT.steel, x, 2.05, z);
box(0.8, 0.1, 0.16, MAT.steel, x + 0.3, 3.62, z);
box(0.42, 0.18, 0.32, MAT.cream, x + 0.58, 3.5, z);
}
makeLamp(-12.8, 3.75);
makeLamp(7.7, 3.75);
makeLamp(18.2, 3.75);
for (let x = -18; x <= 18; x += 3.2) {
box(0.12, 0.65, 0.12, MAT.steel, x, 0.77, 3.4);
}
// -------------------------------------------------------------------------
// Steel truss bridge across the creek
// -------------------------------------------------------------------------
const bridgeX = -14.7;
box(2.45, 0.18, 11.1, MAT.steel, bridgeX, 0.95, -5.15);
box(2.2, 0.06, 10.7, MAT.concrete, bridgeX, 1.07, -5.15);
for (const side of [-1.12, 1.12]) {
const x = bridgeX + side;
box(0.13, 0.13, 10.8, MAT.darkSteel, x, 3.22, -5.15);
for (let z = -10.4; z <= 0.1; z += 1.7) {
box(0.12, 2.18, 0.12, MAT.darkSteel, x, 2.15, z);
}
for (let z = -10.35; z < 0; z += 1.7) {
beamBetween(
[x, 1.15, z],
[x, 3.16, z + 1.7],
0.11,
MAT.darkSteel
);
}
}
// -------------------------------------------------------------------------
// Boat, water marks and opposite-bank fragments
// -------------------------------------------------------------------------
const boat = new THREE.Group();
boat.position.set(-4.1, 0.12, -5.85);
scene.add(boat);
box(5.4, 0.45, 1.85, MAT.woodDark, 0, 0.18, 0, boat);
box(4.8, 0.1, 1.55, MAT.wood, 0, 0.45, 0, boat);
box(1.4, 1.15, 1.3, MAT.cream, 1.45, 1.03, 0, boat);
box(1.1, 0.45, 0.08, MAT.glass, 1.45, 1.17, -0.68, boat);
box(1.65, 0.7, 1.45, MAT.brickLight, -0.85, 0.82, 0, boat);
box(0.08, 2.3, 0.08, MAT.steel, 1.95, 2.3, 0, boat);
const ripples = [];
for (let i = 0; i < 34; i++) {
const ripple = box(
0.65 + Math.random() * 1.8,
0.025,
0.07 + Math.random() * 0.1,
MAT.ripple,
-19 + Math.random() * 38,
0.105,
-9.8 + Math.random() * 9.3,
scene,
false
);
ripple.userData.speed = 0.025 + Math.random() * 0.035;
ripples.push(ripple);
}
// Low opposite-bank buildings create depth without competing with the reuse.
const oppositeColors = [0xa6aaa0, 0xb4ab98, 0x8f9a92, 0xb8ac94];
for (let i = 0; i < 6; i++) {
const x = -17 + i * 6.6;
const h = 2.3 + (i % 3) * 0.65;
box(
4.9, h, 1.65,
standard(oppositeColors[i % oppositeColors.length]),
x, h / 2 - 0.02, -11.15
);
box(
0.45, 1.7 + (i % 2) * 0.6, 0.45,
MAT.brickDark,
x + 1.1, h + 0.85, -11.1
);
}
// -------------------------------------------------------------------------
// Jogger: a small animated voxel figure
// -------------------------------------------------------------------------
const jogger = new THREE.Group();
scene.add(jogger);
const body = new THREE.Group();
jogger.add(body);
box(0.58, 0.76, 0.38, MAT.orange, 0, 1.28, 0, body);
box(0.54, 0.28, 0.36, MAT.navy, 0, 0.78, 0, body);
box(0.4, 0.42, 0.38, MAT.skin, 0, 1.94, 0, body);
box(0.43, 0.15, 0.4, MAT.woodDark, 0, 2.15, 0, body);
box(0.12, 0.12, 0.4, MAT.skin, 0.24, 1.98, 0, body);
box(0.5, 0.12, 0.45, MAT.white, 0, 0.63, 0, body);
function makeLimb(material, length, width, depth) {
const pivot = new THREE.Group();
box(width, length, depth, material, 0, -length / 2, 0, pivot);
body.add(pivot);
return pivot;
}
const leftArm = makeLimb(MAT.skin, 0.58, 0.15, 0.15);
const rightArm = makeLimb(MAT.skin, 0.58, 0.15, 0.15);
leftArm.position.set(0, 1.57, 0.29);
rightArm.position.set(0, 1.57, -0.29);
const leftLeg = makeLimb(MAT.navy, 0.64, 0.18, 0.18);
const rightLeg = makeLimb(MAT.navy, 0.64, 0.18, 0.18);
leftLeg.position.set(0, 0.76, 0.13);
rightLeg.position.set(0, 0.76, -0.13);
box(
0.31, 0.15, 0.18, MAT.white,
0.09, -0.69, 0, leftLeg
);
box(
0.31, 0.15, 0.18, MAT.white,
0.09, -0.69, 0, rightLeg
);
// A small pedestrian adds scale without competing with the jogger.
const pedestrian = new THREE.Group();
pedestrian.position.set(-7.6, 0.48, 2.0);
scene.add(pedestrian);
box(0.48, 0.7, 0.34, MAT.cream, 0, 1.18, 0, pedestrian);
box(0.43, 0.22, 0.32, MAT.navy, 0, 0.73, 0, pedestrian);
box(0.34, 0.37, 0.34, MAT.wood, 0, 1.77, 0, pedestrian);
box(0.13, 0.64, 0.13, MAT.navy, -0.12, 0.3, 0, pedestrian);
box(0.13, 0.64, 0.13, MAT.navy, 0.12, 0.3, 0, pedestrian);
box(0.12, 0.57, 0.12, MAT.wood, -0.3, 1.22, 0, pedestrian);
box(0.12, 0.57, 0.12, MAT.wood, 0.3, 1.22, 0, pedestrian);
// -------------------------------------------------------------------------
// Custom camera controls — no addons
// -------------------------------------------------------------------------
const view = {
azimuth: 2.38,
polar: 1.02,
zoom: 1,
target: new THREE.Vector3(0, 1.3, 2.0)
};
const initialView = {
azimuth: view.azimuth,
polar: view.polar,
zoom: view.zoom,
target: view.target.clone()
};
function updateCamera() {
const sinPolar = Math.sin(view.polar);
const cosPolar = Math.cos(view.polar);
camera.position.set(
view.target.x + 42 * sinPolar * Math.sin(view.azimuth),
view.target.y + 42 * cosPolar,
view.target.z + 42 * sinPolar * Math.cos(view.azimuth)
);
camera.lookAt(view.target);
camera.zoom = view.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const aspect = window.innerWidth / window.innerHeight;
const halfHeight = Math.max(13, 22 / aspect);
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
updateCamera();
}
window.addEventListener("resize", resize);
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
view.azimuth -= dx * 0.006;
view.polar = THREE.MathUtils.clamp(
view.polar + dy * 0.0045,
0.12,
1.38
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (event.pointerId !== undefined &&
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();
view.zoom = THREE.MathUtils.clamp(
view.zoom * Math.exp(-event.deltaY * 0.001),
0.68,
2.15
);
updateCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", () => {
view.azimuth = initialView.azimuth;
view.polar = initialView.polar;
view.zoom = initialView.zoom;
view.target.copy(initialView.target);
updateCamera();
});
document.getElementById("reset").addEventListener("click", () => {
view.azimuth = initialView.azimuth;
view.polar = initialView.polar;
view.zoom = initialView.zoom;
view.target.copy(initialView.target);
updateCamera();
});
document.getElementById("top").addEventListener("click", () => {
view.azimuth = 0;
view.polar = 0.12;
view.zoom = 0.95;
view.target.set(0, 0.8, 1.5);
updateCamera();
});
resize();
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
let runPhase = 0;
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
// Jogger follows the continuous route and never enters the buildings.
runPhase += delta * 7.2;
const travel = (elapsed * 1.35) % 35.5;
jogger.position.x = -17.7 + travel;
jogger.position.z = 2.02;
jogger.position.y = 0.48 + Math.abs(Math.sin(runPhase)) * 0.045;
const stride = Math.sin(runPhase) * 0.72;
leftLeg.rotation.z = stride;
rightLeg.rotation.z = -stride;
leftArm.rotation.z = -stride * 0.78;
rightArm.rotation.z = stride * 0.78;
body.rotation.z = Math.sin(runPhase * 2) * 0.025;
// Gentle walking motion for the stationary-scale pedestrian.
pedestrian.position.y = 0.48 + Math.sin(elapsed * 2.1) * 0.012;
for (const ripple of ripples) {
ripple.position.x += ripple.userData.speed * delta;
if (ripple.position.x > 20.5) {
ripple.position.x = -20.5;
}
}
boat.position.y = 0.12 + Math.sin(elapsed * 0.7) * 0.025;
boat.rotation.z = Math.sin(elapsed * 0.45) * 0.003;
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
document.getElementById("loading").classList.add("hidden");
animate();
</script>
</body>
</html>
```