Prompt specification
Build or customize the Three.js 3D scene "Kota Tua window bay and arcade fragment" 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: Kota Tua window bay and arcade fragment
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/kota-tua-window-bay-and-arcade-fragment-x2993
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts Fatahillah Square in Jakarta's Kota Tua. Build a referenced Jakarta historic facade bay with deep window and shaded ground-level opening. Identify the selected building context and simplify ornament without inventing historical details. Low-poly.
Working Three.js Starter (kota-tua-window-bay-and-arcade-fragment-x2993):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Fatahillah Square — Kota Tua Facade Study</title>
<style>
:root {
color-scheme: dark;
--paper: #f2eadb;
--muted: #c7bda9;
--accent: #d9a55d;
--panel: rgba(24, 27, 25, 0.86);
--line: rgba(255, 255, 255, 0.14);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b9cdd0;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.panel {
position: fixed;
z-index: 10;
pointer-events: none;
}
#context-card {
top: 22px;
left: 22px;
width: min(390px, calc(100vw - 44px));
padding: 20px 22px;
color: var(--paper);
background: var(--panel);
border: 1px solid var(--line);
border-radius: 4px;
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(12px);
}
.eyebrow {
margin-bottom: 8px;
color: var(--accent);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.17em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 4vw, 42px);
font-weight: 400;
line-height: 1.03;
}
.subtitle {
margin: 8px 0 18px;
color: var(--muted);
font-size: 14px;
}
.context-row {
display: grid;
grid-template-columns: 12px 1fr;
gap: 11px;
align-items: start;
padding-top: 15px;
border-top: 1px solid var(--line);
}
.swatch {
width: 8px;
height: 8px;
margin-top: 5px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 4px rgba(217, 165, 93, 0.14);
}
.context-row strong {
display: block;
margin-bottom: 4px;
font-size: 12px;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.context-row p {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.disclaimer {
margin-top: 14px;
color: #aaa394;
font-size: 11px;
line-height: 1.5;
}
#controls {
right: 22px;
bottom: 22px;
display: flex;
gap: 8px;
pointer-events: auto;
}
button {
min-height: 38px;
padding: 0 15px;
color: var(--paper);
font: inherit;
font-size: 12px;
font-weight: 650;
letter-spacing: 0.03em;
background: rgba(24, 27, 25, 0.9);
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 3px;
cursor: pointer;
backdrop-filter: blur(10px);
transition:
background 160ms ease,
border-color 160ms ease;
}
button:hover,
button:focus-visible {
background: #323630;
border-color: var(--accent);
outline: none;
}
#hint {
left: 22px;
bottom: 22px;
padding: 9px 12px;
color: rgba(245, 239, 225, 0.85);
font-size: 11px;
letter-spacing: 0.035em;
background: rgba(24, 27, 25, 0.72);
border: 1px solid var(--line);
border-radius: 3px;
backdrop-filter: blur(8px);
}
.scene-label {
position: fixed;
z-index: 5;
display: none;
pointer-events: none;
transform: translate(-50%, -100%);
}
.scene-label .label-inner {
position: relative;
padding: 8px 11px;
color: #f4ecdc;
white-space: nowrap;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.07em;
text-transform: uppercase;
background: rgba(26, 29, 26, 0.88);
border: 1px solid rgba(255, 255, 255, 0.18);
border-radius: 3px;
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
backdrop-filter: blur(8px);
}
.scene-label::after {
position: absolute;
top: 100%;
left: 50%;
width: 1px;
height: 26px;
content: "";
background: rgba(255, 255, 255, 0.55);
}
.scene-label .label-dot {
position: absolute;
top: calc(100% + 24px);
left: 50%;
width: 7px;
height: 7px;
transform: translate(-50%, -50%);
background: var(--accent);
border: 2px solid rgba(255, 255, 255, 0.8);
border-radius: 50%;
}
#statue-label .label-inner {
color: #ddd8cc;
font-size: 9px;
}
#statue-label::after,
#statue-label .label-dot {
display: none;
}
@media (max-width: 700px) {
#context-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 15px 17px;
}
.subtitle {
margin-bottom: 12px;
}
.context-row {
padding-top: 11px;
}
.disclaimer {
display: none;
}
#controls {
right: 12px;
bottom: 12px;
}
#hint {
display: none;
}
button {
min-height: 36px;
padding: 0 11px;
font-size: 11px;
}
}
</style>
</head>
<body>
<section id="context-card" class="panel">
<div class="eyebrow">Kota Tua · Jakarta</div>
<h1>Fatahillah Square</h1>
<p class="subtitle">Low-poly architectural context study</p>
<div class="context-row">
<span class="swatch"></span>
<div>
<strong>Selected building context</strong>
<p>
Representative historic commercial-house façade bay on the heritage
frontage bordering Fatahillah Square, Kota Tua, Jakarta.
</p>
</div>
</div>
<p class="disclaimer">
Contextual interpretation, not an attribution to a specific named building
or a measured reconstruction. The deep upper window, recessed shaded
ground-floor opening, cornice, and pilaster rhythm are simplified without
inventing decorative motifs.
</p>
</section>
<div id="controls" class="panel">
<button id="view-square" type="button">Square view</button>
<button id="view-bay" type="button">Focus façade bay</button>
</div>
<div id="hint" class="panel">
Drag to orbit · Scroll or pinch to zoom
</div>
<div id="bay-label" class="scene-label">
<div class="label-inner">Selected representative façade bay</div>
<span class="label-dot"></span>
</div>
<div id="statue-label" class="scene-label">
<div class="label-inner">Fatahillah statue · interpretive marker</div>
</div>
<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(0xb9cdd0);
scene.fog = new THREE.Fog(0xb9cdd0, 30, 65);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, 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);
// ------------------------------------------------------------
// Materials
// ------------------------------------------------------------
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.92,
metalness: 0,
flatShading: true,
...options
});
}
const mat = {
ground: material(0x8d9180),
paving: material(0xffffff, { vertexColors: true }),
curb: material(0xc5bca9),
grass: material(0x66785a),
grassDark: material(0x52664a),
stone: material(0xb8aa93),
stoneDark: material(0x817968),
selected: material(0xd5c19f),
selectedTrim: material(0xb39b76),
contextA: material(0xb8b0a0),
contextB: material(0xc8b9a3),
contextC: material(0x9fa6a0),
roof: material(0x665f58),
wood: material(0x49362b),
woodLight: material(0x6a5140),
glass: material(0x263c40, { roughness: 0.35, metalness: 0.12 }),
recess: material(0x252823),
interior: material(0x1c211f),
metal: material(0x343936, { roughness: 0.65, metalness: 0.35 }),
bronze: material(0x405a50, { roughness: 0.72, metalness: 0.22 }),
trunk: material(0x67503c),
leafA: material(0x526c4e),
leafB: material(0x687c58),
leafC: material(0x788861),
clothing: [
material(0x925f48),
material(0x536c78),
material(0xb4a37c),
material(0x6a6658)
],
skin: material(0xa87d62)
};
// ------------------------------------------------------------
// Geometry helpers
// ------------------------------------------------------------
function box(w, h, d, x, y, z, meshMaterial, castShadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
meshMaterial
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
function cylinder(
radiusTop,
radiusBottom,
height,
segments,
x,
y,
z,
meshMaterial,
castShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
meshMaterial
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
function ico(radius, detail, x, y, z, meshMaterial) {
const mesh = new THREE.Mesh(
new THREE.IcosahedronGeometry(radius, detail),
meshMaterial
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
function addShallowWindow(x, y, frontZ, width, height, frameColor = mat.wood) {
box(width, height, 0.08, x, y, frontZ + 0.045, mat.glass, false);
box(0.10, height + 0.16, 0.13, x - width / 2, y, frontZ + 0.09, frameColor);
box(0.10, height + 0.16, 0.13, x + width / 2, y, frontZ + 0.09, frameColor);
box(width + 0.16, 0.10, 0.13, x, y + height / 2, frontZ + 0.09, frameColor);
box(width + 0.16, 0.12, 0.17, x, y - height / 2, frontZ + 0.12, mat.selectedTrim);
}
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xd8e8e5, 0x70624f, 2.2);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe7bd, 3.2);
sun.position.set(12, 19, 11);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -25;
sun.shadow.camera.right = 25;
sun.shadow.camera.top = 22;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.bias = -0.00045;
scene.add(sun);
// ------------------------------------------------------------
// Plaza ground and paving
// ------------------------------------------------------------
box(58, 0.24, 48, 0, -0.32, 1, mat.ground, false);
box(29, 0.18, 24, 0, -0.05, 2.7, mat.curb, false);
const pavingGeometry = new THREE.BoxGeometry(1.76, 0.10, 1.76);
const columns = 15;
const rows = 13;
const paving = new THREE.InstancedMesh(
pavingGeometry,
mat.paving,
columns * rows
);
const dummy = new THREE.Object3D();
const pavingColors = [
new THREE.Color(0xc8bba4),
new THREE.Color(0xd1c5ae),
new THREE.Color(0xbeaf98),
new THREE.Color(0xd6ccb8)
];
let pavingIndex = 0;
for (let row = 0; row < rows; row++) {
for (let col = 0; col < columns; col++) {
dummy.position.set(
(col - (columns - 1) / 2) * 1.82,
0.07,
-7.55 + row * 1.82
);
dummy.rotation.y = 0;
dummy.updateMatrix();
paving.setMatrixAt(pavingIndex, dummy.matrix);
paving.setColorAt(
pavingIndex,
pavingColors[(row * 3 + col * 2) % pavingColors.length]
);
pavingIndex++;
}
}
paving.receiveShadow = true;
scene.add(paving);
// Formal green strips establish the square without reproducing a survey.
box(7.4, 0.18, 11.7, -7.0, 0.15, 2.0, mat.grass, false);
box(7.4, 0.18, 11.7, 7.0, 0.15, 2.0, mat.grass, false);
box(7.8, 0.28, 0.24, -7.0, 0.18, -4.0, mat.curb, false);
box(7.8, 0.28, 0.24, -7.0, 0.18, 8.0, mat.curb, false);
box(0.24, 0.28, 12.2, -10.95, 0.18, 2.0, mat.curb, false);
box(0.24, 0.28, 12.2, -3.05, 0.18, 2.0, mat.curb, false);
box(7.8, 0.28, 0.24, 7.0, 0.18, -4.0, mat.curb, false);
box(7.8, 0.28, 0.24, 7.0, 0.18, 8.0, mat.curb, false);
box(0.24, 0.28, 12.2, 3.05, 0.18, 2.0, mat.curb, false);
box(0.24, 0.28, 12.2, 10.95, 0.18, 2.0, mat.curb, false);
// ------------------------------------------------------------
// Historic frontage: contextual massing
// ------------------------------------------------------------
function contextFacade(x, width, height, wallMaterial) {
const centerZ = -8.65;
const depth = 2.8;
const frontZ = centerZ + depth / 2;
box(width, height, depth, x, height / 2, centerZ, wallMaterial);
box(width + 0.35, 0.35, depth + 0.25, x, height - 0.22, centerZ, mat.stoneDark);
box(width + 0.12, 0.42, 0.22, x, height + 0.08, frontZ + 0.03, mat.stone);
const columnCount = width > 6 ? 3 : 2;
const spacing = width / (columnCount + 1);
for (let c = 0; c < columnCount; c++) {
const wx = x - width / 2 + spacing * (c + 1);
addShallowWindow(wx, 2.1, frontZ, 1.15, 1.8);
addShallowWindow(wx, 4.7, frontZ, 1.15, 1.8);
addShallowWindow(wx, height - 1.4, frontZ, 0.95, 1.25);
}
// Simplified pilasters and horizontal trim, not copied ornament.
for (let c = 0; c <= columnCount; c++) {
const px = x - width / 2 + spacing * c;
box(0.18, height - 0.4, 0.16, px, height / 2, frontZ + 0.10, mat.stone);
}
box(width, 0.16, 0.18, x, 3.25, frontZ + 0.10, mat.stone);
}
contextFacade(-5.15, 7.1, 7.15, mat.contextA);
contextFacade(10.15, 6.7, 8.1, mat.contextB);
contextFacade(16.4, 5.4, 6.8, mat.contextC);
contextFacade(-12.2, 5.2, 6.5, mat.contextC);
// ------------------------------------------------------------
// Selected façade bay
// Selected context: representative Kota Tua commercial-house bay.
// ------------------------------------------------------------
const bayX = 3.1;
const bayFront = -7.15;
const bayBack = -9.8;
const bayCenterZ = (bayFront + bayBack) / 2;
const bayDepth = bayFront - bayBack;
const lowerHeight = 3.25;
const totalHeight = 7.65;
// Lower side masses leave a real void for the recessed ground opening.
box(1.95, lowerHeight, bayDepth, bayX - 2.075, 1.63, bayCenterZ, mat.selected);
box(1.95, lowerHeight, bayDepth, bayX + 2.075, 1.63, bayCenterZ, mat.selected);
// Upper façade framing around a genuine window recess.
box(1.95, 4.40, bayDepth, bayX - 2.075, 5.45, bayCenterZ, mat.selected);
box(1.95, 4.40, bayDepth, bayX + 2.075, 5.45, bayCenterZ, mat.selected);
box(2.20, 1.00, bayDepth, bayX, 3.75, bayCenterZ, mat.selected);
box(2.20, 1.05, bayDepth, bayX, 7.125, bayCenterZ, mat.selected);
// Rear wall and dark interior make the apertures read as deep.
box(6.2, totalHeight, 0.22, bayX, totalHeight / 2, bayBack + 0.08, mat.interior);
// Ground-level shaded opening.
box(2.12, 2.62, 0.08, bayX, 1.62, bayBack + 0.27, mat.recess, false);
box(0.14, 2.62, 1.25, bayX - 1.03, 1.62, -8.48, mat.recess);
box(0.14, 2.62, 1.25, bayX + 1.03, 1.62, -8.48, mat.recess);
box(2.20, 0.16, 1.30, bayX, 2.98, -8.45, mat.recess);
box(2.20, 0.12, 1.30, bayX, 0.30, -8.45, mat.stoneDark);
// Recessed timber doors and glazing, placed well behind the facade line.
box(0.90, 2.35, 0.10, bayX - 0.50, 1.53, bayBack + 0.37, mat.wood);
box(0.90, 2.35, 0.10, bayX + 0.50, 1.53, bayBack + 0.37, mat.wood);
box(0.07, 2.40, 0.16, bayX, 1.53, bayBack + 0.43, mat.woodLight);
box(0.65, 0.92, 0.06, bayX - 0.50, 1.92, bayBack + 0.44, mat.glass, false);
box(0.65, 0.92, 0.06, bayX + 0.50, 1.92, bayBack + 0.44, mat.glass, false);
// Front piers and lintel emphasize the shade beneath them.
box(0.30, 3.05, 0.48, bayX - 1.27, 1.54, bayFront + 0.06, mat.selectedTrim);
box(0.30, 3.05, 0.48, bayX + 1.27, 1.54, bayFront + 0.06, mat.selectedTrim);
box(2.85, 0.27, 0.46, bayX, 3.13, bayFront + 0.06, mat.selectedTrim);
box(3.10, 0.14, 0.52, bayX, 3.37, bayFront + 0.07, mat.selectedTrim);
// Deep upper window recess.
box(1.62, 2.30, 0.07, bayX, 5.38, bayBack + 0.28, mat.glass, false);
box(0.13, 2.35, 1.25, bayX - 0.80, 5.38, -8.48, mat.selectedTrim);
box(0.13, 2.35, 1.25, bayX + 0.80, 5.38, -8.48, mat.selectedTrim);
box(1.72, 0.14, 1.25, bayX, 6.56, -8.48, mat.selectedTrim);
box(1.78, 0.18, 1.38, bayX, 4.22, -8.45, mat.selectedTrim);
// Window joinery at the back of the reveal.
box(0.09, 2.34, 0.14, bayX, 5.38, bayBack + 0.35, mat.wood);
box(1.62, 0.09, 0.14, bayX, 5.38, bayBack + 0.35, mat.wood);
box(1.62, 0.10, 0.16, bayX, 5.46, bayBack + 0.35, mat.wood);
// Simple inset shutters.
box(0.48, 2.15, 0.10, bayX - 0.62, 5.38, bayBack + 0.47, mat.woodLight);
box(0.48, 2.15, 0.10, bayX + 0.62, 5.38, bayBack + 0.47, mat.woodLight);
// Shallow upper pilasters and plain cornice bands.
box(0.22, 4.25, 0.18, bayX - 1.20, 5.44, bayFront + 0.08, mat.selectedTrim);
box(0.22, 4.25, 0.18, bayX + 1.20, 5.44, bayFront + 0.08, mat.selectedTrim);
box(6.48, 0.26, 0.34, bayX, 7.68, bayFront + 0.03, mat.selectedTrim);
box(6.72, 0.19, 0.42, bayX, 7.88, bayFront + 0.03, mat.stoneDark);
box(6.35, 0.16, 0.27, bayX, 8.05, bayFront + 0.01, mat.selectedTrim);
// Small ground-floor side windows, kept subordinate to the deep opening.
for (const side of [-1, 1]) {
const sx = bayX + side * 2.12;
box(1.04, 1.50, 0.07, sx, 1.65, bayFront + 0.04, mat.glass, false);
box(0.09, 1.62, 0.13, sx - 0.52, 1.65, bayFront + 0.08, mat.wood);
box(0.09, 1.62, 0.13, sx + 0.52, 1.65, bayFront + 0.08, mat.wood);
box(1.10, 0.10, 0.14, sx, 1.65, bayFront + 0.08, mat.wood);
box(1.16, 0.13, 0.17, sx, 0.86, bayFront + 0.10, mat.selectedTrim);
}
// ------------------------------------------------------------
// Fatahillah statue: intentionally simplified interpretive marker
// ------------------------------------------------------------
const statueX = -2.1;
const statueZ = 1.55;
box(3.65, 0.34, 3.65, statueX, 0.30, statueZ, mat.stoneDark);
box(2.85, 0.28, 2.85, statueX, 0.58, statueZ, mat.stone);
box(2.15, 0.36, 2.15, statueX, 0.87, statueZ, mat.stoneDark);
box(1.55, 0.70, 1.55, statueX, 1.38, statueZ, mat.stone);
cylinder(0.42, 0.58, 1.55, 6, statueX, 2.43, statueZ, mat.bronze);
cylinder(0.18, 0.22, 1.05, 6, statueX - 0.22, 1.30, statueZ, mat.bronze);
cylinder(0.18, 0.22, 1.05, 6, statueX + 0.22, 1.30, statueZ, mat.bronze);
ico(0.34, 1, statueX, 3.43, statueZ, mat.bronze);
const leftArm = cylinder(0.14, 0.17, 1.20, 6, statueX - 0.58, 2.83, statueZ, mat.bronze);
leftArm.rotation.z = -0.72;
const rightArm = cylinder(0.14, 0.17, 1.20, 6, statueX + 0.58, 2.83, statueZ, mat.bronze);
rightArm.rotation.z = 0.72;
// Abstract sword and balance-bar silhouettes.
const sword = box(0.08, 1.72, 0.08, statueX + 0.91, 2.75, statueZ + 0.02, mat.metal);
sword.rotation.z = -0.22;
const balance = box(1.02, 0.07, 0.07, statueX - 0.72, 3.18, statueZ, mat.metal);
balance.rotation.z = 0.08;
box(0.65, 0.03, 0.12, statueX, 1.09, statueZ + 0.79, mat.selectedTrim, false);
// ------------------------------------------------------------
// Trees, benches, lamps, and people
// ------------------------------------------------------------
const leafMaterials = [mat.leafA, mat.leafB, mat.leafC];
function tree(x, z, scale = 1) {
cylinder(0.17 * scale, 0.25 * scale, 2.6 * scale, 6, x, 1.25 * scale, z, mat.trunk);
const crown1 = ico(1.15 * scale, 0, x, 3.05 * scale, z, leafMaterials[0]);
crown1.scale.set(1.05, 0.85, 1.0);
const crown2 = ico(0.86 * scale, 0, x - 0.58 * scale, 2.75 * scale, z + 0.15, leafMaterials[1]);
const crown3 = ico(0.80 * scale, 0, x + 0.62 * scale, 2.92 * scale, z - 0.12, leafMaterials[2]);
crown2.rotation.y = 0.7;
crown3.rotation.y = -0.5;
}
[
[-9.2, -2.5, 1.05],
[-9.1, 6.5, 0.92],
[9.3, -2.6, 1.02],
[9.2, 6.4, 0.95],
[-12.0, 1.5, 0.80],
[12.0, 1.4, 0.85]
].forEach(([x, z, scale]) => tree(x, z, scale));
function bench(x, z, rotation = 0) {
const group = new THREE.Group();
const seat = new THREE.Mesh(new THREE.BoxGeometry(1.7, 0.12, 0.48), mat.wood);
seat.castShadow = true;
seat.receiveShadow = true;
group.add(seat);
const back = new THREE.Mesh(new THREE.BoxGeometry(1.7, 0.55, 0.10), mat.wood);
back.position.set(0, 0.30, -0.20);
back.castShadow = true;
group.add(back);
for (const side of [-1, 1]) {
const leg = new THREE.Mesh(new THREE.BoxGeometry(0.10, 0.48, 0.40), mat.metal);
leg.position.set(side * 0.64, -0.30, 0);
leg.castShadow = true;
group.add(leg);
}
group.position.set(x, 0.52, z);
group.rotation.y = rotation;
scene.add(group);
}
bench(-6.7, -2.8, Math.PI / 2);
bench(-6.7, 5.8, -Math.PI / 2);
bench(6.8, -2.8, -Math.PI / 2);
bench(6.8, 5.8, Math.PI / 2);
bench(-1.0, 8.6, 0);
bench(1.1, 8.6, 0);
function lamp(x, z) {
cylinder(0.07, 0.11, 3.25, 6, x, 1.62, z, mat.metal);
box(0.48, 0.58, 0.48, x, 3.42, z, mat.metal);
box(0.35, 0.42, 0.35, x, 3.43, z, material(0xe8d8a6, {
emissive: 0x806b3e,
emissiveIntensity: 0.35
}), false);
box(0.60, 0.08, 0.60, x, 3.77, z, mat.metal);
}
[
[-10.8, -4.0],
[-10.8, 8.1],
[10.8, -4.0],
[10.8, 8.1],
[-3.0, 10.3],
[3.2, 10.3]
].forEach(([x, z]) => lamp(x, z));
function person(x, z, rotation, colorIndex, scale = 1) {
const group = new THREE.Group();
const torso = new THREE.Mesh(
new THREE.CylinderGeometry(0.20, 0.29, 0.72, 5),
mat.clothing[colorIndex % mat.clothing.length]
);
torso.position.y = 1.05;
torso.castShadow = true;
group.add(torso);
const head = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.18, 0),
mat.skin
);
head.position.y = 1.57;
head.castShadow = true;
group.add(head);
const legA = new THREE.Mesh(new THREE.BoxGeometry(0.13, 0.65, 0.14), mat.metal);
const legB = legA.clone();
legA.position.set(-0.12, 0.35, 0);
legB.position.set(0.12, 0.35, 0);
legA.castShadow = legB.castShadow = true;
group.add(legA, legB);
group.position.set(x, 0.16, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
scene.add(group);
}
person(-0.6, 5.1, 0.2, 0, 0.95);
person(1.2, 4.2, -0.8, 1, 1.02);
person(-4.8, -2.9, 1.5, 2, 0.91);
person(6.9, 2.2, -1.2, 3, 0.97);
person(3.7, 9.0, 0.7, 1, 0.88);
// ------------------------------------------------------------
// Camera controls implemented directly
// ------------------------------------------------------------
const desiredView = {
target: new THREE.Vector3(0.4, 2.6, -2.0),
theta: 0.55,
phi: 1.15,
radius: 22.0
};
const currentView = {
target: desiredView.target.clone(),
theta: desiredView.theta,
phi: desiredView.phi,
radius: desiredView.radius
};
function updateCamera(dt) {
const smoothing = 1 - Math.exp(-dt * 6);
currentView.target.lerp(desiredView.target, smoothing);
currentView.theta += (desiredView.theta - currentView.theta) * smoothing;
currentView.phi += (desiredView.phi - currentView.phi) * smoothing;
currentView.radius += (desiredView.radius - currentView.radius) * smoothing;
const sinPhi = Math.sin(currentView.phi);
camera.position.set(
currentView.target.x +
currentView.radius * sinPhi * Math.sin(currentView.theta),
currentView.target.y + currentView.radius * Math.cos(currentView.phi),
currentView.target.z +
currentView.radius * sinPhi * Math.cos(currentView.theta)
);
camera.lookAt(currentView.target);
}
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
desiredView.theta -= dx * 0.005;
desiredView.phi = THREE.MathUtils.clamp(
desiredView.phi - dy * 0.004,
0.66,
1.46
);
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined && renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredView.radius = THREE.MathUtils.clamp(
desiredView.radius + event.deltaY * 0.012,
9.5,
34
);
},
{ passive: false }
);
document.getElementById("view-square").addEventListener("click", () => {
desiredView.target.set(0.4, 2.6, -2.0);
desiredView.theta = 0.55;
desiredView.phi = 1.15;
desiredView.radius = 22.0;
});
document.getElementById("view-bay").addEventListener("click", () => {
desiredView.target.set(3.1, 4.0, -7.5);
desiredView.theta = 0.50;
desiredView.phi = 1.22;
desiredView.radius = 12.0;
});
// ------------------------------------------------------------
// Projected HTML labels
// ------------------------------------------------------------
const bayLabel = document.getElementById("bay-label");
const statueLabel = document.getElementById("statue-label");
const bayAnchor = new THREE.Vector3(3.1, 8.25, -7.0);
const statueAnchor = new THREE.Vector3(-2.1, 3.95, 1.55);
function placeLabel(element, worldPosition) {
const projected = worldPosition.clone().project(camera);
if (
projected.z < -1 ||
projected.z > 1 ||
Math.abs(projected.x) > 1.15 ||
Math.abs(projected.y) > 1.15
) {
element.style.display = "none";
return;
}
element.style.display = "block";
element.style.left = `${(projected.x * 0.5 + 0.5) * innerWidth}px`;
element.style.top = `${(-projected.y * 0.5 + 0.5) * innerHeight}px`;
}
// ------------------------------------------------------------
// Resize and animation
// ------------------------------------------------------------
function onResize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
}
window.addEventListener("resize", onResize);
let previousTime = performance.now();
function animate(time) {
const dt = Math.min((time - previousTime) / 1000, 0.05);
previousTime = time;
updateCamera(dt);
placeLabel(bayLabel, bayAnchor);
placeLabel(statueLabel, statueAnchor);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```