Prompt specification
Build or customize the Three.js 3D scene "Street Ensemble Spatial Arrangement" 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: Street Ensemble Spatial Arrangement
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/street-ensemble-spatial-arrangement-x3303
Scene Description Prompt:
Build a voxel fictional street ensemble with geometric instruments, separate performer zones, and open listening space. One HTML file using Three.js from cdnjs.
Working Three.js Starter (street-ensemble-spatial-arrangement-x3303):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#17202a" />
<title>Side Street Sessions — Voxel Ensemble</title>
<style>
:root {
--ink: #17202a;
--paper: rgba(249, 246, 237, 0.88);
--paper-solid: #f9f6ed;
--line: rgba(23, 32, 42, 0.14);
--pulse: #f06d5f;
--chime: #18a999;
--signal: #8165d8;
--shadow: 0 18px 50px rgba(23, 32, 42, 0.16);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dfe8e5;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#app,
#app canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
}
#app canvas {
display: block;
outline: none;
cursor: grab;
touch-action: none;
}
#app canvas:active {
cursor: grabbing;
}
.brand {
position: fixed;
z-index: 5;
top: 22px;
left: 22px;
width: min(430px, calc(100vw - 44px));
padding: 18px 20px 17px;
border: 1px solid rgba(255, 255, 255, 0.55);
border-radius: 18px;
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(16px) saturate(1.2);
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
color: rgba(23, 32, 42, 0.64);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
.live-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #ef5b50;
box-shadow: 0 0 0 5px rgba(239, 91, 80, 0.12);
animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
50% {
box-shadow: 0 0 0 8px rgba(239, 91, 80, 0.02);
}
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 39px);
font-weight: 850;
letter-spacing: -0.055em;
line-height: 0.98;
}
.brand p {
max-width: 340px;
margin: 10px 0 0;
color: rgba(23, 32, 42, 0.67);
font-size: 12px;
line-height: 1.5;
}
.transport {
position: fixed;
z-index: 6;
top: 22px;
right: 22px;
display: grid;
gap: 9px;
width: 178px;
padding: 12px;
border: 1px solid rgba(255, 255, 255, 0.55);
border-radius: 18px;
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(16px) saturate(1.2);
}
.transport-title {
padding: 2px 4px 3px;
color: rgba(23, 32, 42, 0.52);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.transport button {
width: 100%;
min-height: 36px;
padding: 8px 11px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255, 255, 255, 0.46);
color: var(--ink);
cursor: pointer;
font-size: 11px;
font-weight: 700;
text-align: left;
transition:
transform 150ms ease,
background 150ms ease,
border-color 150ms ease;
}
.transport button:hover {
transform: translateX(-2px);
border-color: rgba(23, 32, 42, 0.28);
background: white;
}
.transport button.active {
border-color: var(--ink);
background: var(--ink);
color: white;
}
.transport button.sound.active {
border-color: #0b887d;
background: #0b887d;
}
.legend {
position: fixed;
z-index: 5;
bottom: 22px;
left: 22px;
display: flex;
flex-wrap: wrap;
gap: 9px;
max-width: calc(100vw - 44px);
padding: 11px 13px;
border: 1px solid rgba(255, 255, 255, 0.5);
border-radius: 14px;
background: var(--paper);
box-shadow: var(--shadow);
backdrop-filter: blur(14px);
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 7px;
padding: 3px 5px;
color: rgba(23, 32, 42, 0.72);
font-size: 10px;
font-weight: 750;
white-space: nowrap;
}
.swatch {
width: 9px;
height: 9px;
border-radius: 3px;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.camera-hint {
position: fixed;
z-index: 5;
right: 22px;
bottom: 22px;
padding: 10px 13px;
border: 1px solid rgba(255, 255, 255, 0.45);
border-radius: 12px;
background: rgba(249, 246, 237, 0.76);
color: rgba(23, 32, 42, 0.66);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.04em;
pointer-events: none;
backdrop-filter: blur(12px);
}
.loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: #e4ebe6;
transition:
opacity 500ms ease,
visibility 500ms ease;
}
.loading.hidden {
visibility: hidden;
opacity: 0;
}
.loading-card {
text-align: center;
}
.loading-blocks {
display: flex;
justify-content: center;
gap: 5px;
margin-bottom: 15px;
}
.loading-blocks span {
width: 12px;
height: 12px;
border-radius: 3px;
background: var(--pulse);
animation: build 1s ease-in-out infinite alternate;
}
.loading-blocks span:nth-child(2) {
background: var(--chime);
animation-delay: 150ms;
}
.loading-blocks span:nth-child(3) {
background: var(--signal);
animation-delay: 300ms;
}
@keyframes build {
to {
transform: translateY(-9px);
}
}
.loading-card p {
margin: 0;
color: rgba(23, 32, 42, 0.65);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.12em;
text-transform: uppercase;
}
@media (max-width: 720px) {
.brand {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 13px 15px;
}
.brand p {
display: none;
}
h1 {
font-size: 27px;
}
.transport {
top: auto;
right: 12px;
bottom: 62px;
width: 145px;
padding: 9px;
}
.transport button {
min-height: 32px;
padding: 7px 9px;
font-size: 10px;
}
.transport-title,
.camera-hint {
display: none;
}
.legend {
right: 12px;
bottom: 12px;
left: 12px;
gap: 4px;
justify-content: center;
padding: 8px;
}
.legend-item {
font-size: 9px;
}
}
</style>
</head>
<body>
<main id="app" aria-label="Interactive voxel street ensemble"></main>
<header class="brand">
<div class="eyebrow">
<span class="live-dot"></span>
<span id="performance-status">Side Street Sessions · Visual Set</span>
</div>
<h1>A pocket concert<br />for passing feet.</h1>
<p>
Three miniature performers turn an ordinary street corner into a
colorful open-air ensemble.
</p>
</header>
<nav class="transport" aria-label="Scene controls">
<div class="transport-title">Scene controls</div>
<button type="button" data-view="overview" class="active">01 · Overview</button>
<button type="button" data-view="performers">02 · Performers</button>
<button type="button" data-view="audience">03 · Listening space</button>
<button type="button" id="night-button">04 · Night lights</button>
<button type="button" id="labels-button" class="active">05 · Labels on</button>
<button type="button" id="sound-button" class="sound">06 · Start audio</button>
</nav>
<aside class="legend" aria-label="Performance zone legend">
<span class="legend-item">
<span class="swatch" style="background:#f06d5f"></span>
01 Pulse
</span>
<span class="legend-item">
<span class="swatch" style="background:#18a999"></span>
02 Chime
</span>
<span class="legend-item">
<span class="swatch" style="background:#8165d8"></span>
03 Signal
</span>
<span class="legend-item">
<span class="swatch" style="background:#f3c969"></span>
Open listening
</span>
</aside>
<div class="camera-hint">
Drag to orbit · Shift/right-drag to pan · Scroll to zoom
</div>
<div class="loading" id="loading">
<div class="loading-card">
<div class="loading-blocks">
<span></span><span></span><span></span>
</div>
<p>Building the block</p>
</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const app = document.getElementById("app");
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdde8e4);
scene.fog = new THREE.Fog(0xdde8e4, 28, 58);
const camera = new THREE.PerspectiveCamera(
40,
window.innerWidth / window.innerHeight,
0.1,
100
);
let renderer;
try {
renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
} catch (error) {
loading.innerHTML =
'<div class="loading-card"><p>WebGL is required to view this scene.</p></div>';
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75));
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;
app.appendChild(renderer.domElement);
const hemiLight = new THREE.HemisphereLight(0xeaf8ff, 0x867967, 2.2);
scene.add(hemiLight);
const sun = new THREE.DirectionalLight(0xfff2d7, 3.4);
sun.position.set(-9, 16, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -24;
sun.shadow.camera.right = 24;
sun.shadow.camera.top = 22;
sun.shadow.camera.bottom = -20;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const world = new THREE.Group();
const labelGroup = new THREE.Group();
const noteGroup = new THREE.Group();
scene.add(world, labelGroup, noteGroup);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
const zoneMaterials = [];
const musicians = [];
const audience = [];
const mallets = [];
const lampLights = [];
const lampBulbs = [];
const palette = {
ground: 0xdad8ca,
pavement: 0xe9e2d3,
cream: 0xf4eddd,
ink: 0x24313a,
asphalt: 0x44515a,
coral: 0xf06d5f,
teal: 0x18a999,
violet: 0x8165d8,
yellow: 0xf3c969,
orange: 0xe99745,
blue: 0x5598c7,
wood: 0xb9794b,
woodLight: 0xdba16b,
skin: [0xf0bd91, 0xc98258, 0x8f5638, 0xe6a77a]
};
function getMaterial(color, options = {}) {
const roughness = options.roughness ?? 0.8;
const metalness = options.metalness ?? 0;
const emissive = options.emissive ?? 0x000000;
const emissiveIntensity = options.emissiveIntensity ?? 0;
const transparent = options.transparent ?? false;
const opacity = options.opacity ?? 1;
const key = [
color,
roughness,
metalness,
emissive,
emissiveIntensity,
transparent,
opacity
].join("|");
if (!options.unique && materialCache.has(key)) {
return materialCache.get(key);
}
const material = new THREE.MeshStandardMaterial({
color,
roughness,
metalness,
emissive,
emissiveIntensity,
transparent,
opacity
});
if (!options.unique) materialCache.set(key, material);
return material;
}
function box(
parent,
size,
position,
color,
options = {}
) {
const mesh = new THREE.Mesh(
unitBox,
options.material || getMaterial(color, options)
);
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = options.cast !== false;
mesh.receiveShadow = options.receive !== false;
parent.add(mesh);
return mesh;
}
function cylinder(
parent,
radiusTop,
radiusBottom,
height,
position,
color,
options = {}
) {
const geometry = new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
options.segments ?? 16
);
const mesh = new THREE.Mesh(
geometry,
options.material || getMaterial(color, options)
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = options.cast !== false;
mesh.receiveShadow = options.receive !== false;
parent.add(mesh);
return mesh;
}
function sphere(parent, radius, position, color, options = {}) {
const geometry = new THREE.SphereGeometry(radius, 12, 8);
const mesh = new THREE.Mesh(
geometry,
options.material || getMaterial(color, options)
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = options.cast !== false;
parent.add(mesh);
return mesh;
}
function makeTextTexture(text, options = {}) {
const canvas = document.createElement("canvas");
canvas.width = options.width ?? 1024;
canvas.height = options.height ?? 256;
const context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
if (options.background) {
context.fillStyle = options.background;
context.fillRect(0, 0, canvas.width, canvas.height);
}
if (options.border) {
context.strokeStyle = options.border;
context.lineWidth = 10;
context.strokeRect(8, 8, canvas.width - 16, canvas.height - 16);
}
const lines = String(text).split("\n");
const fontSize = options.fontSize ?? 76;
const lineHeight = fontSize * 1.12;
context.textAlign = "center";
context.textBaseline = "middle";
context.font = `${options.weight ?? 800} ${fontSize}px Arial, sans-serif`;
context.fillStyle = options.color ?? "#17202a";
const startY = canvas.height / 2 - ((lines.length - 1) * lineHeight) / 2;
lines.forEach((line, index) => {
context.fillText(line, canvas.width / 2, startY + index * lineHeight);
});
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
function addText(
parent,
text,
worldWidth,
worldHeight,
position,
rotation = [0, 0, 0],
options = {}
) {
const texture = makeTextTexture(text, options);
const material = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
side: THREE.DoubleSide,
toneMapped: false
});
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(worldWidth, worldHeight),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.rotation.set(rotation[0], rotation[1], rotation[2]);
parent.add(mesh);
return mesh;
}
function makeVoxelPerson(config) {
const group = new THREE.Group();
const skin = config.skin ?? palette.skin[0];
const shirt = config.shirt ?? palette.coral;
const trousers = config.trousers ?? palette.ink;
const seated = config.seated ?? false;
const scale = config.scale ?? 1;
const bodyY = seated ? 0.8 : 1.02;
const headY = seated ? 1.37 : 1.62;
box(group, [0.54, 0.64, 0.36], [0, bodyY, 0], shirt);
box(group, [0.58, 0.08, 0.39], [0, bodyY + 0.3, 0.01], shirt, {
roughness: 0.65
});
box(group, [0.43, 0.43, 0.42], [0, headY, 0], skin);
box(group, [0.46, 0.14, 0.45], [0, headY + 0.2, -0.015], config.hair ?? 0x3b302c);
if (config.hat) {
box(group, [0.51, 0.13, 0.5], [0, headY + 0.28, 0], config.hat);
box(group, [0.6, 0.05, 0.35], [0, headY + 0.22, 0.18], config.hat);
}
box(group, [0.055, 0.065, 0.025], [-0.105, headY + 0.015, 0.216], 0x26313a, {
cast: false
});
box(group, [0.055, 0.065, 0.025], [0.105, headY + 0.015, 0.216], 0x26313a, {
cast: false
});
box(group, [0.055, 0.045, 0.025], [0, headY - 0.055, 0.22], skin, {
cast: false
});
const legY = seated ? 0.38 : 0.36;
box(group, [0.19, 0.58, 0.21], [-0.15, legY, seated ? 0.05 : 0], trousers);
box(group, [0.19, 0.58, 0.21], [0.15, legY, seated ? 0.05 : 0], trousers);
if (seated) {
box(group, [0.19, 0.17, 0.42], [-0.15, 0.18, 0.25], trousers);
box(group, [0.19, 0.17, 0.42], [0.15, 0.18, 0.25], trousers);
} else {
box(group, [0.22, 0.12, 0.33], [-0.15, 0.07, 0.07], 0x26313a);
box(group, [0.22, 0.12, 0.33], [0.15, 0.07, 0.07], 0x26313a);
}
const armL = new THREE.Group();
const armR = new THREE.Group();
armL.position.set(-0.35, bodyY + 0.18, 0);
armR.position.set(0.35, bodyY + 0.18, 0);
box(armL, [0.16, 0.48, 0.18], [0, -0.21, 0], shirt);
box(armR, [0.16, 0.48, 0.18], [0, -0.21, 0], shirt);
box(armL, [0.17, 0.15, 0.18], [0, -0.48, 0], skin);
box(armR, [0.17, 0.15, 0.18], [0, -0.48, 0], skin);
group.add(armL, armR);
group.userData.armL = armL;
group.userData.armR = armR;
group.userData.head = group.children.find((child) =>
child.geometry === unitBox && child.position.y === headY
);
group.userData.bodyY = bodyY;
group.userData.headY = headY;
group.userData.seated = seated;
group.userData.phase = config.phase ?? Math.random() * Math.PI * 2;
group.scale.setScalar(scale);
group.position.set(config.x ?? 0, config.y ?? 0, config.z ?? 0);
group.rotation.y = config.rotationY ?? 0;
return group;
}
// ---------------------------------------------------------------
// Ground, street and listening plaza
// ---------------------------------------------------------------
box(world, [42, 0.2, 36], [0, -0.12, -2], palette.ground, {
receive: true,
cast: false
});
box(world, [36, 0.08, 3.2], [0, 0.005, -10.3], palette.asphalt, {
cast: false
});
box(world, [36, 0.16, 1.05], [0, 0.02, -8.35], 0xc8c4b8, {
cast: false
});
for (let x = -16; x <= 16; x += 3) {
box(world, [1.25, 0.018, 0.09], [x, 0.06, -10.3], 0xf1dca1, {
cast: false
});
}
const plaza = cylinder(
world,
5.25,
5.25,
0.08,
[0, 0.025, 2.45],
0xeadfbe,
{ segments: 48, cast: false }
);
plaza.receiveShadow = true;
for (let i = 0; i < 40; i++) {
const angle = (i / 40) * Math.PI * 2;
const radius = 4.75;
const paver = box(
world,
[0.55, 0.035, 0.92],
[Math.sin(angle) * radius, 0.09, 2.45 + Math.cos(angle) * radius],
i % 5 === 0 ? 0xf3c969 : 0xf0e5cc,
{ cast: false }
);
paver.rotation.y = -angle;
}
addText(
labelGroup,
"OPEN LISTENING",
5.3,
0.74,
[0, 0.105, 6.1],
[-Math.PI / 2, 0, 0],
{
color: "#6f756f",
fontSize: 66,
weight: 700
}
);
addText(
labelGroup,
"COME CLOSER • STAY A WHILE",
4.4,
0.35,
[0, 0.108, 6.67],
[-Math.PI / 2, 0, 0],
{
color: "#92968e",
fontSize: 34,
weight: 700
}
);
function makeBench(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
box(group, [2.2, 0.14, 0.54], [0, 0.48, 0], palette.wood);
box(group, [2.2, 0.48, 0.12], [0, 0.78, -0.25], palette.woodLight);
box(group, [0.14, 0.48, 0.14], [-0.82, 0.24, 0], palette.ink);
box(group, [0.14, 0.48, 0.14], [0.82, 0.24, 0], palette.ink);
world.add(group);
}
makeBench(-7.2, 3.5, Math.PI / 2);
makeBench(7.2, 3.5, -Math.PI / 2);
makeBench(-6.8, 7.1, 0);
makeBench(6.8, 7.1, 0);
// ---------------------------------------------------------------
// Street façades
// ---------------------------------------------------------------
const windowMaterial = getMaterial(0xffe5a4, {
emissive: 0xffbd57,
emissiveIntensity: 0.12,
roughness: 0.45,
unique: true
});
const bulbMaterial = getMaterial(0xffdf8a, {
emissive: 0xffb545,
emissiveIntensity: 0.4,
roughness: 0.35,
unique: true
});
const buildingColors = [
0xd58470,
0xe2b967,
0x72a59a,
0x7795bb,
0xb88b73,
0x9a8fb7
];
function makeBuilding(x, width, height, color, index) {
const group = new THREE.Group();
group.position.set(x, 0, -14.45);
box(group, [width, height, 4.3], [0, height / 2, 0], color);
box(group, [width + 0.22, 0.22, 4.5], [0, height + 0.08, 0], palette.cream);
box(group, [width + 0.15, 0.35, 4.35], [0, 0.17, 0], 0x687176);
box(group, [width * 0.76, 0.12, 0.8], [0, 2.48, 2.45], palette.cream);
const rows = Math.max(2, Math.floor((height - 1) / 1.55));
const columns = Math.max(2, Math.floor(width / 1.1));
for (let row = 0; row < rows; row++) {
for (let column = 0; column < columns; column++) {
const wx =
-width / 2 + (width / columns) * (column + 0.5);
const wy = 3.05 + row * 1.48;
box(
group,
[0.63, 0.72, 0.055],
[wx, wy, 2.18],
0x000000,
{ material: windowMaterial, cast: false }
);
box(
group,
[0.72, 0.08, 0.09],
[wx, wy - 0.4, 2.22],
palette.cream,
{ cast: false }
);
}
}
const awningColor = buildingColors[(index + 2) % buildingColors.length];
box(group, [width * 0.7, 0.13, 0.78], [0, 2.12, 2.45], awningColor);
addText(
labelGroup,
["TINY GOODS", "NIGHT MARKET", "RECORDS", "BAKERY", "CORNER FM", "PLANTS"][index % 6],
width * 0.7,
0.43,
[x, 1.72, -12.24],
[0, 0, 0],
{
color: "#24313a",
background: "#f6edda",
fontSize: 58
}
);
world.add(group);
}
const buildingData = [
[-12.2, 4.3, 7.2],
[-7.4, 4.6, 8.4],
[-2.3, 4.5, 6.7],
[2.8, 4.6, 8.1],
[7.8, 4.5, 6.9],
[12.5, 4.3, 7.8]
];
buildingData.forEach((entry, index) => {
makeBuilding(
entry[0],
entry[1],
entry[2],
buildingColors[index % buildingColors.length],
index
);
});
// ---------------------------------------------------------------
// Trees, lamps and string lights
// ---------------------------------------------------------------
function makeTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.scale.setScalar(scale);
box(group, [0.46, 2.2, 0.46], [0, 1.1, 0], 0x8a654b);
box(group, [2.1, 1.4, 1.75], [0, 2.7, 0], 0x5d9672);
box(group, [1.45, 1.05, 1.45], [-0.5, 3.45, 0.12], 0x76aa7f);
box(group, [1.25, 1.2, 1.3], [0.72, 3.55, -0.12], 0x4e8667);
box(group, [1.8, 0.45, 1.8], [0, 0.22, 0], 0xb1a68f);
box(group, [1.5, 0.08, 1.5], [0, 0.48, 0], 0x6c5947);
world.add(group);
}
makeTree(-10.4, 1.8, 1.1);
makeTree(10.4, 1.5, 1.0);
makeTree(-10.2, 8.3, 0.88);
makeTree(10.1, 8.1, 0.95);
function makeLamp(x, z) {
const group = new THREE.Group();
group.position.set(x, 0, z);
box(group, [0.14, 3.8, 0.14], [0, 1.9, 0], palette.ink);
box(group, [0.75, 0.12, 0.75], [0, 0.06, 0], palette.ink);
box(group, [0.65, 0.16, 0.65], [0, 3.75, 0], palette.ink);
box(group, [0.42, 0.36, 0.42], [0, 3.56, 0], 0xffe2a0, {
material: bulbMaterial,
cast: false
});
const light = new THREE.PointLight(0xffc779, 0, 9, 2);
light.position.set(0, 3.42, 0);
group.add(light);
lampLights.push(light);
lampBulbs.push(bulbMaterial);
world.add(group);
}
makeLamp(-8.7, -1.1);
makeLamp(8.7, -1.1);
makeLamp(-8.7, 6.3);
makeLamp(8.7, 6.3);
box(world, [0.15, 4.2, 0.15], [-9.25, 2.1, -6.6], palette.ink);
box(world, [0.15, 4.2, 0.15], [9.25, 2.1, -6.6], palette.ink);
const stringPoints = [];
for (let i = 0; i <= 40; i++) {
const x = -9.2 + (18.4 * i) / 40;
const y = 4.15 - 0.58 * (1 - Math.pow(x / 9.2, 2));
stringPoints.push(new THREE.Vector3(x, y, -6.6));
if (i % 2 === 0) {
box(world, [0.12, 0.18, 0.12], [x, y - 0.15, -6.6], 0xffe3a2, {
material: bulbMaterial,
cast: false
});
}
}
const stringGeometry = new THREE.BufferGeometry().setFromPoints(stringPoints);
const stringLine = new THREE.Line(
stringGeometry,
new THREE.LineBasicMaterial({ color: 0x39454b })
);
world.add(stringLine);
// ---------------------------------------------------------------
// Separate performance zones
// ---------------------------------------------------------------
function makeZone(x, z, color, number, name, subtitle) {
const group = new THREE.Group();
group.position.set(x, 0, z);
const platformMaterial = getMaterial(color, {
roughness: 0.68,
emissive: color,
emissiveIntensity: 0.09,
unique: true
});
zoneMaterials.push(platformMaterial);
box(group, [4.35, 0.32, 3.45], [0, 0.16, 0], color, {
material: platformMaterial
});
box(group, [4.12, 0.035, 3.22], [0, 0.34, 0], 0xfff8e9, {
roughness: 0.92
});
box(group, [4.0, 0.08, 0.08], [0, 0.23, 1.72], color);
box(group, [0.08, 1.75, 0.08], [-1.2, 1.35, -1.46], palette.ink);
box(group, [0.08, 1.75, 0.08], [1.2, 1.35, -1.46], palette.ink);
addText(
labelGroup,
`${number} ${name}`,
2.3,
0.38,
[x, 2.3, z - 1.4],
[0, 0, 0],
{
color: "#ffffff",
background: `#${new THREE.Color(color).getHexString()}`,
fontSize: 61
}
);
addText(
labelGroup,
subtitle,
2.1,
0.24,
[x, 0.365, z + 1.18],
[-Math.PI / 2, 0, 0],
{
color: "#72766f",
fontSize: 35,
weight: 700
}
);
world.add(group);
return group;
}
makeZone(-5.55, -4.65, palette.coral, "01", "PULSE", "PERCUSSION / RHYTHM");
makeZone(0, -5.25, palette.teal, "02", "CHIME", "MALLETS / HARMONY");
makeZone(5.55, -4.65, palette.violet, "03", "SIGNAL", "SYNTH / TEXTURE");
// ---------------------------------------------------------------
// Zone 01: geometric drum kit
// ---------------------------------------------------------------
const pulseInstrument = new THREE.Group();
pulseInstrument.position.set(-5.55, 0, -4.05);
const kick = cylinder(
pulseInstrument,
0.56,
0.56,
0.5,
[0, 0.83, 0],
0xe85f52,
{ segments: 20 }
);
kick.rotation.x = Math.PI / 2;
const kickFace = cylinder(
pulseInstrument,
0.47,
0.47,
0.025,
[0, 0.83, 0.27],
0xf6e5c9,
{ segments: 20 }
);
kickFace.rotation.x = Math.PI / 2;
cylinder(
pulseInstrument,
0.42,
0.42,
0.33,
[0.62, 1.28, -0.04],
0xf2a149,
{ segments: 16 }
);
cylinder(
pulseInstrument,
0.34,
0.34,
0.27,
[-0.58, 1.22, -0.05],
0xf2c85b,
{ segments: 16 }
);
for (const x of [-0.62, 0.62]) {
cylinder(
pulseInstrument,
0.035,
0.045,
1.65,
[x, 1.14, -0.2],
palette.ink,
{ segments: 8 }
);
}
cylinder(
pulseInstrument,
0.5,
0.5,
0.035,
[-0.85, 1.93, -0.2],
0xe5ad49,
{ metalness: 0.35 }
);
cylinder(
pulseInstrument,
0.42,
0.42,
0.035,
[0.86, 1.77, -0.18],
0xe5ad49,
{ metalness: 0.35 }
);
box(pulseInstrument, [0.65, 0.1, 0.55], [0.72, 0.48, 0.08], palette.ink);
world.add(pulseInstrument);
const pulsePlayer = makeVoxelPerson({
x: -5.55,
z: -5.47,
shirt: palette.coral,
trousers: 0x39404b,
hair: 0x28282b,
hat: palette.cream,
scale: 0.94
});
world.add(pulsePlayer);
musicians.push({ type: "pulse", group: pulsePlayer, phase: 0 });
// ---------------------------------------------------------------
// Zone 02: voxel marimba
// ---------------------------------------------------------------
const chimeInstrument = new THREE.Group();
chimeInstrument.position.set(0, 0, -4.75);
box(chimeInstrument, [3.05, 0.17, 0.78], [0, 1.2, 0], palette.wood);
box(chimeInstrument, [3.08, 0.08, 0.18], [0, 1.31, -0.28], palette.woodLight);
for (let i = 0; i < 10; i++) {
const barHeight = 0.08 + (i % 3) * 0.025;
const colors = [0xf06d5f, 0xf3c969, 0x18a999, 0x8165d8];
box(
chimeInstrument,
[0.23, barHeight, 0.58],
[-1.22 + i * 0.27, 1.37 + barHeight / 2, 0],
colors[i % colors.length]
);
}
for (const x of [-1.25, 1.25]) {
box(chimeInstrument, [0.12, 1.05, 0.12], [x, 0.65, 0], palette.ink);
box(chimeInstrument, [0.12, 0.12, 0.7], [x, 1.1, 0], palette.ink);
}
for (let i = 0; i < 2; i++) {
const mallet = new THREE.Group();
cylinder(mallet, 0.025, 0.025, 0.58, [0, 0, 0], palette.woodLight, {
segments: 8
});
sphere(mallet, 0.085, [0, 0.32, 0], palette.cream);
mallet.position.set(i === 0 ? -0.65 : 0.65, 1.95, 0.15);
chimeInstrument.add(mallet);
mallets.push({ mesh: mallet, side: i });
}
world.add(chimeInstrument);
const chimePlayer = makeVoxelPerson({
x: 0,
z: -6.03,
shirt: palette.teal,
trousers: 0x3f4550,
hair: 0x6e4636,
scale: 0.95
});
world.add(chimePlayer);
musicians.push({ type: "chime", group: chimePlayer, phase: 1.8 });
// ---------------------------------------------------------------
// Zone 03: synthesizer and speakers
// ---------------------------------------------------------------
const signalInstrument = new THREE.Group();
signalInstrument.position.set(5.55, 0, -4.05);
box(signalInstrument, [2.2, 0.7, 1.0], [0, 0.68, 0], palette.violet);
const consoleTop = box(
signalInstrument,
[2.3, 0.16, 1.15],
[0, 1.26, 0],
0x303844
);
consoleTop.rotation.x = -0.08;
for (let i = 0; i < 12; i++) {
box(
signalInstrument,
[0.145, 0.06, 0.48],
[-0.94 + i * 0.17, 1.36, 0.22],
i % 3 === 0 ? 0x343b45 : 0xf6f0dc
);
}
for (let i = 0; i < 6; i++) {
const knob = cylinder(
signalInstrument,
0.055,
0.055,
0.06,
[-0.78 + i * 0.31, 1.39, -0.27],
[palette.coral, palette.yellow, palette.teal][i % 3],
{ segments: 10 }
);
knob.rotation.x = Math.PI / 2;
}
for (const x of [-1.48, 1.48]) {
box(signalInstrument, [0.72, 1.36, 0.72], [x, 0.75, -0.06], 0x2e3540);
cylinder(
signalInstrument,
0.25,
0.25,
0.035,
[x, 0.88, 0.32],
0x171d24,
{ segments: 18 }
);
cylinder(
signalInstrument,
0.13,
0.13,
0.04,
[x, 0.42, 0.32],
0x171d24,
{ segments: 16 }
);
}
world.add(signalInstrument);
const signalPlayer = makeVoxelPerson({
x: 5.55,
z: -5.46,
shirt: palette.violet,
trousers: 0x263641,
hair: 0x22262a,
hat: 0xf3c969,
scale: 0.96
});
world.add(signalPlayer);
musicians.push({ type: "signal", group: signalPlayer, phase: 3.5 });
// ---------------------------------------------------------------
// Audience around, but not inside, the listening space
// ---------------------------------------------------------------
const audienceColors = [
0xe06f62,
0x4f9c92,
0x7866b8,
0xe8b653,
0x568caf,
0xd88954
];
let seed = 19;
function random() {
seed = (seed * 9301 + 49297) % 233280;
return seed / 233280;
}
for (let i = 0; i < 23; i++) {
const angle = -0.9 + random() * 1.8;
const radius = 3.7 + random() * 3.15;
const x = Math.sin(angle) * radius;
const z = 2.45 + Math.cos(angle) * radius;
const seated = i % 3 === 0;
const person = makeVoxelPerson({
x,
z,
y: seated ? 0.12 : 0,
shirt: audienceColors[i % audienceColors.length],
trousers: i % 2 ? 0x35424d : 0x59626b,
hair: [0x2d2927, 0x704735, 0xb58b62, 0x3f3430][i % 4],
seated,
scale: 0.69 + random() * 0.08,
phase: random() * Math.PI * 2
});
const lookX = -x;
const lookZ = -(z + 5.3);
person.rotation.y = Math.atan2(lookX, lookZ);
person.userData.baseY = person.position.y;
audience.push(person);
world.add(person);
}
// ---------------------------------------------------------------
// Floating geometric notes
// ---------------------------------------------------------------
const noteTexture = (() => {
const canvas = document.createElement("canvas");
canvas.width = 128;
canvas.height = 128;
const context = canvas.getContext("2d");
context.clearRect(0, 0, 128, 128);
context.font = "900 94px Arial, sans-serif";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillStyle = "#ffffff";
context.fillText("♪", 64, 61);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
})();
const notes = [];
const noteZones = [
{ x: -5.55, z: -4.8, color: palette.coral },
{ x: 0, z: -5.3, color: palette.teal },
{ x: 5.55, z: -4.8, color: palette.violet }
];
for (let i = 0; i < 18; i++) {
const zone = noteZones[i % 3];
const material = new THREE.SpriteMaterial({
map: noteTexture,
color: zone.color,
transparent: true,
opacity: 0.88,
depthWrite: false,
toneMapped: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(0.32, 0.32, 0.32);
sprite.userData = {
zone,
phase: i * 0.73,
offset: (i % 5) * 0.16
};
notes.push(sprite);
noteGroup.add(sprite);
}
// ---------------------------------------------------------------
// Custom camera controls
// ---------------------------------------------------------------
const cameraGoal = {
yaw: 0.46,
pitch: 0.42,
radius: 27,
target: new THREE.Vector3(0, 1, -2)
};
const cameraCurrent = {
yaw: cameraGoal.yaw,
pitch: cameraGoal.pitch,
radius: cameraGoal.radius,
target: cameraGoal.target.clone()
};
const canvas = renderer.domElement;
const pointers = new Map();
let dragMode = null;
let lastPointer = { x: 0, y: 0 };
let previousPinchDistance = 0;
const views = {
overview: {
yaw: 0.46,
pitch: 0.42,
radius: 27,
target: new THREE.Vector3(0, 1, -2)
},
performers: {
yaw: 0.32,
pitch: 0.34,
radius: 16.5,
target: new THREE.Vector3(0, 1.2, -4.8)
},
audience: {
yaw: 0.68,
pitch: 0.53,
radius: 16.5,
target: new THREE.Vector3(0, 0.8, 2.1)
}
};
function setView(name) {
const view = views[name];
if (!view) return;
cameraGoal.yaw = view.yaw;
cameraGoal.pitch = view.pitch;
cameraGoal.radius = view.radius;
cameraGoal.target.copy(view.target);
document.querySelectorAll("[data-view]").forEach((button) => {
button.classList.toggle("active", button.dataset.view === name);
});
}
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 1) {
dragMode = event.button === 2 || event.shiftKey ? "pan" : "orbit";
lastPointer = { x: event.clientX, y: event.clientY };
} else if (pointers.size === 2) {
dragMode = "pinch";
const [a, b] = [...pointers.values()];
previousPinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
canvas.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size >= 2) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
if (previousPinchDistance > 0 && distance > 0) {
cameraGoal.radius = THREE.MathUtils.clamp(
cameraGoal.radius * (previousPinchDistance / distance),
9,
44
);
}
previousPinchDistance = distance;
return;
}
const dx = event.clientX - lastPointer.x;
const dy = event.clientY - lastPointer.y;
lastPointer = { x: event.clientX, y: event.clientY };
if (dragMode === "orbit") {
cameraGoal.yaw -= dx * 0.005;
cameraGoal.pitch = THREE.MathUtils.clamp(
cameraGoal.pitch + dy * 0.004,
0.12,
1.22
);
} else if (dragMode === "pan") {
const right = new THREE.Vector3(1, 0, 0).applyQuaternion(
camera.quaternion
);
const up = new THREE.Vector3(0, 1, 0).applyQuaternion(
camera.quaternion
);
const scale = cameraCurrent.radius * 0.00125;
cameraGoal.target
.addScaledVector(right, -dx * scale)
.addScaledVector(up, dy * scale);
cameraGoal.target.x = THREE.MathUtils.clamp(
cameraGoal.target.x,
-12,
12
);
cameraGoal.target.y = THREE.MathUtils.clamp(
cameraGoal.target.y,
0,
7
);
cameraGoal.target.z = THREE.MathUtils.clamp(
cameraGoal.target.z,
-10,
10
);
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
if (pointers.size === 1) {
const remaining = [...pointers.values()][0];
lastPointer = { x: remaining.x, y: remaining.y };
dragMode = "orbit";
} else if (pointers.size === 0) {
dragMode = null;
previousPinchDistance = 0;
}
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraGoal.radius = THREE.MathUtils.clamp(
cameraGoal.radius * Math.exp(event.deltaY * 0.001),
9,
44
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", () => setView("overview"));
// ---------------------------------------------------------------
// UI, lighting mode and labels
// ---------------------------------------------------------------
let isNight = false;
function setNight(enabled) {
isNight = enabled;
scene.background.set(enabled ? 0x111a2b : 0xdde8e4);
scene.fog.color.set(enabled ? 0x111a2b : 0xdde8e4);
hemiLight.intensity = enabled ? 0.65 : 2.2;
hemiLight.color.set(enabled ? 0x7186ba : 0xeaf8ff);
hemiLight.groundColor.set(enabled ? 0x25212c : 0x867967);
sun.intensity = enabled ? 0.55 : 3.4;
sun.color.set(enabled ? 0x8fa8df : 0xfff2d7);
windowMaterial.emissiveIntensity = enabled ? 2.2 : 0.12;
bulbMaterial.emissiveIntensity = enabled ? 3.2 : 0.4;
lampLights.forEach((light) => {
light.intensity = enabled ? 24 : 0;
});
renderer.toneMappingExposure = enabled ? 1.18 : 1.08;
const button = document.getElementById("night-button");
button.textContent = enabled ? "04 · Daylight" : "04 · Night lights";
button.classList.toggle("active", enabled);
}
document.getElementById("night-button").addEventListener("click", () => {
setNight(!isNight);
});
const labelsButton = document.getElementById("labels-button");
labelsButton.addEventListener("click", () => {
labelGroup.visible = !labelGroup.visible;
labelsButton.classList.toggle("active", labelGroup.visible);
labelsButton.textContent = labelGroup.visible
? "05 · Labels on"
: "05 · Labels off";
});
document.querySelectorAll("[data-view]").forEach((button) => {
button.addEventListener("click", () => setView(button.dataset.view));
});
window.addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "r") setView("overview");
if (event.key === "1") setView("overview");
if (event.key === "2") setView("performers");
if (event.key === "3") setView("audience");
if (event.key.toLowerCase() === "n") setNight(!isNight);
if (event.key.toLowerCase() === "l") labelsButton.click();
});
// ---------------------------------------------------------------
// Optional synthesized ensemble audio
// ---------------------------------------------------------------
let audioContext = null;
let masterGain = null;
let audioTimer = null;
let audioStep = 0;
let noiseBuffer = null;
let audioEnabled = false;
const soundButton = document.getElementById("sound-button");
const performanceStatus = document.getElementById("performance-status");
function midiToFrequency(midi) {
return 440 * Math.pow(2, (midi - 69) / 12);
}
function ensureAudio() {
if (audioContext) return;
audioContext = new (window.AudioContext || window.webkitAudioContext)();
masterGain = audioContext.createGain();
masterGain.gain.value = 0;
masterGain.connect(audioContext.destination);
noiseBuffer = audioContext.createBuffer(
1,
audioContext.sampleRate * 0.3,
audioContext.sampleRate
);
const data = noiseBuffer.getChannelData(0);
for (let i = 0; i < data.length; i++) {
data[i] = Math.random() * 2 - 1;
}
}
function triggerTone(midi, time, duration, type, volume) {
const oscillator = audioContext.createOscillator();
const gain = audioContext.createGain();
oscillator.type = type;
oscillator.frequency.setValueAtTime(midiToFrequency(midi), time);
gain.gain.setValueAtTime(0.0001, time);
gain.gain.exponentialRampToValueAtTime(
volume,
time + 0.012
);
gain.gain.exponentialRampToValueAtTime(
0.0001,
time + duration
);
oscillator.connect(gain);
gain.connect(masterGain);
oscillator.start(time);
oscillator.stop(time + duration + 0.03);
}
function triggerKick(time) {
const oscillator = audioContext.createOscillator();
const gain = audioContext.createGain();
oscillator.type = "sine";
oscillator.frequency.setValueAtTime(135, time);
oscillator.frequency.exponentialRampToValueAtTime(47, time + 0.14);
gain.gain.setValueAtTime(0.16, time);
gain.gain.exponentialRampToValueAtTime(0.0001, time + 0.22);
oscillator.connect(gain);
gain.connect(masterGain);
oscillator.start(time);
oscillator.stop(time + 0.24);
}
function triggerNoise(time, volume, frequency) {
const source = audioContext.createBufferSource();
const filter = audioContext.createBiquadFilter();
const gain = audioContext.createGain();
source.buffer = noiseBuffer;
filter.type = "highpass";
filter.frequency.value = frequency;
gain.gain.setValueAtTime(volume, time);
gain.gain.exponentialRampToValueAtTime(0.0001, time + 0.12);
source.connect(filter);
filter.connect(gain);
gain.connect(masterGain);
source.start(time);
source.stop(time + 0.14);
}
function scheduleBeat() {
if (!audioContext || !audioEnabled) return;
const now = audioContext.currentTime + 0.025;
const roots = [48, 45, 41, 43];
const chords = [
[0, 4, 7, 11],
[0, 3, 7, 10],
[0, 4, 7, 11],
[0, 4, 7, 10]
];
const chordIndex = Math.floor(audioStep / 4) % roots.length;
const root = roots[chordIndex];
const chord = chords[chordIndex];
const note = chord[audioStep % chord.length];
triggerTone(root + 12 + note, now, 0.5, "triangle", 0.042);
triggerTone(root + 24 + note, now, 0.28, "sine", 0.016);
if (audioStep % 4 === 0) {
triggerTone(root, now, 0.7, "sine", 0.055);
}
if ([0, 6, 8, 14].includes(audioStep % 16)) {
triggerKick(now);
}
if (audioStep % 8 === 4) {
triggerNoise(now, 0.055, 1100);
}
if (audioStep % 2 === 1) {
triggerNoise(now, 0.013, 4200);
}
audioStep++;
}
soundButton.addEventListener("click", async () => {
ensureAudio();
if (!audioEnabled) {
await audioContext.resume();
audioEnabled = true;
masterGain.gain.cancelScheduledValues(audioContext.currentTime);
masterGain.gain.setTargetAtTime(0.72, audioContext.currentTime, 0.08);
scheduleBeat();
audioTimer = window.setInterval(scheduleBeat, 420);
soundButton.textContent = "06 · Audio playing";
soundButton.classList.add("active");
performanceStatus.textContent = "Side Street Sessions · Live Audio";
} else {
audioEnabled = false;
window.clearInterval(audioTimer);
audioTimer = null;
masterGain.gain.cancelScheduledValues(audioContext.currentTime);
masterGain.gain.setTargetAtTime(0, audioContext.currentTime, 0.08);
soundButton.textContent = "06 · Start audio";
soundButton.classList.remove("active");
performanceStatus.textContent = "Side Street Sessions · Visual Set";
}
});
// ---------------------------------------------------------------
// Resize and render loop
// ---------------------------------------------------------------
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75));
renderer.setSize(width, height, false);
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const time = clock.elapsedTime;
const smoothing = 1 - Math.exp(-delta * 8);
cameraCurrent.yaw = THREE.MathUtils.lerp(
cameraCurrent.yaw,
cameraGoal.yaw,
smoothing
);
cameraCurrent.pitch = THREE.MathUtils.lerp(
cameraCurrent.pitch,
cameraGoal.pitch,
smoothing
);
cameraCurrent.radius = THREE.MathUtils.lerp(
cameraCurrent.radius,
cameraGoal.radius,
smoothing
);
cameraCurrent.target.lerp(cameraGoal.target, smoothing);
const horizontalRadius =
cameraCurrent.radius * Math.sin(cameraCurrent.pitch);
camera.position.set(
cameraCurrent.target.x +
horizontalRadius * Math.sin(cameraCurrent.yaw),
cameraCurrent.target.y +
cameraCurrent.radius * Math.cos(cameraCurrent.pitch),
cameraCurrent.target.z +
horizontalRadius * Math.cos(cameraCurrent.yaw)
);
camera.lookAt(cameraCurrent.target);
zoneMaterials.forEach((material, index) => {
material.emissiveIntensity =
0.08 + (Math.sin(time * 2.4 + index * 1.8) + 1) * 0.055;
});
musicians.forEach((musician, index) => {
const { group, type, phase } = musician;
const armL = group.userData.armL;
const armR = group.userData.armR;
const head = group.userData.head;
if (type === "pulse") {
const beat = Math.sin(time * 10.5 + phase);
armL.rotation.x = -1.03 + beat * 0.38;
armR.rotation.x = -1.03 - beat * 0.38;
armL.rotation.z = 0.17;
armR.rotation.z = -0.17;
} else if (type === "chime") {
armL.rotation.x = -1.03 + Math.sin(time * 5.1 + phase) * 0.22;
armR.rotation.x = -1.03 + Math.sin(time * 5.1 + phase + 1.4) * 0.22;
armL.rotation.z = 0.24;
armR.rotation.z = -0.24;
} else {
armL.rotation.x = -1.0 + Math.sin(time * 2.5 + phase) * 0.12;
armR.rotation.x = -1.0 + Math.sin(time * 2.5 + phase + 0.7) * 0.12;
armL.rotation.z = 0.2;
armR.rotation.z = -0.2;
}
if (head) {
head.position.y =
group.userData.headY + Math.sin(time * 2.1 + phase) * 0.018;
}
});
mallets.forEach((mallet, index) => {
const targetX = mallet.side === 0 ? -0.65 : 0.65;
mallet.mesh.position.x =
targetX + Math.sin(time * 5.1 + index * 1.4) * 0.18;
mallet.mesh.position.z =
0.15 + Math.cos(time * 5.1 + index * 1.4) * 0.13;
mallet.mesh.rotation.z =
Math.sin(time * 5.1 + index * 1.4) * 0.24;
});
audience.forEach((person) => {
const phase = person.userData.phase;
person.rotation.z = Math.sin(time * 0.8 + phase) * 0.012;
person.position.y =
person.userData.baseY +
Math.abs(Math.sin(time * 1.6 + phase)) * 0.015;
});
notes.forEach((note, index) => {
const data = note.userData;
const progress = (time * 0.34 + data.offset + index * 0.037) % 1;
note.position.set(
data.zone.x + Math.sin(time * 1.4 + data.phase) * 0.45,
1.65 + progress * 2.05,
data.zone.z + Math.cos(time * 1.1 + data.phase) * 0.3
);
note.material.opacity = Math.sin(progress * Math.PI) * 0.9;
note.material.rotation = Math.sin(time + data.phase) * 0.12;
});
bulbMaterial.emissiveIntensity = isNight
? 2.8 + Math.sin(time * 1.8) * 0.3
: 0.35;
renderer.render(scene, camera);
}
animate();
requestAnimationFrame(() => {
loading.classList.add("hidden");
});
</script>
</body>
</html>
```