Prompt specification
Build or customize the Three.js 3D scene "Afternoon square performance" 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: Afternoon square performance
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/afternoon-square-performance-x0547
Scene Description Prompt:
Make one HTML file using Three.js from cdnjs for this stylized scene: Build a small plaza with musician, café tables, fountain edge, and pedestrians; audience attention and ordinary passing movement coexist without requiring a crowded scene.
Working Three.js Starter (afternoon-square-performance-x0547):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Corner Notes — A Small Plaza</title>
<style>
:root {
color-scheme: light;
--ink: #263b3b;
--muted: #617372;
--paper: rgba(255, 252, 242, 0.88);
--accent: #df765d;
--green: #5e8b75;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d9e5df;
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
color: var(--ink);
}
#app,
#app canvas {
display: block;
width: 100%;
height: 100%;
}
#app canvas {
touch-action: none;
cursor: grab;
}
#app canvas:active {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.title-card {
position: absolute;
top: 22px;
left: 22px;
width: min(360px, calc(100vw - 44px));
padding: 17px 19px 15px;
border: 1px solid rgba(255, 255, 255, 0.65);
border-radius: 18px;
background: var(--paper);
box-shadow: 0 14px 40px rgba(50, 75, 70, 0.13);
backdrop-filter: blur(12px);
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 7px;
color: var(--green);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.live-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 4px rgba(223, 118, 93, 0.13);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 3vw, 38px);
font-weight: 500;
line-height: 1.03;
letter-spacing: -0.025em;
}
.subtitle {
margin: 8px 0 14px;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 7px;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 9px;
border-radius: 999px;
background: rgba(255, 255, 255, 0.65);
color: #536563;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.legend i {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--accent);
}
.legend .audience {
background: var(--green);
}
.legend .passing {
background: #d2a94a;
}
.controls-card {
position: absolute;
right: 22px;
bottom: 22px;
display: flex;
align-items: center;
gap: 9px;
pointer-events: auto;
}
button {
appearance: none;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 12px;
padding: 10px 13px;
background: var(--paper);
color: var(--ink);
box-shadow: 0 8px 24px rgba(46, 70, 66, 0.12);
backdrop-filter: blur(10px);
cursor: pointer;
font: inherit;
font-size: 12px;
font-weight: 700;
transition: transform 150ms ease, background 150ms ease;
}
button:hover {
transform: translateY(-1px);
background: rgba(255, 255, 253, 0.96);
}
button:active {
transform: translateY(0);
}
.hint {
position: absolute;
left: 22px;
bottom: 24px;
padding: 9px 12px;
border-radius: 10px;
background: rgba(38, 59, 59, 0.72);
color: rgba(255, 255, 255, 0.9);
font-size: 11px;
letter-spacing: 0.02em;
backdrop-filter: blur(8px);
}
.hint kbd {
padding: 1px 4px;
border: 1px solid rgba(255, 255, 255, 0.25);
border-radius: 4px;
font: inherit;
font-size: 10px;
}
#loading {
position: fixed;
inset: 0;
z-index: 10;
display: grid;
place-items: center;
background: #d9e5df;
transition: opacity 500ms ease, visibility 500ms ease;
}
#loading.hidden {
visibility: hidden;
opacity: 0;
}
.loader {
text-align: center;
}
.loader-mark {
width: 42px;
height: 42px;
margin: 0 auto 14px;
border: 3px solid rgba(94, 139, 117, 0.2);
border-top-color: var(--green);
border-radius: 50%;
animation: spin 900ms linear infinite;
}
.loader p {
margin: 0;
color: var(--muted);
font-size: 13px;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
@media (max-width: 700px) {
.title-card {
top: 14px;
left: 14px;
padding: 14px 15px;
}
.subtitle {
margin-bottom: 10px;
}
.controls-card {
right: 14px;
bottom: 14px;
}
.hint {
display: none;
}
}
</style>
</head>
<body>
<div id="app"></div>
<div class="hud">
<section class="title-card">
<div class="eyebrow">
<span class="live-dot"></span>
A living miniature
</div>
<h1>Corner Notes</h1>
<p class="subtitle">
A small plaza where a street musician gathers a few quiet listeners
without interrupting the everyday rhythm.
</p>
<div class="legend" aria-label="Scene legend">
<span><i></i>Music</span>
<span><i class="audience"></i>Listeners</span>
<span><i class="passing"></i>Passing through</span>
</div>
</section>
<div class="hint">
<kbd>drag</kbd> orbit
<kbd>wheel</kbd> zoom
<kbd>shift + drag</kbd> pan
</div>
<div class="controls-card">
<button id="pause" type="button" aria-pressed="false">Pause scene</button>
<button id="reset" type="button">Reset view</button>
</div>
</div>
<div id="loading">
<div class="loader">
<div class="loader-mark"></div>
<p>Setting out the café chairs…</p>
</div>
</div>
<script type="module">
const loadingElement = document.getElementById("loading");
let THREE;
try {
THREE = await import(
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js"
);
} catch (error) {
loadingElement.innerHTML = `
<div class="loader">
<p>Three.js could not be loaded. Please check your connection.</p>
</div>`;
throw error;
}
const app = document.getElementById("app");
const pauseButton = document.getElementById("pause");
const resetButton = document.getElementById("reset");
let renderer;
try {
renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
} catch (error) {
loadingElement.innerHTML = `
<div class="loader">
<p>This scene needs a browser with WebGL enabled.</p>
</div>`;
throw error;
}
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;
renderer.domElement.setAttribute(
"aria-label",
"Interactive 3D scene of a musician, listeners, café tables, fountain, and pedestrians"
);
app.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color("#d9e5df");
scene.fog = new THREE.Fog("#d9e5df", 30, 65);
const camera = new THREE.PerspectiveCamera(
39,
window.innerWidth / window.innerHeight,
0.1,
120
);
// ------------------------------------------------------------
// Small direct camera-control implementation
// ------------------------------------------------------------
const cameraControl = {
target: new THREE.Vector3(0, 1, 0),
desiredTarget: new THREE.Vector3(0, 1, 0),
current: new THREE.Spherical(31.5, 1.03, 0.69),
desired: new THREE.Spherical(31.5, 1.03, 0.69),
minRadius: 14,
maxRadius: 47
};
function applyCameraImmediately() {
cameraControl.current.copy(cameraControl.desired);
cameraControl.target.copy(cameraControl.desiredTarget);
camera.position
.copy(cameraControl.target)
.add(new THREE.Vector3().setFromSpherical(cameraControl.current));
camera.lookAt(cameraControl.target);
}
applyCameraImmediately();
let dragging = null;
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = {
id: event.pointerId,
x: event.clientX,
y: event.clientY,
pan: event.button === 2 || event.shiftKey
};
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging || dragging.id !== event.pointerId) return;
const dx = event.clientX - dragging.x;
const dy = event.clientY - dragging.y;
dragging.x = event.clientX;
dragging.y = event.clientY;
if (dragging.pan) {
const right = new THREE.Vector3(
Math.cos(cameraControl.desired.theta),
0,
-Math.sin(cameraControl.desired.theta)
);
const forward = new THREE.Vector3(
Math.sin(cameraControl.desired.theta),
0,
Math.cos(cameraControl.desired.theta)
);
const panScale = cameraControl.desired.radius * 0.00135;
cameraControl.desiredTarget.addScaledVector(right, -dx * panScale);
cameraControl.desiredTarget.addScaledVector(forward, dy * panScale);
} else {
cameraControl.desired.theta -= dx * 0.006;
cameraControl.desired.phi -= dy * 0.005;
cameraControl.desired.phi = THREE.MathUtils.clamp(
cameraControl.desired.phi,
0.34,
1.46
);
}
});
function endDrag(event) {
if (dragging && dragging.id === event.pointerId) dragging = null;
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraControl.desired.radius *= Math.exp(event.deltaY * 0.001);
cameraControl.desired.radius = THREE.MathUtils.clamp(
cameraControl.desired.radius,
cameraControl.minRadius,
cameraControl.maxRadius
);
},
{ passive: false }
);
function resetView() {
cameraControl.desiredTarget.set(0, 1, 0);
cameraControl.desired.set(31.5, 1.03, 0.69);
}
resetButton.addEventListener("click", resetView);
let paused = false;
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Resume scene" : "Pause scene";
pauseButton.setAttribute("aria-pressed", String(paused));
});
window.addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "r") resetView();
if (event.code === "Space") {
event.preventDefault();
pauseButton.click();
}
});
// ------------------------------------------------------------
// Materials and geometry helpers
// ------------------------------------------------------------
const materialCache = new Map();
function material(color, options = {}) {
const key = `${color}|${JSON.stringify(options)}`;
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
...options
})
);
}
return materialCache.get(key);
}
function solid(geometry, colorOrMaterial, parent = scene, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(
geometry,
typeof colorOrMaterial === "string"
? material(colorOrMaterial)
: colorOrMaterial
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function box(parent, w, h, d, color, x = 0, y = 0, z = 0) {
return solid(
new THREE.BoxGeometry(w, h, d),
color,
parent,
x,
y,
z
);
}
function cylinder(
parent,
topRadius,
bottomRadius,
height,
color,
x = 0,
y = 0,
z = 0,
segments = 16
) {
return solid(
new THREE.CylinderGeometry(
topRadius,
bottomRadius,
height,
segments
),
color,
parent,
x,
y,
z
);
}
function sphere(parent, radius, color, x = 0, y = 0, z = 0) {
return solid(
new THREE.SphereGeometry(radius, 16, 12),
color,
parent,
x,
y,
z
);
}
function cylinderBetween(parent, start, end, radius, color) {
const direction = new THREE.Vector3().subVectors(end, start);
const mesh = cylinder(
parent,
radius,
radius,
direction.length(),
color,
0,
0,
0,
10
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return mesh;
}
// ------------------------------------------------------------
// Ground, paving, and light
// ------------------------------------------------------------
function makePavingTexture() {
const canvas = document.createElement("canvas");
canvas.width = canvas.height = 512;
const context = canvas.getContext("2d");
let seed = 71;
const random = () => {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
};
context.fillStyle = "#b7aa93";
context.fillRect(0, 0, 512, 512);
const tile = 64;
for (let row = 0; row < 8; row++) {
for (let col = 0; col < 8; col++) {
const light = 69 + random() * 8;
const warmth = random() * 7;
context.fillStyle = `hsl(${38 + warmth}, 25%, ${light}%)`;
context.fillRect(
col * tile + 2,
row * tile + 2,
tile - 4,
tile - 4
);
}
}
for (let i = 0; i < 1800; i++) {
context.fillStyle = random() > 0.5
? "rgba(255,255,255,0.045)"
: "rgba(50,40,30,0.035)";
context.fillRect(
random() * 512,
random() * 512,
1 + random() * 2,
1 + random() * 2
);
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(5, 4);
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
const outerGround = solid(
new THREE.PlaneGeometry(120, 120),
"#afc2b5",
scene,
0,
-0.62,
0
);
outerGround.rotation.x = -Math.PI / 2;
outerGround.castShadow = false;
box(scene, 26, 0.62, 20, "#c8bda7", 0, -0.31, 0);
const paving = solid(
new THREE.PlaneGeometry(26, 20),
new THREE.MeshStandardMaterial({
map: makePavingTexture(),
roughness: 0.96
}),
scene,
0,
0.012,
0
);
paving.rotation.x = -Math.PI / 2;
paving.castShadow = false;
// A narrow border emphasizes the edge of the plaza.
box(scene, 26.2, 0.12, 0.28, "#eee3cf", 0, 0.05, 9.92);
box(scene, 26.2, 0.12, 0.28, "#eee3cf", 0, 0.05, -9.92);
box(scene, 0.28, 0.12, 20, "#eee3cf", -12.92, 0.05, 0);
box(scene, 0.28, 0.12, 20, "#eee3cf", 12.92, 0.05, 0);
const hemisphere = new THREE.HemisphereLight("#edf5ed", "#8f806b", 2.1);
scene.add(hemisphere);
const sunlight = new THREE.DirectionalLight("#fff0cf", 3.25);
sunlight.position.set(-10, 18, 12);
sunlight.castShadow = true;
sunlight.shadow.mapSize.set(2048, 2048);
sunlight.shadow.camera.left = -18;
sunlight.shadow.camera.right = 18;
sunlight.shadow.camera.top = 18;
sunlight.shadow.camera.bottom = -18;
sunlight.shadow.camera.near = 1;
sunlight.shadow.camera.far = 52;
sunlight.shadow.bias = -0.00035;
sunlight.shadow.normalBias = 0.025;
scene.add(sunlight);
const fillLight = new THREE.DirectionalLight("#b8d8e3", 0.65);
fillLight.position.set(12, 9, -14);
scene.add(fillLight);
const sunDisc = new THREE.Mesh(
new THREE.SphereGeometry(2.2, 24, 16),
new THREE.MeshBasicMaterial({ color: "#f8dda2" })
);
sunDisc.position.set(-17, 17, -28);
scene.add(sunDisc);
// ------------------------------------------------------------
// Café building and tables
// ------------------------------------------------------------
function makeLabelTexture(title, subtitle = "") {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const context = canvas.getContext("2d");
context.fillStyle = "#f7efdc";
context.fillRect(0, 0, 1024, 256);
context.strokeStyle = "#d6b786";
context.lineWidth = 12;
context.strokeRect(12, 12, 1000, 232);
context.textAlign = "center";
context.textBaseline = "middle";
context.fillStyle = "#315b55";
context.font = "600 88px Georgia";
context.fillText(title, 512, subtitle ? 101 : 132);
if (subtitle) {
context.fillStyle = "#9a7750";
context.font = "600 34px sans-serif";
context.letterSpacing = "5px";
context.fillText(subtitle, 512, 187);
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
const cafe = new THREE.Group();
cafe.position.set(-7, 0, -8.45);
scene.add(cafe);
box(cafe, 7.4, 3.5, 2.2, "#e8dcc5", 0, 1.75, 0);
box(cafe, 8, 0.32, 2.8, "#6a776a", 0, 3.68, 0);
box(cafe, 7.7, 0.18, 2.5, "#f0e4cf", 0, 3.46, 0);
// Windows and door.
box(cafe, 1.85, 1.45, 0.08, "#496c69", -2.05, 1.55, 1.13);
box(cafe, 1.85, 1.45, 0.08, "#496c69", 2.05, 1.55, 1.13);
box(cafe, 0.08, 1.45, 0.1, "#d8c7a7", -2.05, 1.55, 1.19);
box(cafe, 0.08, 1.45, 0.1, "#d8c7a7", 2.05, 1.55, 1.19);
box(cafe, 1.05, 2.25, 0.09, "#42635f", 0, 1.13, 1.14);
sphere(cafe, 0.055, "#d8b56d", 0.37, 1.08, 1.22);
// Striped awning.
for (let i = 0; i < 10; i++) {
const awningPiece = box(
cafe,
0.76,
0.13,
1.55,
i % 2 === 0 ? "#cf6e59" : "#f2e7d0",
-3.42 + i * 0.76,
2.66,
1.65
);
awningPiece.rotation.x = -0.08;
}
cylinder(cafe, 0.055, 0.055, 2.55, "#806e55", -3.62, 1.28, 2.25);
cylinder(cafe, 0.055, 0.055, 2.55, "#806e55", 3.62, 1.28, 2.25);
const cafeSign = new THREE.Mesh(
new THREE.PlaneGeometry(4.8, 0.92),
new THREE.MeshBasicMaterial({
map: makeLabelTexture("CAFÉ ÉTOILE", "COFFEE • PASTRIES • QUIET CORNERS")
})
);
cafeSign.position.set(0, 3.04, 1.13);
cafe.add(cafeSign);
function makeChair(x, z, rotation = 0, color = "#9c7656") {
const chair = new THREE.Group();
chair.position.set(x, 0, z);
chair.rotation.y = rotation;
scene.add(chair);
box(chair, 0.56, 0.11, 0.54, color, 0, 0.58, 0);
box(chair, 0.56, 0.58, 0.09, color, 0, 1.0, -0.25);
for (const side of [-1, 1]) {
cylinder(chair, 0.035, 0.035, 0.58, "#685641", side * 0.22, 0.29, 0.17, 8);
cylinder(chair, 0.035, 0.035, 0.58, "#685641", side * 0.22, 0.29, -0.17, 8);
}
return chair;
}
const cafeTables = [];
function makeTable(x, z, chairMode = "east-west") {
const table = new THREE.Group();
table.position.set(x, 0, z);
scene.add(table);
cylinder(table, 0.74, 0.74, 0.13, "#eadfca", 0, 1.08, 0, 28);
cylinder(table, 0.075, 0.09, 1.0, "#6e695d", 0, 0.52, 0, 12);
cylinder(table, 0.42, 0.46, 0.07, "#6e695d", 0, 0.055, 0, 20);
// A cup and small plate make the tables feel inhabited.
cylinder(table, 0.16, 0.16, 0.025, "#faf3e7", 0.22, 1.16, 0.06, 20);
cylinder(table, 0.08, 0.065, 0.14, "#f7efe0", -0.16, 1.2, -0.05, 16);
cylinder(table, 0.068, 0.068, 0.012, "#75503b", -0.16, 1.276, -0.05, 16);
if (chairMode === "east-west") {
makeChair(x - 0.98, z, Math.PI / 2);
makeChair(x + 0.98, z, -Math.PI / 2);
} else {
makeChair(x, z - 0.98, 0);
makeChair(x, z + 0.98, Math.PI);
}
cafeTables.push({ x, z });
return table;
}
makeTable(-8.1, -3.45, "east-west");
makeTable(-4.55, -2.0, "north-south");
makeTable(-7.7, 2.15, "east-west");
// ------------------------------------------------------------
// Stylized people
// ------------------------------------------------------------
function makePerson({
shirt = "#d26f5b",
pants = "#405b64",
skin = "#c88e68",
hair = "#493b32",
seated = false,
scale = 1
} = {}) {
const root = new THREE.Group();
root.scale.setScalar(scale);
scene.add(root);
const torsoHeight = seated ? 0.55 : 0.62;
const torsoY = seated ? 1.02 : 1.19;
const headY = seated ? 1.48 : 1.73;
const torso = solid(
new THREE.CylinderGeometry(
seated ? 0.22 : 0.23,
seated ? 0.25 : 0.27,
torsoHeight,
12
),
shirt,
root,
0,
torsoY,
0
);
const head = new THREE.Group();
head.position.set(0, headY, 0);
root.add(head);
sphere(head, 0.19, skin);
const hairCap = sphere(head, 0.195, hair, 0, 0.105, -0.012);
hairCap.scale.set(1.02, 0.56, 1.01);
sphere(head, 0.025, skin, 0, -0.005, 0.182);
sphere(head, 0.015, "#283333", -0.062, 0.035, 0.173);
sphere(head, 0.015, "#283333", 0.062, 0.035, 0.173);
if (randomPersonStyle() === 0) {
const bun = sphere(head, 0.09, hair, 0, 0.14, -0.15);
bun.scale.set(1, 0.8, 0.8);
}
const arms = [];
const legs = [];
if (seated) {
for (const side of [-1, 1]) {
const thigh = cylinder(
root,
0.095,
0.1,
0.4,
pants,
side * 0.12,
0.64,
0.19,
10
);
thigh.rotation.x = Math.PI / 2;
sphere(root, 0.1, pants, side * 0.12, 0.61, 0.39);
cylinder(root, 0.085, 0.075, 0.43, pants, side * 0.12, 0.38, 0.4, 10);
box(root, 0.18, 0.11, 0.29, "#3e3934", side * 0.12, 0.15, 0.47);
}
} else {
for (const side of [-1, 1]) {
const legPivot = new THREE.Group();
legPivot.position.set(side * 0.12, 0.86, 0);
root.add(legPivot);
cylinder(legPivot, 0.085, 0.075, 0.68, pants, 0, -0.34, 0, 10);
box(legPivot, 0.18, 0.12, 0.3, "#393735", 0, -0.71, 0.065);
legs.push(legPivot);
}
}
for (const side of [-1, 1]) {
const armPivot = new THREE.Group();
armPivot.position.set(side * 0.28, seated ? 1.23 : 1.45, 0);
root.add(armPivot);
cylinder(
armPivot,
0.068,
0.06,
seated ? 0.48 : 0.58,
shirt,
0,
seated ? -0.24 : -0.29,
0,
10
);
sphere(armPivot, 0.073, skin, 0, seated ? -0.5 : -0.61, 0);
arms.push(armPivot);
}
root.userData.parts = { torso, head, arms, legs, seated };
return root;
}
function randomPersonStyle() {
return Math.floor(Math.random() * 3);
}
function faceTarget(object, target) {
object.rotation.y = Math.atan2(
target.x - object.position.x,
target.z - object.position.z
);
}
// ------------------------------------------------------------
// Musician and performance area
// ------------------------------------------------------------
const rug = cylinder(
scene,
2.12,
2.12,
0.055,
"#c66f5c",
-1.3,
0.05,
-0.45,
48
);
rug.receiveShadow = true;
const rugBorder = solid(
new THREE.TorusGeometry(1.89, 0.025, 8, 64),
"#e5aa83",
scene,
-1.3,
0.083,
-0.45
);
rugBorder.rotation.x = Math.PI / 2;
const musician = makePerson({
shirt: "#3d7773",
pants: "#6a5144",
skin: "#9f6749",
hair: "#2f2927"
});
musician.position.set(-1.3, 0, -0.48);
const hatBrim = cylinder(
musician,
0.34,
0.34,
0.045,
"#d6b873",
0,
1.92,
0,
24
);
const hatCrown = cylinder(
musician,
0.22,
0.25,
0.18,
"#d6b873",
0,
2.01,
0,
20
);
const guitar = new THREE.Group();
guitar.position.set(0, 1.14, 0.34);
guitar.rotation.z = -0.43;
musician.add(guitar);
const guitarBody = sphere(guitar, 0.38, "#bb6d3d");
guitarBody.scale.set(0.95, 1.16, 0.34);
const guitarNeck = box(guitar, 0.115, 0.9, 0.075, "#65432f", 0.17, 0.54, 0);
guitarNeck.rotation.z = -0.17;
const guitarHead = box(guitar, 0.18, 0.2, 0.09, "#3e3029", 0.27, 1.02, 0);
guitarHead.rotation.z = -0.17;
for (const offset of [-0.025, 0, 0.025]) {
box(guitar, 0.009, 0.84, 0.012, "#e5d6b5", 0.17 + offset, 0.57, 0.049);
}
cylinder(guitar, 0.14, 0.14, 0.02, "#4b3327", 0, -0.2, 0.045, 18);
musician.userData.guitar = guitar;
musician.userData.parts.arms[0].rotation.set(-1.05, 0, 0.42);
musician.userData.parts.arms[1].rotation.set(-1.14, 0, -0.42);
// Microphone and stand.
const microphone = new THREE.Group();
microphone.position.set(1.18, 0, 0.28);
scene.add(microphone);
cylinder(microphone, 0.27, 0.3, 0.08, "#343b3b", 0, 0.06, 0, 20);
cylinder(microphone, 0.025, 0.025, 1.55, "#40494a", 0, 0.82, 0, 10);
cylinderBetween(
microphone,
new THREE.Vector3(0, 1.54, 0),
new THREE.Vector3(-0.42, 1.72, 0),
0.022,
"#40494a"
);
const micHead = sphere(microphone, 0.075, "#2d3334", -0.44, 1.73, 0);
micHead.scale.set(1.15, 0.9, 0.9);
// Small speakers.
function makeSpeaker(x, z) {
const speaker = new THREE.Group();
speaker.position.set(x, 0, z);
speaker.rotation.y = x < -1.3 ? 0.15 : -0.15;
scene.add(speaker);
box(speaker, 0.56, 0.88, 0.48, "#3b4545", 0, 0.48, 0);
const speakerCone = cylinder(
speaker,
0.16,
0.16,
0.025,
"#1f292a",
0,
0.38,
0.255,
20
);
speakerCone.rotation.x = Math.PI / 2;
const tweeter = cylinder(
speaker,
0.07,
0.07,
0.025,
"#202829",
0,
0.72,
0.255,
16
);
tweeter.rotation.x = Math.PI / 2;
}
makeSpeaker(-3.0, 0.05);
makeSpeaker(0.42, -0.12);
// Small session sign.
const posterTextureCanvas = document.createElement("canvas");
posterTextureCanvas.width = 512;
posterTextureCanvas.height = 512;
const posterContext = posterTextureCanvas.getContext("2d");
posterContext.fillStyle = "#f4e8cf";
posterContext.fillRect(0, 0, 512, 512);
posterContext.strokeStyle = "#cc725a";
posterContext.lineWidth = 18;
posterContext.strokeRect(18, 18, 476, 476);
posterContext.fillStyle = "#315b55";
posterContext.textAlign = "center";
posterContext.font = "700 72px Georgia";
posterContext.fillText("CORNER", 256, 175);
posterContext.fillText("SESSION", 256, 255);
posterContext.fillStyle = "#b36e50";
posterContext.font = "600 29px sans-serif";
posterContext.fillText("SONGS • 4 PM", 256, 337);
const posterTexture = new THREE.CanvasTexture(posterTextureCanvas);
posterTexture.colorSpace = THREE.SRGBColorSpace;
const poster = new THREE.Group();
poster.position.set(-4.1, 0, 0.75);
poster.rotation.y = 0.22;
scene.add(poster);
box(poster, 1.4, 1.15, 0.1, "#a47b55", 0, 0.72, 0);
const posterFace = new THREE.Mesh(
new THREE.PlaneGeometry(1.32, 1.06),
new THREE.MeshBasicMaterial({ map: posterTexture })
);
posterFace.position.set(0, 0.72, 0.056);
poster.add(posterFace);
// ------------------------------------------------------------
// Audience: sparse, attentive, and clearly separated
// ------------------------------------------------------------
function makeBench(x, z, rotation = 0) {
const bench = new THREE.Group();
bench.position.set(x, 0, z);
bench.rotation.y = rotation;
scene.add(bench);
box(bench, 3.15, 0.13, 0.64, "#8f684b", 0, 0.59, 0);
box(bench, 3.15, 0.57, 0.11, "#9c7554", 0, 1.0, -0.29);
for (const xSide of [-1.25, 1.25]) {
box(bench, 0.13, 0.62, 0.53, "#4b5554", xSide, 0.3, 0);
box(bench, 0.12, 1.1, 0.12, "#4b5554", xSide, 0.55, -0.29);
}
}
makeBench(0.9, 3.38, Math.PI);
const audience = [];
function addAudienceMember(person, phase, seated = false) {
faceTarget(person, musician.position);
person.userData.audiencePhase = phase;
person.userData.audienceSeated = seated;
audience.push(person);
}
const listenerA = makePerson({
shirt: "#d8a85c",
pants: "#526c6b",
skin: "#e0ad84",
hair: "#5a3d31"
});
listenerA.position.set(-3.25, 0, 2.05);
addAudienceMember(listenerA, 0.2);
const listenerB = makePerson({
shirt: "#758fa3",
pants: "#574c48",
skin: "#8f5f45",
hair: "#2e2a28",
seated: true
});
listenerB.position.set(0, 0, 3.38);
listenerB.rotation.y = Math.PI;
addAudienceMember(listenerB, 1.3, true);
const listenerC = makePerson({
shirt: "#bc7b79",
pants: "#3f5961",
skin: "#d7a17a",
hair: "#705044",
seated: true
});
listenerC.position.set(1.8, 0, 3.38);
listenerC.rotation.y = Math.PI;
addAudienceMember(listenerC, 2.4, true);
const listenerD = makePerson({
shirt: "#6f8d6a",
pants: "#765c4d",
skin: "#a86f50",
hair: "#46352d"
});
listenerD.position.set(3.35, 0, 1.92);
addAudienceMember(listenerD, 3.4);
// Café patrons remain occupied with their own table.
const cafePatrons = [];
const cafeReader = makePerson({
shirt: "#c67d67",
pants: "#435c60",
skin: "#e0a77d",
hair: "#594036",
seated: true
});
cafeReader.position.set(-9.08, 0, -3.45);
cafeReader.rotation.y = Math.PI / 2;
cafePatrons.push(cafeReader);
const cafeReaderTwo = makePerson({
shirt: "#6f8f86",
pants: "#514945",
skin: "#9c674a",
hair: "#322a27",
seated: true
});
cafeReaderTwo.position.set(-4.55, 0, -2.98);
cafeReaderTwo.rotation.y = 0;
cafePatrons.push(cafeReaderTwo);
// ------------------------------------------------------------
// Fountain positioned at the plaza edge
// ------------------------------------------------------------
const fountain = new THREE.Group();
fountain.position.set(7.05, 0, -8.05);
scene.add(fountain);
cylinder(fountain, 2.28, 2.4, 0.34, "#b8b6a8", 0, 0.17, 0, 48);
cylinder(fountain, 1.96, 1.96, 0.12, "#8faaa5", 0, 0.37, 0, 48);
const waterMaterial = new THREE.MeshStandardMaterial({
color: "#6bb8bd",
roughness: 0.24,
metalness: 0.05,
transparent: true,
opacity: 0.88
});
cylinder(fountain, 1.92, 1.92, 0.055, waterMaterial, 0, 0.45, 0, 48);
const fountainRim = solid(
new THREE.TorusGeometry(2.08, 0.17, 12, 64),
"#d1d0c0",
fountain,
0,
0.43,
0
);
fountainRim.rotation.x = Math.PI / 2;
cylinder(fountain, 0.24, 0.42, 1.25, "#c3c3b4", 0, 1.0, 0, 24);
cylinder(fountain, 0.8, 0.35, 0.27, "#d1d0c0", 0, 1.65, 0, 32);
cylinder(fountain, 0.68, 0.68, 0.03, waterMaterial, 0, 1.81, 0, 32);
const streamMaterial = new THREE.MeshStandardMaterial({
color: "#c7f0ed",
transparent: true,
opacity: 0.56,
roughness: 0.15,
depthWrite: false
});
const jetCurves = [];
const jetDrops = [];
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
const end = new THREE.Vector3(
Math.cos(angle) * 1.55,
0.52,
Math.sin(angle) * 1.55
);
const curve = new THREE.QuadraticBezierCurve3(
new THREE.Vector3(0, 1.84, 0),
new THREE.Vector3(
Math.cos(angle) * 0.75,
2.65,
Math.sin(angle) * 0.75
),
end
);
jetCurves.push(curve);
const stream = new THREE.Mesh(
new THREE.TubeGeometry(curve, 28, 0.021, 6, false),
streamMaterial
);
fountain.add(stream);
const drop = sphere(fountain, 0.045, "#d5f5f1");
jetDrops.push(drop);
}
const fountainRipples = [];
for (let i = 0; i < 4; i++) {
const rippleMaterial = new THREE.MeshBasicMaterial({
color: "#d5f2e8",
transparent: true,
opacity: 0.4,
depthWrite: false
});
const ripple = new THREE.Mesh(
new THREE.TorusGeometry(0.22, 0.012, 6, 40),
rippleMaterial
);
ripple.rotation.x = Math.PI / 2;
ripple.position.y = 0.49;
fountain.add(ripple);
fountainRipples.push(ripple);
}
// ------------------------------------------------------------
// Trees, planters, lamps, and small street details
// ------------------------------------------------------------
const swayingCanopies = [];
function makeTree(x, z, scale = 1) {
const tree = new THREE.Group();
tree.position.set(x, 0, z);
tree.scale.setScalar(scale);
scene.add(tree);
cylinder(tree, 0.55, 0.68, 0.38, "#a78669", 0, 0.19, 0, 16);
cylinder(tree, 0.16, 0.24, 2.3, "#80664d", 0, 1.35, 0, 10);
const canopy = new THREE.Group();
canopy.position.y = 2.5;
tree.add(canopy);
const leafColors = ["#6f9675", "#7fa17d", "#5f876d"];
for (let i = 0; i < 4; i++) {
const angle = i * Math.PI * 0.5;
const leaf = solid(
new THREE.IcosahedronGeometry(0.9 + (i % 2) * 0.13, 1),
leafColors[i % leafColors.length],
canopy,
Math.cos(angle) * 0.48,
(i % 2) * 0.34,
Math.sin(angle) * 0.48
);
leaf.scale.set(1.1, 0.92, 1.08);
}
swayingCanopies.push({ canopy, phase: Math.random() * Math.PI * 2 });
}
makeTree(-10.7, -5.1, 1.05);
makeTree(-10.65, 6.45, 0.92);
makeTree(9.75, 3.65, 1.0);
makeTree(4.45, -8.75, 0.82);
makeTree(-1.2, -8.85, 0.78);
function makeLamp(x, z) {
const lamp = new THREE.Group();
lamp.position.set(x, 0, z);
scene.add(lamp);
cylinder(lamp, 0.15, 0.2, 0.25, "#485451", 0, 0.12, 0, 12);
cylinder(lamp, 0.045, 0.065, 3.2, "#485451", 0, 1.7, 0, 10);
cylinder(lamp, 0.24, 0.13, 0.22, "#485451", 0, 3.35, 0, 16);
const bulb = sphere(
lamp,
0.18,
new THREE.MeshStandardMaterial({
color: "#ffe2a6",
emissive: "#e5a94b",
emissiveIntensity: 1.4,
roughness: 0.35
}),
0,
3.57,
0
);
bulb.scale.y = 1.2;
}
makeLamp(-11.35, 1.1);
makeLamp(6.0, 6.1);
makeLamp(11.45, -0.9);
for (const x of [-10, -6, -2, 2, 6, 10]) {
cylinder(scene, 0.09, 0.11, 0.52, "#59625d", x, 0.27, 9.45, 10);
sphere(scene, 0.105, "#d8cfb7", x, 0.56, 9.45);
}
// Small flower beds along the edge.
for (const [x, z] of [[-8.4, 6.9], [5.7, -4.65], [11.2, 1.9]]) {
box(scene, 1.55, 0.32, 0.78, "#a88969", x, 0.16, z);
for (let i = 0; i < 7; i++) {
const flower = sphere(
scene,
0.09,
i % 2 ? "#e0a16c" : "#b97d83",
x - 0.57 + i * 0.19,
0.39 + (i % 2) * 0.08,
z + (i % 2 ? 0.12 : -0.1)
);
flower.scale.y = 0.65;
}
}
// ------------------------------------------------------------
// Passing pedestrians: ordinary movement around the listeners
// ------------------------------------------------------------
const walkers = [];
function makeWalker(points, speed, colors, phase = 0, glances = false) {
const person = makePerson(colors);
const curve = new THREE.CatmullRomCurve3(
points.map(([x, z]) => new THREE.Vector3(x, 0, z)),
true,
"catmullrom",
0.3
);
walkers.push({
person,
curve,
speed,
progress: phase,
phase: phase * 10,
glances
});
}
makeWalker(
[
[-12, 7.45],
[-5, 7.8],
[3, 8.05],
[11.4, 7.45],
[11.6, 5.0],
[7.2, 5.2],
[-1.0, 5.65],
[-12, 6.5]
],
0.78,
{
shirt: "#d6a958",
pants: "#4d6467",
skin: "#bd805b",
hair: "#3b302b"
},
0.08,
true
);
makeWalker(
[
[9.2, 5.8],
[10.45, 2.4],
[10.15, -1.7],
[8.0, -3.45],
[4.4, -3.25],
[4.65, -0.7],
[5.45, 2.85],
[7.55, 5.15]
],
0.67,
{
shirt: "#7794a4",
pants: "#68544b",
skin: "#e2ad82",
hair: "#6b4b38"
},
0.43
);
makeWalker(
[
[-11.5, -5.25],
[-5.6, -4.95],
[1.8, -4.55],
[4.8, -3.85],
[1.0, -3.7],
[-5.6, -4.2],
[-11.5, -4.25]
],
0.72,
{
shirt: "#8a9b79",
pants: "#3e555c",
skin: "#9c674b",
hair: "#302824"
},
0.72
);
// ------------------------------------------------------------
// Pigeons and floating musical notes
// ------------------------------------------------------------
const pigeons = [];
function makePigeon(x, z, phase) {
const pigeon = new THREE.Group();
pigeon.position.set(x, 0, z);
scene.add(pigeon);
const body = sphere(pigeon, 0.13, "#87908b");
body.scale.set(1.35, 0.9, 0.9);
sphere(pigeon, 0.075, "#9ea49e", 0.1, 0.13, 0);
box(pigeon, 0.06, 0.035, 0.08, "#d7a45f", 0.17, 0.12, 0);
cylinder(pigeon, 0.012, 0.012, 0.14, "#b19a61", 0, 0.075, 0, 6);
pigeons.push({ pigeon, baseX: x, baseZ: z, phase });
}
makePigeon(6.6, 5.8, 0.2);
makePigeon(7.1, 5.55, 2.1);
makePigeon(-8.9, 5.0, 4.3);
function makeNoteTexture() {
const canvas = document.createElement("canvas");
canvas.width = 128;
canvas.height = 128;
const context = canvas.getContext("2d");
context.clearRect(0, 0, 128, 128);
context.fillStyle = "#fff3c9";
context.font = "96px Georgia";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText("♪", 64, 68);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
}
const noteTexture = makeNoteTexture();
const musicNotes = [];
for (let i = 0; i < 3; i++) {
const note = new THREE.Sprite(
new THREE.SpriteMaterial({
map: noteTexture,
transparent: true,
opacity: 0.72,
depthWrite: false
})
);
note.scale.set(0.48, 0.65, 1);
scene.add(note);
musicNotes.push({ note, offset: i / 3, x: -1.3 + (i - 1) * 0.38 });
}
// Distant, simple clouds add depth without distracting from the plaza.
const clouds = [];
for (const [x, y, z, scale] of [
[-8, 12, -27, 1.4],
[9, 14, -31, 1.7],
[19, 10, -24, 1.1]
]) {
const cloud = new THREE.Group();
cloud.position.set(x, y, z);
cloud.scale.setScalar(scale);
scene.add(cloud);
for (let i = 0; i < 4; i++) {
const puff = new THREE.Mesh(
new THREE.SphereGeometry(0.8 + (i % 2) * 0.22, 14, 10),
new THREE.MeshBasicMaterial({
color: "#edf1e8",
transparent: true,
opacity: 0.78
})
);
puff.position.set(i * 0.72 - 1.1, Math.sin(i) * 0.18, 0);
puff.scale.set(1.2, 0.65, 0.8);
cloud.add(puff);
}
clouds.push(cloud);
}
// ------------------------------------------------------------
// Animation
// ------------------------------------------------------------
const clock = new THREE.Clock();
let elapsed = 0;
function smoothStep(value) {
const clamped = THREE.MathUtils.clamp(value, 0, 1);
return clamped * clamped * (3 - 2 * clamped);
}
function updateAudience(time) {
for (const person of audience) {
const phase = person.userData.audiencePhase;
const parts = person.userData.parts;
parts.torso.scale.y = 1 + Math.sin(time * 1.45 + phase) * 0.009;
parts.head.rotation.y = Math.sin(time * 0.55 + phase) * 0.08;
parts.head.rotation.x = Math.sin(time * 0.7 + phase) * 0.025;
const cycle = (time + phase * 0.65) % 7.2;
let clap = 0;
if (cycle > 1.2 && cycle < 3.0) {
clap = Math.sin(((cycle - 1.2) / 1.8) * Math.PI);
}
parts.arms[0].rotation.x = -0.12 - clap * 1.08;
parts.arms[1].rotation.x = -0.12 - clap * 1.08;
parts.arms[0].rotation.z = 0.05 + clap * 0.2;
parts.arms[1].rotation.z = -0.05 - clap * 0.2;
}
}
function updateCafePatrons(time) {
cafePatrons.forEach((person, index) => {
const parts = person.userData.parts;
parts.torso.scale.y = 1 + Math.sin(time * 1.1 + index) * 0.008;
parts.head.rotation.x = -0.08 + Math.sin(time * 0.5 + index) * 0.025;
const sip = Math.pow(
Math.max(0, Math.sin(time * 0.42 + index * 1.8)),
12
);
parts.arms[0].rotation.x = -0.18 - sip * 0.78;
parts.arms[1].rotation.x = -0.16;
});
}
function updateWalkers(dt, time) {
for (const walker of walkers) {
const { person, curve, speed } = walker;
const length = curve.getLength();
walker.progress = (walker.progress + (speed * dt) / length) % 1;
walker.phase += dt * speed * 5.7;
const position = curve.getPointAt(walker.progress);
const tangent = curve.getTangentAt(walker.progress);
person.position.copy(position);
person.rotation.y = Math.atan2(tangent.x, tangent.z);
const parts = person.userData.parts;
const swing = Math.sin(walker.phase) * 0.55;
parts.legs[0].rotation.x = swing;
parts.legs[1].rotation.x = -swing;
parts.arms[0].rotation.x = -swing * 0.72;
parts.arms[1].rotation.x = swing * 0.72;
parts.torso.scale.y = 1 + Math.abs(Math.sin(walker.phase)) * 0.012;
if (walker.glances) {
const proximity = Math.max(
0,
1 - Math.abs(person.position.x - musician.position.x) / 4.2
);
parts.head.rotation.y = -0.62 * proximity;
parts.head.rotation.x = 0.06 * proximity;
} else {
parts.head.rotation.y = Math.sin(time * 0.8 + walker.phase) * 0.06;
}
}
}
function updateFountain(time) {
jetDrops.forEach((drop, index) => {
const progress = (time * 0.52 + index / jetDrops.length) % 1;
drop.position.copy(jetCurves[index].getPoint(progress));
});
fountainRipples.forEach((ripple, index) => {
const progress = (time * 0.34 + index / fountainRipples.length) % 1;
const scale = 1 + progress * 5.4;
ripple.scale.setScalar(scale);
ripple.material.opacity = 0.42 * (1 - progress);
});
}
function updatePigeons(time) {
pigeons.forEach(({ pigeon, baseX, baseZ, phase }) => {
pigeon.position.x = baseX + Math.sin(time * 0.22 + phase) * 0.28;
pigeon.position.z = baseZ + Math.cos(time * 0.19 + phase) * 0.16;
const peck = Math.pow(
Math.max(0, Math.sin(time * 1.6 + phase)),
10
);
pigeon.rotation.x = peck * 0.55;
});
}
function updateScene(dt, time) {
const musicianParts = musician.userData.parts;
musicianParts.torso.scale.y = 1 + Math.sin(time * 2.1) * 0.012;
musicianParts.arms[0].rotation.x =
-1.05 + Math.sin(time * 4.1) * 0.13;
musicianParts.arms[1].rotation.x =
-1.14 + Math.sin(time * 4.1 + 0.5) * 0.09;
musician.userData.guitar.rotation.z =
-0.43 + Math.sin(time * 2.0) * 0.025;
musician.userData.guitar.rotation.x =
Math.sin(time * 4.0) * 0.025;
updateAudience(time);
updateCafePatrons(time);
updateWalkers(dt, time);
updateFountain(time);
updatePigeons(time);
swayingCanopies.forEach(({ canopy, phase }) => {
canopy.rotation.z = Math.sin(time * 0.55 + phase) * 0.018;
canopy.rotation.x = Math.cos(time * 0.43 + phase) * 0.012;
});
clouds.forEach((cloud, index) => {
cloud.position.x += dt * (0.035 + index * 0.006);
if (cloud.position.x > 27) cloud.position.x = -25;
});
musicNotes.forEach(({ note, offset, x }) => {
const progress = (time * 0.19 + offset) % 1;
note.position.set(
x + Math.sin(progress * Math.PI * 2 + offset * 5) * 0.35,
2.18 + progress * 1.8,
-0.05 + Math.cos(progress * Math.PI * 2) * 0.15
);
note.material.opacity =
Math.sin(progress * Math.PI) * 0.68;
note.scale.set(
0.42 + Math.sin(progress * Math.PI) * 0.13,
0.58 + Math.sin(progress * Math.PI) * 0.15,
1
);
});
}
function updateCamera() {
const damping = 0.095;
cameraControl.current.radius = THREE.MathUtils.lerp(
cameraControl.current.radius,
cameraControl.desired.radius,
damping
);
cameraControl.current.theta = THREE.MathUtils.lerp(
cameraControl.current.theta,
cameraControl.desired.theta,
damping
);
cameraControl.current.phi = THREE.MathUtils.lerp(
cameraControl.current.phi,
cameraControl.desired.phi,
damping
);
cameraControl.target.lerp(cameraControl.desiredTarget, damping);
camera.position
.copy(cameraControl.target)
.add(
new THREE.Vector3().setFromSpherical(cameraControl.current)
);
camera.lookAt(cameraControl.target);
}
renderer.setAnimationLoop(() => {
const dt = Math.min(clock.getDelta(), 0.05);
if (!paused) {
elapsed += dt;
updateScene(dt, elapsed);
}
updateCamera();
renderer.render(scene, camera);
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
requestAnimationFrame(() => {
loadingElement.classList.add("hidden");
});
</script>
</body>
</html>
```