Prompt specification
Build or customize the Three.js 3D scene "Khlong Bang Luang canal-neighborhood slice" 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: Khlong Bang Luang canal-neighborhood slice
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/khlong-bang-luang-canal-neighborhood-slice-x2967
Scene Description Prompt:
Bangkok's Khlong Bang Luang in voxels: wooden canal houses, footbridge, and cultural venue frontage. Build one HTML scene with Three.js from cdnjs.
Acceptance checks: Use Baan Silapin (Khlong Bang Luang Artist’s House) as the sole named cultural frontage. The Thai Ministry of Foreign Affairs Bangkok guide identifies the community, its Artist’s House and the wooden buildings: https://image.mfa.go.th/mfa/0/uK8Kxy2oDV/Bangkok_2019.pdf . Keep the wood river frontage and a small clearly schematic local footbridge. Do not claim bridge dimensions, exact colors or an exact shop list.
Return a single complete HTML document. It must work in a sandbox that allows scripts, with the cdnjs Three.js r160 module and inline CSS. Use procedural geometry and local button handlers; no native form submission, pointer lock, remote assets, or runtime network requests besides Three.js.
Working Three.js Starter (khlong-bang-luang-canal-neighborhood-slice-x2967):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="#b9cbc2">
<title>Khlong Bang Luang in Voxels</title>
<style>
:root {
color-scheme: light;
--ink: #24332e;
--paper: rgba(248, 244, 230, 0.94);
--line: rgba(45, 59, 52, 0.2);
--accent: #7b4b36;
--accent-dark: #49352c;
--shadow: 0 18px 60px rgba(35, 49, 43, 0.2);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b9cbc2;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
overscroll-behavior: none;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
outline: none;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
linear-gradient(180deg, rgba(32, 48, 42, 0.13), transparent 24%),
radial-gradient(circle at 52% 44%, transparent 48%, rgba(31, 46, 40, 0.13) 100%);
z-index: 2;
}
.panel {
position: fixed;
z-index: 5;
top: clamp(18px, 4vw, 42px);
left: clamp(18px, 4vw, 48px);
width: min(430px, calc(100vw - 36px));
padding: 24px 26px 22px;
border: 1px solid rgba(255, 255, 255, 0.62);
border-radius: 4px;
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(14px) saturate(0.9);
-webkit-backdrop-filter: blur(14px) saturate(0.9);
}
.eyebrow {
margin-bottom: 11px;
color: #66766f;
font-size: 0.68rem;
font-weight: 750;
letter-spacing: 0.17em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(2rem, 4vw, 3.25rem);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
h1 span {
color: var(--accent);
font-style: italic;
}
.intro {
margin: 17px 0 0;
max-width: 38em;
color: #46554f;
font-size: 0.92rem;
line-height: 1.6;
}
.intro strong {
color: #2d3c36;
font-weight: 700;
}
.note {
display: flex;
align-items: center;
gap: 9px;
margin-top: 17px;
padding-top: 14px;
border-top: 1px solid var(--line);
color: #718078;
font-size: 0.72rem;
line-height: 1.45;
}
.note::before {
width: 8px;
height: 8px;
flex: 0 0 auto;
border-radius: 50%;
background: #9b6a4d;
box-shadow: 0 0 0 4px rgba(155, 106, 77, 0.13);
content: "";
}
.controls {
position: fixed;
z-index: 6;
right: clamp(18px, 3vw, 42px);
bottom: clamp(18px, 3vw, 34px);
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px;
max-width: calc(100vw - 36px);
padding: 8px;
border: 1px solid rgba(255, 255, 255, 0.56);
border-radius: 5px;
background: rgba(248, 244, 230, 0.86);
box-shadow: 0 12px 38px rgba(35, 49, 43, 0.16);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
button {
appearance: none;
min-height: 38px;
padding: 0 15px;
border: 1px solid rgba(50, 65, 58, 0.17);
border-radius: 3px;
background: rgba(255, 255, 255, 0.5);
color: #314039;
font: inherit;
font-size: 0.76rem;
font-weight: 700;
letter-spacing: 0.02em;
cursor: pointer;
transition: transform 150ms ease, background 150ms ease, color 150ms ease,
border-color 150ms ease;
}
button:hover {
transform: translateY(-1px);
border-color: rgba(50, 65, 58, 0.32);
background: rgba(255, 255, 255, 0.88);
}
button:focus-visible {
outline: 3px solid rgba(123, 75, 54, 0.32);
outline-offset: 2px;
}
button.active,
button[aria-pressed="true"] {
border-color: var(--accent-dark);
background: var(--accent-dark);
color: #fffaf0;
}
.hint {
position: fixed;
z-index: 5;
left: clamp(18px, 4vw, 48px);
bottom: clamp(20px, 3vw, 34px);
padding: 8px 11px;
border-radius: 3px;
background: rgba(248, 244, 230, 0.68);
color: #53625c;
font-size: 0.68rem;
font-weight: 650;
letter-spacing: 0.04em;
pointer-events: none;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
}
.labels {
position: fixed;
inset: 0;
z-index: 4;
pointer-events: none;
}
.labels-off .scene-label {
display: none;
}
.scene-label {
position: absolute;
width: max-content;
max-width: 250px;
padding: 7px 10px;
transform: translate(-50%, -100%);
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 3px;
background: rgba(247, 242, 224, 0.9);
box-shadow: 0 8px 24px rgba(37, 48, 43, 0.16);
color: #35453e;
font-size: 0.66rem;
font-weight: 750;
letter-spacing: 0.035em;
text-align: center;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
transition: opacity 180ms ease;
}
.scene-label::after {
position: absolute;
left: 50%;
bottom: -6px;
width: 1px;
height: 6px;
background: rgba(53, 69, 62, 0.48);
content: "";
}
.scene-label.venue {
padding: 9px 13px;
border-color: rgba(100, 65, 47, 0.28);
background: rgba(250, 244, 224, 0.95);
color: #5b3e30;
font-family: Georgia, "Times New Roman", serif;
font-size: 0.78rem;
font-weight: 600;
letter-spacing: 0;
}
.loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #b9cbc2;
color: #43534c;
font-size: 0.72rem;
font-weight: 750;
letter-spacing: 0.16em;
text-transform: uppercase;
transition: opacity 500ms ease, visibility 500ms ease;
}
.loading.ready {
visibility: hidden;
opacity: 0;
}
.loading span {
display: inline-block;
animation: breathe 1.4s ease-in-out infinite;
}
@keyframes breathe {
50% { opacity: 0.42; }
}
@media (max-width: 720px) {
.panel {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
padding: 18px 19px 16px;
}
h1 {
font-size: 2.05rem;
}
.intro {
margin-top: 12px;
font-size: 0.82rem;
line-height: 1.5;
}
.note {
margin-top: 12px;
padding-top: 11px;
}
.controls {
right: 14px;
bottom: 14px;
left: 14px;
justify-content: center;
max-width: none;
}
button {
min-height: 35px;
padding: 0 12px;
font-size: 0.7rem;
}
.hint {
display: none;
}
.scene-label {
font-size: 0.6rem;
}
}
@media (max-height: 620px) and (min-width: 721px) {
.panel {
top: 16px;
padding: 17px 21px;
}
h1 {
font-size: 2.2rem;
}
.intro {
margin-top: 10px;
}
.note {
margin-top: 10px;
}
}
</style>
</head>
<body>
<canvas id="scene" tabindex="0" aria-label="Interactive voxel view of Khlong Bang Luang"></canvas>
<div class="vignette" aria-hidden="true"></div>
<header class="panel">
<div class="eyebrow">Bangkok · interpretive voxel study</div>
<h1>Khlong Bang Luang<br><span>in voxels</span></h1>
<p class="intro">
Wooden canal houses line the near bank, a small schematic footbridge crosses the
water, and <strong>Baan Silapin (Khlong Bang Luang Artist’s House)</strong>
forms the named cultural frontage on the far side.
</p>
<div class="note">A stylized interpretation, not a surveyed reconstruction.</div>
</header>
<div class="labels" id="labels" aria-hidden="true">
<div class="scene-label venue" id="label-venue">Baan Silapin · Khlong Bang Luang Artist’s House</div>
<div class="scene-label" id="label-homes">wooden canal houses</div>
<div class="scene-label" id="label-bridge">small schematic footbridge</div>
</div>
<div class="controls" role="group" aria-label="Scene views">
<button type="button" class="active" data-view="overview">Overview</button>
<button type="button" data-view="venue">Venue</button>
<button type="button" data-view="homes">Houses</button>
<button type="button" data-view="bridge">Footbridge</button>
<button type="button" id="toggle-labels" aria-pressed="true">Labels</button>
</div>
<div class="hint">Drag to orbit · wheel or pinch to zoom · arrow keys also work</div>
<div class="loading" id="loading"><span>Building the canal edge…</span></div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.getElementById("scene");
const loading = document.getElementById("loading");
const labelsRoot = document.getElementById("labels");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xb9cbc2);
scene.fog = new THREE.Fog(0xb9cbc2, 62, 142);
const camera = new THREE.PerspectiveCamera(
window.innerWidth < 700 ? 50 : 42,
window.innerWidth / window.innerHeight,
0.1,
220
);
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setSize(window.innerWidth, window.innerHeight, false);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const hemi = new THREE.HemisphereLight(0xf7f1dc, 0x53685d, 2.05);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffe7bd, 3.15);
sun.position.set(-27, 42, 28);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -54;
sun.shadow.camera.right = 54;
sun.shadow.camera.top = 44;
sun.shadow.camera.bottom = -44;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 115;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9dc8ce, 0.65);
fill.position.set(30, 18, -30);
scene.add(fill);
const standard = (color, options = {}) => new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0,
flatShading: true,
...options
});
const materials = {
earth: standard(0x746d58),
bank: standard(0x879779),
path: standard(0xb0a58a),
water: standard(0x477f80, {
roughness: 0.42,
metalness: 0.08,
transparent: true,
opacity: 0.94
}),
ripple: standard(0xa4c5bd, {
roughness: 0.5,
transparent: true,
opacity: 0.48
}),
stone: standard(0x8b8d7c),
stoneDark: standard(0x74796c),
stoneLight: standard(0x9b9c89),
wood: standard(0x916849),
woodLight: standard(0xac805a),
woodDark: standard(0x654a39),
woodPale: standard(0xbe986c),
roof: standard(0x743f35),
roofLight: standard(0x875044),
roofDark: standard(0x573b33),
window: standard(0x30433f, {
roughness: 0.38,
metalness: 0.08
}),
cream: standard(0xe0d3ad),
teal: standard(0x4e8b87),
blue: standard(0x567d96),
ochre: standard(0xc18c50),
terracotta: standard(0xa75f49),
leaf: standard(0x547859),
leafLight: standard(0x6e8b61),
leafDark: standard(0x3f624c),
trunk: standard(0x6b523d),
dark: standard(0x35433e),
skin: standard(0xb98261),
shirt: standard(0xd5c493),
shirtBlue: standard(0x567c87)
};
function box(w, h, d, x, y, z, material, parent = scene, castShadow = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), material);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
let seed = 73241;
function random() {
seed |= 0;
seed = (seed + 0x6D2B79F5) | 0;
let t = Math.imul(seed ^ (seed >>> 15), 1 | seed);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
}
const animatedRipples = [];
// Diorama base, banks, canal and paths.
box(84, 0.8, 49, 0, -0.88, 0, materials.earth);
box(82, 1.52, 10.2, 0, 0.12, 11.35, materials.bank);
box(82, 1.52, 10.2, 0, 0.12, -11.35, materials.bank);
box(82, 0.28, 12.2, 0, -0.07, 0, materials.water, scene, false);
box(80, 0.16, 1.72, 0, 0.95, 6.93, materials.path);
box(80, 0.16, 1.72, 0, 0.95, -6.93, materials.path);
for (const side of [-1, 1]) {
for (let x = -39; x <= 39; x += 3.9) {
const wallMaterial = random() > 0.5 ? materials.stone : materials.stoneDark;
box(3.74, 0.74, 0.38, x, 0.47, side * 6.15, wallMaterial);
box(3.74, 0.1, 0.48, x, 0.88, side * 6.15, materials.stoneLight);
}
}
// Quiet water highlights.
for (let i = 0; i < 44; i++) {
const ripple = box(
0.7 + random() * 1.8,
0.025,
0.07 + random() * 0.08,
-39 + random() * 78,
0.09 + random() * 0.015,
-5.5 + random() * 11,
materials.ripple,
scene,
false
);
ripple.rotation.y = (random() - 0.5) * 0.16;
animatedRipples.push({
mesh: ripple,
speed: 0.12 + random() * 0.28
});
}
function makeTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.9, z);
group.scale.setScalar(scale);
scene.add(group);
box(0.52, 3.1, 0.52, 0, 1.55, 0, materials.trunk, group);
box(2.8, 1.6, 2.5, 0, 3.35, 0, materials.leafDark, group);
box(2.15, 1.45, 2.15, -0.35, 4.35, 0.15, materials.leaf, group);
box(1.45, 1.25, 1.5, 0.75, 4.25, -0.25, materials.leafLight, group);
box(1.2, 0.85, 1.15, -0.5, 5.1, 0.1, materials.leafLight, group);
}
[
[-33, -15, 1.05], [-25, -17, 0.85], [-6, -16, 1.0], [2, -18, 0.8],
[17, -16, 1.0], [25, -17, 0.9], [34, -15, 1.05],
[-29, 15, 0.9], [-13, 16, 1.0], [-7, 15, 0.75], [10, 17, 0.9],
[31, 17, 1.05], [37, 14, 0.8]
].forEach(([x, z, s]) => makeTree(x, z, s));
// Quiet, unlabelled forms beyond the far bank.
const distantMaterials = [standard(0x87968a), standard(0x91a096), standard(0x7e9188)];
for (let i = 0; i < 9; i++) {
const h = 3.5 + random() * 4.5;
const w = 4 + random() * 6;
box(
w,
h,
4 + random() * 3,
-31 + i * 7.7 + random() * 1.5,
0.9 + h / 2,
-23 - random() * 2,
distantMaterials[i % distantMaterials.length]
);
}
function addWindow(parent, x, y, z, w = 1.18, h = 1.28) {
box(w + 0.28, h + 0.28, 0.12, x, y, z, materials.woodDark, parent);
box(w, h, 0.15, x, y, z + 0.025, materials.window, parent);
box(0.06, h, 0.18, x, y, z + 0.07, materials.woodPale, parent);
box(w, 0.06, 0.18, x, y, z + 0.07, materials.woodPale, parent);
box(w + 0.38, 0.16, 0.42, x, y - h / 2 - 0.18, z + 0.07, materials.woodLight, parent);
}
function addRoof(group, width, depth, top, roofMaterial) {
const fullDepth = depth + 1.05;
for (let i = 0; i < 4; i++) {
const layerDepth = fullDepth * (1 - i * 0.225);
box(
width + 1.05,
0.42,
layerDepth,
0,
top + 0.25 + i * 0.39,
0,
i === 0 ? roofMaterial : (i % 2 ? materials.roofDark : roofMaterial),
group
);
}
box(width + 1.15, 0.16, 0.28, 0, top + 1.78, 0, materials.woodDark, group);
}
function makeHouse(x, width, depth, height, wallMaterial, roofMaterial, variant) {
const group = new THREE.Group();
group.position.set(x, 0, 10.25);
scene.add(group);
const base = 1.08;
const front = -depth / 2;
box(width, height, depth, 0, base + height / 2, 0, wallMaterial, group);
box(width + 0.25, 0.28, depth + 0.2, 0, base + 0.08, 0, materials.woodDark, group);
// Narrow vertical boards articulate the river-facing facade.
const plankCount = Math.max(5, Math.floor(width / 0.65));
for (let i = 1; i < plankCount; i++) {
const px = -width / 2 + (width * i) / plankCount;
box(0.055, height - 0.15, 0.075, px, base + height / 2, front - 0.055, materials.woodDark, group);
}
box(width + 0.2, 0.22, 0.18, 0, base + height * 0.55, front - 0.12, materials.woodLight, group);
// Waterside deck and short stilts.
box(width + 0.55, 0.24, 1.55, 0, 0.98, front - 0.58, materials.woodDark, group);
for (const sx of [-width * 0.36, width * 0.36]) {
box(0.24, 1.3, 0.24, sx, 0.32, front - 1.18, materials.woodDark, group);
}
box(width + 0.55, 0.11, 0.12, 0, 1.57, front - 1.26, materials.woodLight, group);
for (const sx of [-width * 0.36, 0, width * 0.36]) {
box(0.12, 0.62, 0.12, sx, 1.28, front - 1.24, materials.woodDark, group);
}
// Door and windows.
box(1.25, 2.28, 0.15, 0, base + 1.14, front - 0.13, materials.woodDark, group);
box(0.95, 2.03, 0.18, 0, base + 1.02, front - 0.2, materials.window, group);
box(0.09, 0.09, 0.12, 0.34, base + 1.05, front - 0.32, materials.ochre, group);
addWindow(group, -width * 0.28, base + 2.35, front - 0.12, 1.08, 1.22);
addWindow(group, width * 0.28, base + 2.35, front - 0.12, 1.08, 1.22);
if (height > 5.15) {
addWindow(group, -width * 0.2, base + 4.25, front - 0.12, 0.95, 1.05);
addWindow(group, width * 0.2, base + 4.25, front - 0.12, 0.95, 1.05);
}
// A small fabric awning, made from colored voxel strips.
if (variant % 2 === 0) {
const awningY = base + 3.25;
const awningZ = front - 0.72;
for (let i = 0; i < 5; i++) {
const stripe = i % 2 === 0 ? materials.cream : materials.teal;
box(
width * 0.145,
0.16,
1.35,
(i - 2) * width * 0.145,
awningY,
awningZ,
stripe,
group
);
}
box(0.13, 1.05, 0.13, -width * 0.29, awningY - 0.52, awningZ + 0.48, materials.woodDark, group);
box(0.13, 1.05, 0.13, width * 0.29, awningY - 0.52, awningZ + 0.48, materials.woodDark, group);
} else {
box(1.4, 0.7, 0.18, width * 0.2, base + 4.8, front - 0.12, materials.woodDark, group);
box(1.15, 0.48, 0.2, width * 0.2, base + 4.8, front - 0.2, materials.cream, group);
}
addRoof(group, width, depth, base + height, roofMaterial);
// Small domestic objects and planters.
box(0.58, 0.58, 0.58, width * 0.38, 1.43, front - 0.52, materials.terracotta, group);
box(0.45, 0.45, 0.45, width * 0.38, 1.92, front - 0.52, materials.leaf, group);
return group;
}
makeHouse(-1.2, 5.8, 4.7, 4.55, materials.wood, materials.roof, 0);
makeHouse(13.0, 6.4, 5.0, 5.55, materials.woodLight, materials.roofDark, 1);
makeHouse(20.0, 5.1, 4.4, 4.25, materials.woodPale, materials.roof, 2);
makeHouse(27.0, 6.1, 4.8, 5.1, materials.wood, materials.roofLight, 3);
makeHouse(34.0, 5.4, 4.6, 4.65, materials.woodLight, materials.roofDark, 4);
function createSignTexture() {
const signCanvas = document.createElement("canvas");
signCanvas.width = 1400;
signCanvas.height = 300;
const ctx = signCanvas.getContext("2d");
ctx.fillStyle = "#eadfbd";
ctx.fillRect(0, 0, signCanvas.width, signCanvas.height);
ctx.strokeStyle = "#634936";
ctx.lineWidth = 18;
ctx.strokeRect(15, 15, signCanvas.width - 30, signCanvas.height - 30);
ctx.strokeStyle = "rgba(99, 73, 54, 0.32)";
ctx.lineWidth = 3;
ctx.strokeRect(36, 36, signCanvas.width - 72, signCanvas.height - 72);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = "#543a2d";
ctx.font = "600 82px Georgia, serif";
ctx.fillText("BAAN SILAPIN", 700, 104);
ctx.font = "600 45px Georgia, serif";
ctx.fillText("Khlong Bang Luang Artist’s House", 700, 205);
const texture = new THREE.CanvasTexture(signCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
// Baan Silapin is the single named cultural frontage.
const venue = new THREE.Group();
venue.position.set(-13, 0, -10.2);
scene.add(venue);
const venueBase = 1.25;
const venueWidth = 14.2;
const venueDepth = 6.4;
const venueHeight = 5.2;
const venueFront = venueDepth / 2;
box(16.1, 0.45, 9.2, 0, 0.93, 1.4, materials.woodDark, venue);
box(14.25, venueHeight, venueDepth, 0, venueBase + venueHeight / 2, 0, materials.woodLight, venue);
for (let i = 1; i < 19; i++) {
const px = -venueWidth / 2 + (venueWidth * i) / 19;
box(
0.055,
venueHeight - 0.12,
0.08,
px,
venueBase + venueHeight / 2,
venueFront - 0.065,
materials.woodDark,
venue
);
}
box(venueWidth + 0.3, 0.24, 0.22, 0, venueBase + 2.85, venueFront - 0.13, materials.woodDark, venue);
box(venueWidth + 0.4, 0.24, 0.24, 0, venueBase + venueHeight - 0.08, venueFront - 0.12, materials.woodDark, venue);
// Front gallery.
for (const gx of [-6.2, -3.5, 3.5, 6.2]) {
box(0.24, 3.35, 0.24, gx, 2.8, venueFront + 0.35, materials.woodDark, venue);
}
box(12.8, 0.22, 1.55, 0, 4.35, venueFront + 0.55, materials.roofDark, venue);
for (let i = 0; i < 10; i++) {
box(
1.28,
0.12,
1.6,
(i - 4.5) * 1.28,
4.23,
venueFront + 0.55,
i % 2 ? materials.cream : materials.terracotta,
venue
);
}
// Entrance and upper openings.
box(1.65, 2.8, 0.15, 0, 2.65, venueFront - 0.11, materials.woodDark, venue);
box(1.32, 2.48, 0.18, 0, 2.58, venueFront - 0.18, materials.window, venue);
addWindow(venue, -4.55, 4.95, venueFront - 0.12, 1.55, 1.5);
addWindow(venue, 4.55, 4.95, venueFront - 0.12, 1.55, 1.5);
// Abstract geometric art panels in the open frontage.
function addArtPanel(px, colorA, colorB, colorC) {
box(2.25, 2.15, 0.13, px, 2.48, venueFront - 0.12, materials.woodDark, venue);
box(1.93, 1.82, 0.16, px, 2.48, venueFront - 0.17, materials.cream, venue);
box(0.78, 1.1, 0.05, px - 0.34, 2.62, venueFront - 0.27, colorA, venue);
box(0.92, 0.48, 0.05, px + 0.38, 2.08, venueFront - 0.27, colorB, venue);
box(0.46, 0.55, 0.05, px + 0.32, 2.9, venueFront - 0.27, colorC, venue);
}
addArtPanel(-5.1, materials.teal, materials.ochre, materials.terracotta);
addArtPanel(5.1, materials.blue, materials.terracotta, materials.teal);
addRoof(venue, venueWidth, venueDepth, venueBase + venueHeight, materials.roof);
const signTexture = createSignTexture();
const signMaterial = new THREE.MeshBasicMaterial({
map: signTexture,
toneMapped: false
});
const sign = new THREE.Mesh(new THREE.PlaneGeometry(10.8, 1.45), signMaterial);
sign.position.set(0, 5.96, venueFront + 0.035);
venue.add(sign);
// Small lamps flank the entrance.
for (const lx of [-1.75, 1.75]) {
box(0.13, 1.2, 0.13, lx, 4.0, venueFront + 0.5, materials.woodDark, venue);
box(0.36, 0.45, 0.36, lx, 4.72, venueFront + 0.5, materials.cream, venue);
}
// A compact, clearly schematic footbridge.
const bridge = new THREE.Group();
bridge.position.x = 6;
scene.add(bridge);
const bridgeDeckY = 1.48;
for (let z = -5.85; z <= 5.85; z += 0.49) {
box(2.65, 0.2, 0.43, 0, bridgeDeckY, z, z % 0.98 < 0.49 ? materials.wood : materials.woodLight, bridge);
}
box(0.22, 0.3, 12.35, -1.12, bridgeDeckY - 0.17, 0, materials.woodDark, bridge);
box(0.22, 0.3, 12.35, 1.12, bridgeDeckY - 0.17, 0, materials.woodDark, bridge);
for (const side of [-1, 1]) {
for (let z = -5.7; z <= 5.7; z += 1.42) {
box(0.13, 1.12, 0.13, side * 1.25, bridgeDeckY + 0.57, z, materials.woodDark, bridge);
}
box(0.14, 0.14, 12.05, side * 1.25, bridgeDeckY + 1.13, 0, materials.woodLight, bridge);
box(0.11, 0.11, 12.05, side * 1.25, bridgeDeckY + 0.61, 0, materials.woodDark, bridge);
}
for (const side of [-1, 1]) {
for (let i = 0; i < 5; i++) {
const stepZ = side * (6.22 + i * 0.42);
const stepTop = 1.43 - i * 0.105;
box(2.18, 0.2, 0.46, 0, stepTop, stepZ, materials.woodLight, bridge);
}
}
// A small moored boat, built entirely from blocks.
const boat = new THREE.Group();
boat.position.set(-7.2, 0.08, 1.25);
boat.rotation.y = -0.12;
scene.add(boat);
box(5.6, 0.48, 1.35, 0, 0.35, 0, materials.woodDark, boat);
box(4.65, 0.52, 1.05, 0, 0.65, 0, materials.wood, boat);
box(1.1, 0.42, 0.86, 2.85, 0.48, 0, materials.woodDark, boat);
box(0.8, 0.38, 0.7, -2.8, 0.45, 0, materials.woodDark, boat);
for (const bx of [-1.6, 0, 1.6]) {
box(0.25, 0.16, 1.18, bx, 0.96, 0, materials.woodPale, boat);
}
box(0.72, 0.45, 0.62, -0.2, 1.16, 0, materials.teal, boat);
function makePerson(x, z, shirtMaterial, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.9, z);
group.rotation.y = rotation;
scene.add(group);
box(0.38, 0.5, 0.25, -0.16, 0.34, 0, materials.dark, group);
box(0.38, 0.5, 0.25, 0.16, 0.34, 0, materials.dark, group);
box(0.62, 0.68, 0.34, 0, 0.92, 0, shirtMaterial, group);
box(0.18, 0.6, 0.18, -0.42, 0.9, 0, shirtMaterial, group);
box(0.18, 0.6, 0.18, 0.42, 0.9, 0, shirtMaterial, group);
box(0.42, 0.42, 0.4, 0, 1.48, 0, materials.skin, group);
box(0.46, 0.16, 0.43, 0, 1.67, 0, materials.woodDark, group);
}
makePerson(2.7, 7.0, materials.shirt, -0.35);
makePerson(-9.6, -7.05, materials.shirtBlue, 2.6);
makePerson(-15.9, -5.7, materials.shirt, 1.5);
// Benches and small riverside details.
for (const [x, z] of [[-23, -7.0], [4, -7.0], [25, -7.0], [-9, 7.0]]) {
box(2.2, 0.18, 0.58, x, 1.38, z, materials.woodLight);
box(0.18, 0.55, 0.42, x - 0.82, 1.08, z, materials.woodDark);
box(0.18, 0.55, 0.42, x + 0.82, 1.08, z, materials.woodDark);
}
// Camera controller implemented directly, without imported controls.
const controls = {
target: new THREE.Vector3(0, 1.6, 0),
theta: 0.46,
phi: 1.02,
radius: window.innerWidth < 700 ? 82 : 62,
minRadius: 22,
maxRadius: 105,
minPhi: 0.45,
maxPhi: 1.36
};
let cameraTween = null;
let dragging = false;
let dragPointer = null;
let lastX = 0;
let lastY = 0;
let labelsVisible = true;
function applyCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
function moveCameraTo(view, duration = 1150) {
cameraTween = {
start: performance.now(),
duration,
from: {
target: controls.target.clone(),
theta: controls.theta,
phi: controls.phi,
radius: controls.radius
},
to: {
target: new THREE.Vector3(...view.target),
theta: view.theta,
phi: view.phi,
radius: view.radius
}
};
}
function updateTween(now) {
if (!cameraTween) return;
const t = Math.min(1, (now - cameraTween.start) / cameraTween.duration);
const eased = t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
const { from, to } = cameraTween;
controls.target.lerpVectors(from.target, to.target, eased);
controls.phi = THREE.MathUtils.lerp(from.phi, to.phi, eased);
controls.radius = THREE.MathUtils.lerp(from.radius, to.radius, eased);
let thetaDelta = ((to.theta - from.theta + Math.PI) % (Math.PI * 2) + Math.PI * 2) % (Math.PI * 2) - Math.PI;
controls.theta = from.theta + thetaDelta * eased;
if (t >= 1) cameraTween = null;
}
function setActiveButton(viewName) {
document.querySelectorAll("[data-view]").forEach((button) => {
button.classList.toggle("active", button.dataset.view === viewName);
});
}
const views = {
overview: {
target: [0, 1.6, 0],
theta: 0.46,
phi: 1.02,
radius: window.innerWidth < 700 ? 82 : 62
},
venue: {
target: [-13, 3.0, -6.0],
theta: 0.12,
phi: 1.045,
radius: window.innerWidth < 700 ? 45 : 31
},
homes: {
target: [17, 2.7, 8.0],
theta: 0.32,
phi: 1.03,
radius: window.innerWidth < 700 ? 45 : 33
},
bridge: {
target: [6, 1.7, 0],
theta: 0.18,
phi: 1.075,
radius: window.innerWidth < 700 ? 48 : 34
}
};
document.querySelectorAll("[data-view]").forEach((button) => {
button.addEventListener("click", () => {
const name = button.dataset.view;
moveCameraTo(views[name]);
setActiveButton(name);
});
});
document.getElementById("toggle-labels").addEventListener("click", (event) => {
labelsVisible = !labelsVisible;
labelsRoot.classList.toggle("labels-off", !labelsVisible);
event.currentTarget.setAttribute("aria-pressed", String(labelsVisible));
});
canvas.addEventListener("pointerdown", (event) => {
if (event.pointerType === "mouse" && event.button !== 0) return;
dragging = true;
dragPointer = event.pointerId;
lastX = event.clientX;
lastY = event.clientY;
cameraTween = null;
setActiveButton("");
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== dragPointer) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(
controls.phi - dy * 0.005,
controls.minPhi,
controls.maxPhi
);
});
function endDrag(event) {
if (event.pointerId !== dragPointer) return;
dragging = false;
dragPointer = null;
if (canvas.hasPointerCapture(event.pointerId)) canvas.releasePointerCapture(event.pointerId);
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
cameraTween = null;
const factor = Math.exp(event.deltaY * 0.0011);
controls.radius = THREE.MathUtils.clamp(
controls.radius * factor,
controls.minRadius,
controls.maxRadius
);
setActiveButton("");
}, { passive: false });
canvas.addEventListener("dblclick", () => {
moveCameraTo(views.overview);
setActiveButton("overview");
});
canvas.addEventListener("keydown", (event) => {
let handled = true;
cameraTween = null;
switch (event.key) {
case "ArrowLeft":
controls.theta += 0.08;
break;
case "ArrowRight":
controls.theta -= 0.08;
break;
case "ArrowUp":
controls.phi = Math.max(controls.minPhi, controls.phi - 0.06);
break;
case "ArrowDown":
controls.phi = Math.min(controls.maxPhi, controls.phi + 0.06);
break;
case "+":
case "=":
controls.radius = Math.max(controls.minRadius, controls.radius * 0.92);
break;
case "-":
controls.radius = Math.min(controls.maxRadius, controls.radius * 1.08);
break;
case "r":
case "R":
moveCameraTo(views.overview);
setActiveButton("overview");
break;
default:
handled = false;
}
if (handled) {
event.preventDefault();
setActiveButton("");
}
});
const labelData = [
{
element: document.getElementById("label-venue"),
anchor: new THREE.Vector3(-13, 7.65, -6.75)
},
{
element: document.getElementById("label-homes"),
anchor: new THREE.Vector3(16.8, 8.15, 7.65)
},
{
element: document.getElementById("label-bridge"),
anchor: new THREE.Vector3(6, 3.05, 0)
}
];
const projected = new THREE.Vector3();
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const item of labelData) {
projected.copy(item.anchor).project(camera);
const inFrame =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.08 &&
projected.x < 1.08 &&
projected.y > -1.08 &&
projected.y < 1.08;
item.element.style.left = `${(projected.x * 0.5 + 0.5) * width}px`;
item.element.style.top = `${(-projected.y * 0.5 + 0.5) * height}px`;
item.element.style.opacity = inFrame ? "1" : "0";
}
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.fov = width < 700 ? 50 : 42;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setSize(width, height, false);
}
window.addEventListener("resize", resize);
applyCamera();
resize();
const clock = new THREE.Clock();
let firstFrame = true;
renderer.setAnimationLoop(() => {
const delta = Math.min(clock.getDelta(), 0.05);
const now = performance.now();
updateTween(now);
applyCamera();
for (const ripple of animatedRipples) {
ripple.mesh.position.x += delta * ripple.speed;
if (ripple.mesh.position.x > 40) ripple.mesh.position.x = -40;
}
updateLabels();
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
loading.classList.add("ready");
window.setTimeout(() => loading.remove(), 600);
}
});
</script>
</body>
</html>
```