Prompt specification
Build or customize the Three.js 3D scene "Plucked Struck and Blown Object Trio" 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: Plucked Struck and Blown Object Trio
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/plucked-struck-and-blown-object-trio-x3301
Scene Description Prompt:
Please make a low-poly Three.js scene in one standalone HTML file using cdnjs. Display three simplified instruments distinguished by excitation method and resonating body. Show the moving element of each without implying every instrument fits one rigid category.
Working Three.js Starter (plucked-struck-and-blown-object-trio-x3301):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Motion & Resonance — Low-Poly Instrument Study</title>
<style>
:root {
--ink: #282a2d;
--muted: #676a6d;
--paper: #eee8dd;
--glass: rgba(255, 255, 255, 0.82);
--strike: #e56f51;
--bow: #269b8b;
--blow: #4d7fd1;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--paper);
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#stage,
#stage canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
}
#stage canvas {
cursor: grab;
touch-action: none;
}
#stage canvas.dragging {
cursor: grabbing;
}
.wash {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 50% 42%, transparent 35%, rgba(58, 50, 40, 0.08) 100%),
linear-gradient(180deg, rgba(255, 255, 255, 0.15), transparent 35%);
}
.hero {
position: fixed;
z-index: 5;
top: 26px;
left: 30px;
max-width: 570px;
pointer-events: none;
text-shadow: 0 1px 16px rgba(255, 255, 255, 0.7);
}
.eyebrow {
margin: 0 0 8px;
color: #7e7468;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 4vw, 52px);
font-weight: 500;
letter-spacing: -0.035em;
line-height: 0.98;
}
.intro {
max-width: 500px;
margin: 12px 0 0;
color: #55585a;
font-size: 14px;
line-height: 1.55;
}
.toolbar {
position: fixed;
z-index: 8;
top: 27px;
right: 28px;
display: flex;
align-items: center;
gap: 13px;
}
.toolbar button {
border: 1px solid rgba(45, 47, 49, 0.15);
border-radius: 999px;
padding: 10px 15px;
background: var(--glass);
color: var(--ink);
cursor: pointer;
box-shadow: 0 8px 28px rgba(54, 45, 34, 0.09);
backdrop-filter: blur(12px);
transition:
transform 160ms ease,
background 160ms ease;
}
.toolbar button:hover {
transform: translateY(-2px);
background: rgba(255, 255, 255, 0.96);
}
.toolbar span {
color: #686b6c;
font-size: 11px;
letter-spacing: 0.04em;
}
#labels {
position: fixed;
z-index: 4;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.pin {
position: absolute;
display: flex;
align-items: center;
gap: 8px;
padding: 7px 10px 7px 7px;
border: 1px solid rgba(35, 37, 39, 0.12);
border-radius: 999px;
background: rgba(255, 255, 255, 0.86);
box-shadow: 0 8px 22px rgba(55, 45, 34, 0.11);
backdrop-filter: blur(10px);
transform: translate(-50%, -100%);
white-space: nowrap;
transition: opacity 120ms linear;
}
.pin::after {
position: absolute;
bottom: -16px;
left: 50%;
width: 1px;
height: 15px;
background: rgba(46, 48, 50, 0.25);
content: "";
}
.pin .number {
display: grid;
width: 24px;
height: 24px;
place-items: center;
border-radius: 50%;
background: var(--accent);
color: white;
font-size: 10px;
font-weight: 800;
}
.pin strong {
display: block;
font-size: 11px;
font-weight: 750;
}
.pin small {
display: block;
margin-top: 1px;
color: var(--muted);
font-size: 9px;
}
.legend {
position: fixed;
z-index: 7;
right: 22px;
bottom: 20px;
left: 22px;
width: min(1120px, calc(100% - 44px));
margin: auto;
}
.legend-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 4px 9px;
color: #625d56;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.cards {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 11px;
}
.card {
position: relative;
min-width: 0;
padding: 15px 16px 14px;
overflow: hidden;
border: 1px solid rgba(43, 45, 47, 0.12);
border-radius: 17px;
background: var(--glass);
color: var(--ink);
text-align: left;
cursor: pointer;
box-shadow: 0 14px 38px rgba(55, 45, 34, 0.1);
backdrop-filter: blur(16px);
transition:
transform 180ms ease,
border-color 180ms ease,
box-shadow 180ms ease;
}
.card::before {
position: absolute;
top: 0;
right: 0;
left: 0;
height: 3px;
background: var(--accent);
content: "";
}
.card:hover,
.card.active {
transform: translateY(-4px);
border-color: color-mix(in srgb, var(--accent), transparent 55%);
box-shadow: 0 18px 42px rgba(55, 45, 34, 0.15);
}
.card-top {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
}
.card-index {
display: grid;
width: 27px;
height: 27px;
flex: 0 0 auto;
place-items: center;
border-radius: 50%;
background: var(--accent);
color: white;
font-size: 10px;
font-weight: 850;
}
.card-title {
font-family: Georgia, "Times New Roman", serif;
font-size: 18px;
line-height: 1.05;
}
.card-row {
display: grid;
grid-template-columns: 73px 1fr;
gap: 8px;
margin-top: 5px;
font-size: 11px;
line-height: 1.35;
}
.card-row > span {
color: var(--muted);
}
.card-row > b {
font-weight: 650;
}
.motion {
display: flex;
align-items: center;
gap: 7px;
margin-top: 10px;
color: var(--accent);
font-size: 10px;
font-weight: 750;
}
.motion i {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 0 var(--accent);
animation: pulse 1.8s infinite;
}
@keyframes pulse {
0%, 100% {
box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent), transparent 65%);
}
50% {
box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent), transparent 100%);
}
}
.caveat {
margin: 9px 4px 0;
color: #69635b;
font-size: 10px;
line-height: 1.45;
text-align: center;
}
@media (max-width: 800px) {
.hero {
top: 18px;
left: 18px;
max-width: 72%;
}
.intro {
display: none;
}
.toolbar {
top: 17px;
right: 17px;
}
.toolbar span {
display: none;
}
.legend {
right: 12px;
bottom: 12px;
left: 12px;
width: auto;
}
.cards {
display: flex;
overflow-x: auto;
padding: 2px 1px 8px;
scroll-snap-type: x mandatory;
}
.card {
min-width: 235px;
scroll-snap-align: start;
}
.legend-heading,
.caveat {
display: none;
}
.pin {
display: none;
}
}
@media (max-width: 480px) {
h1 {
font-size: 31px;
}
.eyebrow {
font-size: 9px;
}
.toolbar button {
padding: 9px 11px;
font-size: 11px;
}
}
</style>
</head>
<body>
<div id="stage" aria-label="Interactive low-poly instrument scene"></div>
<div class="wash"></div>
<div id="labels" aria-hidden="true">
<div class="pin" id="pin-0" style="--accent: var(--strike)">
<span class="number">01</span>
<span><strong>Moving mallet</strong><small>strike → flex</small></span>
</div>
<div class="pin" id="pin-1" style="--accent: var(--bow)">
<span class="number">02</span>
<span><strong>Moving bow</strong><small>slide → vibration</small></span>
</div>
<div class="pin" id="pin-2" style="--accent: var(--blow)">
<span class="number">03</span>
<span><strong>Moving reed</strong><small>breath → air column</small></span>
</div>
</div>
<header class="hero">
<p class="eyebrow">Low-poly study · motion & resonance</p>
<h1>What moves?<br>What answers?</h1>
<p class="intro">
Three deliberately simplified instruments show an energy input and a
resonating body. The colored parts make the motion visible.
</p>
</header>
<div class="toolbar">
<span>Drag to orbit · scroll to zoom</span>
<button id="reset" type="button">Reset view</button>
</div>
<section class="legend" aria-label="Instrument explanations">
<div class="legend-heading">
<span>Follow the moving element</span>
<span>Select a card to focus</span>
</div>
<div class="cards">
<button
class="card"
type="button"
data-focus="0"
style="--accent: var(--strike)"
aria-label="Focus the struck metal-bar instrument"
>
<span class="card-top">
<span class="card-index">01</span>
<span class="card-title">Metal-bar instrument</span>
</span>
<span class="card-row"><span>Excitation</span><b>Mallet strike</b></span>
<span class="card-row"><span>Resonator</span><b>Tuned bar + tube</b></span>
<span class="motion"><i></i>Mallet descends; bar flexes</span>
</button>
<button
class="card"
type="button"
data-focus="1"
style="--accent: var(--bow)"
aria-label="Focus the bowed string instrument"
>
<span class="card-top">
<span class="card-index">02</span>
<span class="card-title">Cello-like instrument</span>
</span>
<span class="card-row"><span>Excitation</span><b>Bow friction</b></span>
<span class="card-row"><span>Resonator</span><b>String + wooden box</b></span>
<span class="motion"><i></i>Bow slides; strings oscillate</span>
</button>
<button
class="card"
type="button"
data-focus="2"
style="--accent: var(--blow)"
aria-label="Focus the reed woodwind instrument"
>
<span class="card-top">
<span class="card-index">03</span>
<span class="card-title">Reed woodwind</span>
</span>
<span class="card-row"><span>Excitation</span><b>Player breath</b></span>
<span class="card-row"><span>Resonator</span><b>Reed + enclosed air</b></span>
<span class="motion"><i></i>Reed flexes; air travels</span>
</button>
</div>
<p class="caveat">
These are emphases, not exclusive categories. Real instruments may combine
striking, bowing, blowing, plucking, and resonant-body behavior at once.
</p>
</section>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.querySelector("#stage");
// ------------------------------------------------------------
// Renderer, scene, camera, and direct camera controls
// ------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xeee8dd);
scene.fog = new THREE.Fog(0xeee8dd, 18, 36);
const camera = new THREE.PerspectiveCamera(
40,
window.innerWidth / window.innerHeight,
0.1,
80
);
const defaultRadius = () => window.innerWidth < 800 ? 30 : 13.5;
let theta = 0;
let phi = 1.18;
let radius = defaultRadius();
let desiredTheta = 0;
let desiredPhi = 1.18;
let desiredRadius = radius;
let activeFocus = null;
const currentTarget = new THREE.Vector3(0, 1.55, 0);
const desiredTarget = currentTarget.clone();
function updateCamera(dt) {
const smoothing = 1 - Math.exp(-dt * 7);
theta += (desiredTheta - theta) * smoothing;
phi += (desiredPhi - phi) * smoothing;
radius += (desiredRadius - radius) * smoothing;
currentTarget.lerp(desiredTarget, smoothing);
const sinPhi = Math.sin(phi);
camera.position.set(
currentTarget.x + radius * sinPhi * Math.sin(theta),
currentTarget.y + radius * Math.cos(phi),
currentTarget.z + radius * sinPhi * Math.cos(theta)
);
camera.lookAt(currentTarget);
}
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.classList.add("dragging");
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
desiredTheta = THREE.MathUtils.clamp(
desiredTheta - dx * 0.006,
-1.02,
1.02
);
desiredPhi = THREE.MathUtils.clamp(
desiredPhi - dy * 0.0045,
0.72,
1.46
);
});
function endDrag(event) {
dragging = false;
renderer.domElement.classList.remove("dragging");
if (event?.pointerId !== undefined) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredRadius = THREE.MathUtils.clamp(
desiredRadius * Math.exp(event.deltaY * 0.001),
5.8,
32
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
function resetView() {
activeFocus = null;
desiredTarget.set(0, 1.55, 0);
desiredTheta = 0;
desiredPhi = 1.18;
desiredRadius = defaultRadius();
document.querySelectorAll(".card").forEach((card) => {
card.classList.remove("active");
card.setAttribute("aria-pressed", "false");
});
}
document.querySelector("#reset").addEventListener("click", resetView);
// ------------------------------------------------------------
// Materials and geometry helpers
// ------------------------------------------------------------
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.72,
metalness: 0,
flatShading: true,
...options
});
function addMesh(parent, geometry, mat, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinderBetween(
parent,
start,
end,
radius,
mat,
radialSegments = 8
) {
const direction = end.clone().sub(start);
const length = direction.length();
const geometry = new THREE.CylinderGeometry(
radius,
radius,
length,
radialSegments,
1,
false
);
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// ------------------------------------------------------------
// Gallery environment and lighting
// ------------------------------------------------------------
const floorMaterial = material(0xd9d2c6, { roughness: 0.95 });
const floor = addMesh(
scene,
new THREE.PlaneGeometry(42, 42),
floorMaterial,
0,
-0.015,
0
);
floor.rotation.x = -Math.PI / 2;
floor.castShadow = false;
const wallMaterial = material(0xe3dbcf, { roughness: 0.96 });
addMesh(
scene,
new THREE.BoxGeometry(32, 11, 0.22),
wallMaterial,
0,
5.3,
-6.5
);
const panelMaterial = new THREE.MeshBasicMaterial({
color: 0xddd3c5,
side: THREE.DoubleSide
});
[-4.2, 0, 4.2].forEach((x, index) => {
const panel = addMesh(
scene,
new THREE.CircleGeometry(2.25 + index * 0.12, 12),
panelMaterial,
x,
3.7,
-6.36
);
panel.castShadow = false;
panel.receiveShadow = false;
});
const hemisphere = new THREE.HemisphereLight(0xfff8ec, 0x81766a, 1.9);
scene.add(hemisphere);
const key = new THREE.DirectionalLight(0xfff3dd, 3.4);
key.position.set(-5, 10, 8);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -12;
key.shadow.camera.right = 12;
key.shadow.camera.top = 12;
key.shadow.camera.bottom = -10;
key.shadow.bias = -0.0004;
scene.add(key);
const rim = new THREE.DirectionalLight(0xbad9ef, 1.2);
rim.position.set(7, 6, -4);
scene.add(rim);
// ------------------------------------------------------------
// Pedestals
// ------------------------------------------------------------
const instrumentX = [-4.2, 0, 4.2];
const accentColors = [0xe56f51, 0x269b8b, 0x4d7fd1];
function createPedestal(x, accent) {
const pedestal = new THREE.Group();
pedestal.position.x = x;
scene.add(pedestal);
const stone = material(0xc9c0b2, { roughness: 0.92 });
const top = material(0xf2ede4, { roughness: 0.86 });
addMesh(
pedestal,
new THREE.CylinderGeometry(1.68, 1.8, 0.32, 12),
stone,
0,
0.16,
0
);
addMesh(
pedestal,
new THREE.CylinderGeometry(1.72, 1.72, 0.12, 12),
top,
0,
0.38,
0
);
const ring = addMesh(
pedestal,
new THREE.TorusGeometry(1.52, 0.018, 4, 28),
material(accent, {
emissive: accent,
emissiveIntensity: 0.18,
roughness: 0.5
}),
0,
0.455,
0
);
ring.rotation.x = Math.PI / 2;
const glow = new THREE.PointLight(accent, 0.55, 5.5, 2);
glow.position.set(x, 1.1, 1.3);
scene.add(glow);
}
instrumentX.forEach((x, index) => createPedestal(x, accentColors[index]));
// ------------------------------------------------------------
// 01 — Struck metal bars
// ------------------------------------------------------------
function createMallets() {
const group = new THREE.Group();
const darkWood = material(0x654635, { roughness: 0.88 });
const frame = material(0x3f4548, { metalness: 0.25 });
const tubeMaterial = material(0x687074, {
metalness: 0.48,
roughness: 0.48
});
// Four legs and two rails.
[-1.02, 1.02].forEach((x) => {
[-0.92, 0.92].forEach((z) => {
cylinderBetween(
group,
new THREE.Vector3(x, 0.08, z),
new THREE.Vector3(x, 1.07, z),
0.065,
darkWood
);
});
});
[-0.92, 0.92].forEach((z) => {
addMesh(
group,
new THREE.BoxGeometry(2.25, 0.13, 0.12),
darkWood,
0,
1.01,
z
);
});
const barColors = [0xd9a441, 0xe0ad4e, 0xe9b95d, 0xe5ae4d, 0xd79a38];
const bars = [];
for (let i = 0; i < 5; i++) {
const z = -0.95 + i * 0.475;
addMesh(
group,
new THREE.CylinderGeometry(0.16, 0.2, 0.72, 8),
tubeMaterial,
0,
0.68,
z
);
const bar = addMesh(
group,
new THREE.BoxGeometry(2.7, 0.18, 0.36),
material(barColors[i], {
metalness: 0.55,
roughness: 0.36
}),
0,
1.19,
z
);
bars.push(bar);
}
addMesh(
group,
new THREE.BoxGeometry(2.12, 0.1, 0.12),
frame,
0,
0.31,
0
);
// The emphasized moving element: a coral mallet.
const mallet = new THREE.Group();
mallet.position.set(0, 1.8, 0.475);
group.add(mallet);
const malletMaterial = material(0xe56f51, {
emissive: 0x7f2415,
emissiveIntensity: 0.22,
roughness: 0.5
});
addMesh(
mallet,
new THREE.DodecahedronGeometry(0.21, 0),
malletMaterial
);
cylinderBetween(
mallet,
new THREE.Vector3(0.13, 0.07, 0),
new THREE.Vector3(0.92, 0.72, 0.12),
0.035,
material(0xc49b69, { roughness: 0.85 })
);
function update(t) {
const impact = Math.pow(Math.max(0, Math.sin(t * 3.4)), 12);
mallet.position.y = 1.8 - impact * 0.3;
mallet.rotation.z = -impact * 0.055;
bars[3].scale.y = 1 + impact * 0.15;
bars[3].scale.x = 1 - impact * 0.008;
}
return { group, update };
}
// ------------------------------------------------------------
// 02 — Bowed string and wooden soundbox
// ------------------------------------------------------------
function createBowedString() {
const group = new THREE.Group();
const wood = material(0x9a4e2d, { roughness: 0.6 });
const darkWood = material(0x392820, { roughness: 0.78 });
const bridgeMaterial = material(0xe3c28e, { roughness: 0.78 });
// Low-poly violin/cello-like body, extruded from a custom outline.
const shape = new THREE.Shape();
shape.moveTo(0, 1.25);
shape.bezierCurveTo(0.5, 1.3, 0.82, 1.02, 0.62, 0.63);
shape.bezierCurveTo(0.48, 0.4, 0.26, 0.28, 0.34, 0.04);
shape.bezierCurveTo(0.42, -0.26, 0.82, -0.66, 0.62, -1.08);
shape.bezierCurveTo(0.48, -1.38, 0.22, -1.55, 0, -1.55);
shape.bezierCurveTo(-0.22, -1.55, -0.48, -1.38, -0.62, -1.08);
shape.bezierCurveTo(-0.82, -0.66, -0.42, -0.26, -0.34, 0.04);
shape.bezierCurveTo(-0.26, 0.28, -0.48, 0.4, -0.62, 0.63);
shape.bezierCurveTo(-0.82, 1.02, -0.5, 1.3, 0, 1.25);
const bodyGeometry = new THREE.ExtrudeGeometry(shape, {
depth: 0.34,
bevelEnabled: false,
curveSegments: 5
});
const body = addMesh(group, bodyGeometry, wood, 0, 1.85, -0.17);
const bodyEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(bodyGeometry, 24),
new THREE.LineBasicMaterial({ color: 0x563020 })
);
bodyEdges.scale.setScalar(1.002);
body.add(bodyEdges);
// Neck, fingerboard, pegbox, and scroll.
addMesh(
group,
new THREE.BoxGeometry(0.31, 1.28, 0.25),
wood,
0,
3.62,
-0.01
);
addMesh(
group,
new THREE.BoxGeometry(0.23, 1.48, 0.09),
darkWood,
0,
3.5,
0.21
);
addMesh(
group,
new THREE.BoxGeometry(0.42, 0.43, 0.25),
darkWood,
0,
4.25,
0
);
const scroll = addMesh(
group,
new THREE.TorusGeometry(0.23, 0.075, 5, 10),
wood,
0,
4.53,
0.03
);
scroll.rotation.z = 0.2;
[-0.28, 0.28].forEach((x) => {
[-0.16, 0.16].forEach((y) => {
cylinderBetween(
group,
new THREE.Vector3(x * 0.45, 4.18 + y, 0.05),
new THREE.Vector3(x, 4.18 + y, 0.05),
0.035,
darkWood
);
});
});
addMesh(
group,
new THREE.BoxGeometry(0.52, 0.17, 0.1),
bridgeMaterial,
0,
2.16,
0.27
);
const tailpiece = addMesh(
group,
new THREE.BoxGeometry(0.34, 0.78, 0.1),
darkWood,
0,
1.52,
0.24
);
tailpiece.rotation.z = 0.06;
// Stylized f-holes.
const holeMaterial = new THREE.MeshBasicMaterial({ color: 0x2b211c });
function addFHole(side) {
const curve = new THREE.CatmullRomCurve3([
new THREE.Vector3(side * 0.53, 2.45, 0.205),
new THREE.Vector3(side * 0.44, 2.28, 0.21),
new THREE.Vector3(side * 0.49, 2.08, 0.21),
new THREE.Vector3(side * 0.38, 1.88, 0.21),
new THREE.Vector3(side * 0.45, 1.72, 0.21)
]);
addMesh(
group,
new THREE.TubeGeometry(curve, 8, 0.025, 4, false),
holeMaterial
);
}
addFHole(-1);
addFHole(1);
// Four animated string lines.
const stringMaterial = new THREE.LineBasicMaterial({
color: 0xf3dfb2,
transparent: true,
opacity: 0.95
});
const strings = [];
const stringBases = [-0.105, -0.035, 0.035, 0.105];
stringBases.forEach((baseX) => {
const geometry = new THREE.BufferGeometry();
const positions = new Float32Array(25 * 3);
geometry.setAttribute(
"position",
new THREE.BufferAttribute(positions, 3)
);
const line = new THREE.Line(geometry, stringMaterial);
group.add(line);
strings.push({ line, geometry, positions, baseX });
});
// The emphasized moving element: a bow sliding across the strings.
const bow = new THREE.Group();
bow.position.set(0, 2.25, 0.3);
group.add(bow);
const bowMaterial = material(0x269b8b, {
emissive: 0x0d554d,
emissiveIntensity: 0.18,
roughness: 0.48
});
cylinderBetween(
bow,
new THREE.Vector3(-1.5, 0.06, 0.03),
new THREE.Vector3(1.5, 0.06, 0.03),
0.035,
bowMaterial
);
cylinderBetween(
bow,
new THREE.Vector3(-1.43, 0, -0.03),
new THREE.Vector3(1.43, 0, -0.03),
0.009,
material(0xf1e6cf, { roughness: 0.95 })
);
addMesh(
bow,
new THREE.BoxGeometry(0.18, 0.13, 0.13),
darkWood,
1.27,
0.05,
0.015
);
function update(t) {
const slide = Math.sin(t * 2.15);
bow.position.x = slide * 0.43;
bow.position.y = 2.25 + Math.cos(t * 2.15) * 0.025;
bow.rotation.z = -0.045 + Math.sin(t * 2.15) * 0.018;
strings.forEach((string, index) => {
const amplitude = 0.022 + 0.009 * Math.sin(index * 1.7);
for (let i = 0; i < 25; i++) {
const u = i / 24;
const oscillation =
Math.sin(u * Math.PI) *
Math.sin(t * 11 + index * 0.7) *
amplitude;
const position = i * 3;
string.positions[position] = string.baseX + oscillation;
string.positions[position + 1] = 2.2 + u * 1.9;
string.positions[position + 2] = 0.285;
}
string.geometry.attributes.position.needsUpdate = true;
});
}
return { group, update };
}
// ------------------------------------------------------------
// 03 — Reed and enclosed air column
// ------------------------------------------------------------
function createReedWoodwind() {
const group = new THREE.Group();
const wood = material(0xc1874c, {
roughness: 0.6,
transparent: true,
opacity: 0.83,
depthWrite: false
});
const dark = material(0x30383d, { roughness: 0.6 });
const reedMaterial = material(0x65cbd2, {
emissive: 0x176d75,
emissiveIntensity: 0.38,
roughness: 0.5
});
addMesh(
group,
new THREE.CylinderGeometry(0.34, 0.34, 2.3, 8),
wood,
0,
1.82,
0
);
const bell = addMesh(
group,
new THREE.CylinderGeometry(0.54, 0.34, 0.82, 8, 1, true),
material(0x8e633d, {
roughness: 0.7,
side: THREE.DoubleSide
}),
0,
0.45,
0
);
bell.castShadow = false;
// Mouthpiece.
addMesh(
group,
new THREE.BoxGeometry(0.48, 0.32, 0.44),
dark,
0,
3.1,
0
);
// The emphasized moving element: a flexible reed tongue.
const reedPivot = new THREE.Group();
reedPivot.position.set(0, 3.23, 0.245);
group.add(reedPivot);
addMesh(
reedPivot,
new THREE.BoxGeometry(0.16, 0.76, 0.08),
reedMaterial,
0,
0.38,
0
);
// Stylized ligature bands.
[-0.06, 0.06].forEach((y) => {
addMesh(
group,
new THREE.BoxGeometry(0.28, 0.045, 0.3),
dark,
0,
3.22 + y,
0.09
);
});
// Tone holes.
[1.1, 1.55, 2.0, 2.45].forEach((y, index) => {
addMesh(
group,
new THREE.CylinderGeometry(0.075 - index * 0.008, 0.075 - index * 0.008, 0.035, 8),
dark,
0,
y,
0.35
).rotation.x = Math.PI / 2;
});
// Visible stylized air particles inside the bore.
const airMaterial = new THREE.MeshBasicMaterial({
color: 0x82e0e7,
transparent: true,
opacity: 0.78
});
const airParticles = [];
for (let i = 0; i < 11; i++) {
const particle = addMesh(
group,
new THREE.OctahedronGeometry(0.055, 0),
airMaterial,
0,
3,
0
);
particle.castShadow = false;
particle.receiveShadow = false;
airParticles.push(particle);
}
function update(t) {
reedPivot.rotation.z = Math.sin(t * 7.5) * 0.115;
reedPivot.rotation.x = Math.cos(t * 4.1) * 0.025;
airParticles.forEach((particle, index) => {
const progress = (t * 0.43 + index / airParticles.length) % 1;
particle.position.y = 3.04 - progress * 2.48;
particle.position.x = Math.sin(index * 2.2 + t * 2.4) * 0.095;
particle.position.z = Math.cos(index * 1.9 + t * 2) * 0.055;
const pulse = 0.82 + Math.sin(t * 5 + index) * 0.2;
particle.scale.setScalar(pulse);
});
}
return { group, update };
}
// ------------------------------------------------------------
// Assemble the three exhibits
// ------------------------------------------------------------
const mallets = createMallets();
const bowed = createBowedString();
const woodwind = createReedWoodwind();
const exhibits = [mallets, bowed, woodwind];
exhibits.forEach((exhibit, index) => {
exhibit.group.position.set(instrumentX[index], 0.47, 0);
scene.add(exhibit.group);
});
// ------------------------------------------------------------
// Projected labels and card focus controls
// ------------------------------------------------------------
const pinAnchors = [
new THREE.Vector3(0, 2.95, 0),
new THREE.Vector3(0, 4.48, 0),
new THREE.Vector3(0, 4.12, 0)
];
const pins = [
document.querySelector("#pin-0"),
document.querySelector("#pin-1"),
document.querySelector("#pin-2")
];
const cards = [...document.querySelectorAll(".card")];
cards.forEach((card) => {
card.setAttribute("aria-pressed", "false");
card.addEventListener("click", () => {
const index = Number(card.dataset.focus);
activeFocus = index;
desiredTarget.set(instrumentX[index], 1.9, 0);
desiredRadius = 7.7;
desiredTheta = 0;
desiredPhi = 1.17;
cards.forEach((item) => {
const selected = item === card;
item.classList.toggle("active", selected);
item.setAttribute("aria-pressed", String(selected));
});
});
});
const projected = new THREE.Vector3();
function updatePins() {
const width = window.innerWidth;
const height = window.innerHeight;
exhibits.forEach((exhibit, index) => {
projected.copy(pinAnchors[index]);
exhibit.group.localToWorld(projected);
projected.project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.15 &&
Math.abs(projected.y) < 1.15;
pins[index].style.opacity = visible ? "1" : "0";
pins[index].style.left = `${(projected.x * 0.5 + 0.5) * width}px`;
pins[index].style.top = `${(-projected.y * 0.5 + 0.5) * height}px`;
});
}
// ------------------------------------------------------------
// Resize and animation loop
// ------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
if (activeFocus === null) {
desiredRadius = defaultRadius();
}
});
const clock = new THREE.Clock();
let elapsed = 0;
renderer.setAnimationLoop(() => {
const dt = Math.min(clock.getDelta(), 0.05);
elapsed += dt;
updateCamera(dt);
mallets.update(elapsed);
bowed.update(elapsed);
woodwind.update(elapsed);
scene.updateMatrixWorld(true);
updatePins();
renderer.render(scene, camera);
});
</script>
</body>
</html>
```