Prompt specification
Build or customize the Three.js 3D scene "String instrument resonance exhibit" 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: String instrument resonance exhibit
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/string-instrument-resonance-exhibit-x1587
Scene Description Prompt:
Make a voxel monochord with a movable finger stop and harmonic modes illustrating ideal frequency versus string length. One HTML file using Three.js from cdnjs.
Working Three.js Starter (string-instrument-resonance-exhibit-x1587):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Monochord — Harmonic Length Laboratory</title>
<style>
:root {
--bg: #080d14;
--panel: #101722;
--panel-2: #151e2a;
--line: #263140;
--text: #f2eee5;
--muted: #8995a5;
--orange: #ff7454;
--orange-soft: rgba(255, 116, 84, 0.14);
--cyan: #78e4d5;
--cyan-soft: rgba(120, 228, 213, 0.12);
--yellow: #ffd166;
--radius: 20px;
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
min-height: 100%;
background: var(--bg);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
overflow: hidden;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
.app {
display: grid;
grid-template-rows: 72px minmax(0, 1fr);
height: 100dvh;
}
.topbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
padding: 0 22px;
border-bottom: 1px solid var(--line);
background: rgba(8, 13, 20, 0.96);
z-index: 10;
}
.brand {
display: flex;
align-items: center;
gap: 13px;
min-width: 0;
}
.brand-mark {
position: relative;
width: 34px;
height: 34px;
flex: 0 0 auto;
}
.brand-mark i {
position: absolute;
display: block;
width: 9px;
height: 9px;
background: var(--orange);
box-shadow: 0 0 18px rgba(255, 116, 84, 0.35);
}
.brand-mark i:nth-child(1) { left: 0; top: 12px; }
.brand-mark i:nth-child(2) { left: 12px; top: 0; }
.brand-mark i:nth-child(3) { left: 24px; top: 12px; }
.brand-mark i:nth-child(4) { left: 12px; top: 24px; }
.brand-mark i:nth-child(5) { left: 12px; top: 12px; background: var(--cyan); }
.brand-copy {
display: flex;
align-items: baseline;
gap: 12px;
min-width: 0;
}
.brand-name {
font-weight: 850;
font-size: 15px;
letter-spacing: 0.13em;
white-space: nowrap;
}
.brand-subtitle {
color: var(--muted);
font-size: 12px;
white-space: nowrap;
}
.top-meta {
margin-left: auto;
color: var(--muted);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.top-actions {
display: flex;
align-items: center;
gap: 8px;
}
.icon-button,
.audio-button {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 9px;
min-height: 38px;
border: 1px solid var(--line);
border-radius: 11px;
background: #111923;
cursor: pointer;
transition:
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
.icon-button {
width: 40px;
font-size: 18px;
}
.audio-button {
padding: 0 14px;
font-size: 12px;
font-weight: 750;
letter-spacing: 0.04em;
}
.icon-button:hover,
.audio-button:hover {
border-color: #455468;
background: #17212d;
transform: translateY(-1px);
}
.audio-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #566170;
box-shadow: 0 0 0 4px rgba(86, 97, 112, 0.08);
}
.audio-button.is-playing {
border-color: rgba(255, 116, 84, 0.6);
background: var(--orange-soft);
}
.audio-button.is-playing .audio-dot {
background: var(--orange);
box-shadow: 0 0 0 4px rgba(255, 116, 84, 0.12), 0 0 14px var(--orange);
}
.layout {
display: grid;
grid-template-columns: minmax(0, 1fr) 370px;
gap: 14px;
min-height: 0;
padding: 14px;
}
.stage {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
border: 1px solid var(--line);
border-radius: var(--radius);
background: #0b111b;
isolation: isolate;
}
#viewport {
position: absolute;
inset: 0;
}
#viewport canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
}
.stage-copy {
position: absolute;
top: 24px;
left: 26px;
z-index: 2;
max-width: 380px;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
color: var(--cyan);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 22px;
height: 1px;
background: currentColor;
}
.stage h1 {
margin: 11px 0 8px;
max-width: 350px;
font-size: clamp(28px, 3.2vw, 45px);
line-height: 0.98;
letter-spacing: -0.055em;
font-weight: 780;
}
.stage-copy p {
margin: 0;
max-width: 350px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.stage-mode {
position: absolute;
top: 24px;
right: 24px;
z-index: 2;
padding: 9px 11px;
border: 1px solid rgba(120, 228, 213, 0.25);
border-radius: 9px;
background: rgba(10, 19, 27, 0.74);
color: var(--cyan);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.13em;
backdrop-filter: blur(10px);
pointer-events: none;
}
.camera-hint {
position: absolute;
right: 24px;
bottom: 116px;
z-index: 2;
color: #647183;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
pointer-events: none;
}
.stage-footer {
position: absolute;
right: 18px;
bottom: 18px;
left: 18px;
z-index: 3;
display: grid;
grid-template-columns: minmax(280px, 1fr) auto;
gap: 24px;
align-items: center;
padding: 14px 16px;
border: 1px solid rgba(67, 83, 101, 0.68);
border-radius: 14px;
background: rgba(11, 17, 27, 0.84);
box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(16px);
}
.length-heading {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
margin-bottom: 9px;
}
.control-label {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
#lengthValue {
color: var(--text);
font-size: 15px;
font-weight: 780;
font-variant-numeric: tabular-nums;
}
input[type="range"] {
width: 100%;
height: 4px;
margin: 0;
border-radius: 999px;
appearance: none;
background: linear-gradient(
to right,
var(--orange) 0%,
var(--orange) 46%,
#2a3543 46%,
#2a3543 100%
);
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 16px;
height: 16px;
border: 3px solid #121b25;
border-radius: 50%;
appearance: none;
background: var(--orange);
box-shadow: 0 0 0 1px var(--orange), 0 0 15px rgba(255, 116, 84, 0.35);
}
input[type="range"]::-moz-range-thumb {
width: 11px;
height: 11px;
border: 3px solid #121b25;
border-radius: 50%;
background: var(--orange);
box-shadow: 0 0 0 1px var(--orange), 0 0 15px rgba(255, 116, 84, 0.35);
}
.range-scale {
display: flex;
justify-content: space-between;
margin-top: 7px;
color: #596677;
font-size: 9px;
font-variant-numeric: tabular-nums;
}
.stage-metrics {
display: flex;
gap: 22px;
padding-left: 22px;
border-left: 1px solid var(--line);
}
.stage-metric {
min-width: 76px;
}
.stage-metric span {
display: block;
margin-bottom: 5px;
color: var(--muted);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.stage-metric strong {
display: block;
color: var(--text);
font-size: 13px;
font-variant-numeric: tabular-nums;
}
.world-label {
position: absolute;
top: 0;
left: 0;
z-index: 2;
padding: 6px 8px;
border: 1px solid rgba(111, 132, 151, 0.35);
border-radius: 7px;
background: rgba(10, 15, 23, 0.72);
color: #a8b4c2;
font-size: 8px;
font-weight: 850;
letter-spacing: 0.12em;
white-space: nowrap;
pointer-events: none;
backdrop-filter: blur(6px);
}
.world-label.stop-label {
border-color: rgba(255, 116, 84, 0.55);
color: #ff9a83;
}
.panel {
min-height: 0;
overflow-y: auto;
padding: 17px;
border: 1px solid var(--line);
border-radius: var(--radius);
background: var(--panel);
scrollbar-width: thin;
scrollbar-color: #394657 transparent;
}
.panel::-webkit-scrollbar {
width: 6px;
}
.panel::-webkit-scrollbar-thumb {
border-radius: 10px;
background: #394657;
}
.card {
padding: 17px;
border: 1px solid var(--line);
border-radius: 15px;
background: linear-gradient(145deg, #151e2a, #111923);
}
.card + .card {
margin-top: 11px;
}
.card-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 15px;
}
.card-title {
color: var(--muted);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.card-index {
color: #546274;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 9px;
}
.frequency-line {
display: flex;
align-items: baseline;
gap: 9px;
margin: 4px 0 3px;
}
#frequencyBig {
font-size: 46px;
line-height: 1;
font-weight: 760;
letter-spacing: -0.06em;
font-variant-numeric: tabular-nums;
}
.frequency-unit {
color: var(--orange);
font-size: 13px;
font-weight: 800;
}
#modeTitle {
margin: 12px 0 6px;
font-size: 16px;
font-weight: 750;
}
#modeDetail {
min-height: 38px;
margin: 0;
color: var(--muted);
font-size: 11px;
line-height: 1.55;
}
.formula {
margin-top: 13px;
padding: 10px 11px;
border: 1px solid rgba(120, 228, 213, 0.16);
border-radius: 9px;
background: var(--cyan-soft);
color: #b6eee6;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 10px;
line-height: 1.55;
overflow-x: auto;
}
.metric-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 8px;
margin-top: 12px;
}
.metric {
padding: 10px;
border: 1px solid #273241;
border-radius: 9px;
background: rgba(8, 13, 20, 0.22);
}
.metric span {
display: block;
margin-bottom: 5px;
color: #6f7c8d;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.metric strong {
font-size: 12px;
font-variant-numeric: tabular-nums;
}
.mode-grid {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: 6px;
}
.mode-button {
position: relative;
min-width: 0;
padding: 10px 2px 9px;
border: 1px solid #2a3543;
border-radius: 9px;
background: #111923;
cursor: pointer;
transition:
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
.mode-button:hover {
border-color: #536173;
transform: translateY(-1px);
}
.mode-button span {
display: block;
margin-bottom: 4px;
color: #657285;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 8px;
}
.mode-button strong {
font-size: 12px;
}
.mode-button.is-active {
border-color: rgba(255, 116, 84, 0.72);
background: var(--orange-soft);
color: #ff9b84;
}
.mode-button.is-active span {
color: var(--orange);
}
.chart-wrap {
position: relative;
width: 100%;
border: 1px solid #263140;
border-radius: 11px;
overflow: hidden;
background: #0c131d;
}
#curveChart {
display: block;
width: 100%;
height: auto;
cursor: crosshair;
}
#curveChart text {
font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}
.chart-axis {
fill: #697687;
font-size: 7px;
font-weight: 700;
letter-spacing: 0.06em;
}
.chart-grid {
stroke: #263140;
stroke-width: 1;
}
.chart-note {
margin: 9px 1px 0;
color: #667385;
font-size: 9px;
line-height: 1.45;
}
.node-list {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.node-chip {
padding: 7px 8px;
border: 1px solid rgba(255, 209, 102, 0.2);
border-radius: 7px;
background: rgba(255, 209, 102, 0.07);
color: #e8c970;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 9px;
}
.node-chip small {
display: block;
margin-bottom: 3px;
color: #7f795f;
font-size: 7px;
font-weight: 800;
letter-spacing: 0.08em;
}
.assumption {
margin: 12px 1px 0;
padding-top: 11px;
border-top: 1px solid #27313f;
color: #667385;
font-size: 9px;
line-height: 1.55;
}
.assumption strong {
color: #9aa6b5;
}
@media (max-width: 1050px) {
.layout {
grid-template-columns: minmax(0, 1fr) 335px;
}
.stage-metrics {
gap: 12px;
padding-left: 15px;
}
.stage-metric {
min-width: 65px;
}
}
@media (max-width: 880px) {
body {
overflow: auto;
}
.app {
height: auto;
min-height: 100dvh;
grid-template-rows: 64px auto;
}
.topbar {
padding: 0 14px;
}
.brand-subtitle,
.top-meta {
display: none;
}
.layout {
grid-template-columns: 1fr;
}
.stage {
height: 64dvh;
min-height: 510px;
}
.panel {
overflow: visible;
}
}
@media (max-width: 560px) {
.brand-name {
font-size: 12px;
}
.audio-button {
width: 39px;
padding: 0;
}
#audioText {
display: none;
}
.stage {
height: 67dvh;
min-height: 500px;
}
.stage-copy {
top: 18px;
left: 18px;
}
.stage-copy p {
max-width: 270px;
}
.stage-mode {
top: 18px;
right: 18px;
}
.stage-footer {
grid-template-columns: 1fr;
gap: 13px;
}
.stage-metrics {
justify-content: space-between;
padding: 12px 0 0;
border-top: 1px solid var(--line);
border-left: 0;
}
.camera-hint {
display: none;
}
}
</style>
</head>
<body>
<div class="app">
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<i></i><i></i><i></i><i></i><i></i>
</div>
<div class="brand-copy">
<div class="brand-name">MONO / CHORD</div>
<div class="brand-subtitle">Harmonic length laboratory</div>
</div>
</div>
<div class="top-meta">Ideal string · wave speed 100 m/s</div>
<div class="top-actions">
<button class="icon-button" id="resetView" type="button" title="Reset camera" aria-label="Reset camera">
↺
</button>
<button class="audio-button" id="audioButton" type="button">
<span class="audio-dot"></span>
<span id="audioText">Audition</span>
</button>
</div>
</header>
<main class="layout">
<section class="stage" id="stage">
<div id="viewport"></div>
<div class="stage-copy">
<div class="eyebrow">Interactive acoustic model</div>
<h1>A string, measured in modes.</h1>
<p>
Drag the coral finger stop to change the speaking length.
Watch the standing wave settle into a new harmonic.
</p>
</div>
<div class="stage-mode" id="stageMode">HARMONIC 03</div>
<div class="camera-hint">Drag scene to orbit · scroll to zoom</div>
<div class="world-label stop-label" id="stopLabel">FINGER STOP</div>
<div class="world-label" id="nutLabel">FIXED NUT</div>
<div class="stage-footer">
<div class="length-control">
<div class="length-heading">
<label class="control-label" for="lengthSlider">Speaking length</label>
<output id="lengthValue" for="lengthSlider">62.0 cm</output>
</div>
<input
id="lengthSlider"
type="range"
min="30"
max="100"
step="0.1"
value="62"
aria-label="String speaking length in centimeters"
/>
<div class="range-scale">
<span>30 cm</span>
<span>65</span>
<span>100 cm</span>
</div>
</div>
<div class="stage-metrics">
<div class="stage-metric">
<span>Frequency</span>
<strong id="stageFrequency">241.9 Hz</strong>
</div>
<div class="stage-metric">
<span>Nodes</span>
<strong id="stageNodeCount">4</strong>
</div>
<div class="stage-metric">
<span>Positions</span>
<strong id="stageNodePositions">0 · 20.7 · 41.3 · 62 cm</strong>
</div>
</div>
</div>
</section>
<aside class="panel">
<section class="card">
<div class="card-head">
<div class="card-title">Active resonance</div>
<div class="card-index">01 / READOUT</div>
</div>
<div class="frequency-line">
<span id="frequencyBig">241.9</span>
<span class="frequency-unit">Hz</span>
</div>
<h2 id="modeTitle">Third harmonic</h2>
<p id="modeDetail"></p>
<div class="formula" id="formulaText"></div>
<div class="metric-grid">
<div class="metric">
<span>Fundamental</span>
<strong id="fundamentalValue">80.6 Hz</strong>
</div>
<div class="metric">
<span>Ratio</span>
<strong id="ratioValue">3×</strong>
</div>
<div class="metric">
<span>Half-wave</span>
<strong id="halfWaveValue">41.3 cm</strong>
</div>
</div>
</section>
<section class="card">
<div class="card-head">
<div class="card-title">Harmonic mode</div>
<div class="card-index">02 / STANDING WAVE</div>
</div>
<div class="mode-grid" id="modeGrid">
<button class="mode-button" type="button" data-mode="1" aria-pressed="false">
<span>01</span><strong>H1</strong>
</button>
<button class="mode-button" type="button" data-mode="2" aria-pressed="false">
<span>02</span><strong>H2</strong>
</button>
<button class="mode-button is-active" type="button" data-mode="3" aria-pressed="true">
<span>03</span><strong>H3</strong>
</button>
<button class="mode-button" type="button" data-mode="4" aria-pressed="false">
<span>04</span><strong>H4</strong>
</button>
<button class="mode-button" type="button" data-mode="5" aria-pressed="false">
<span>05</span><strong>H5</strong>
</button>
<button class="mode-button" type="button" data-mode="6" aria-pressed="false">
<span>06</span><strong>H6</strong>
</button>
</div>
</section>
<section class="card">
<div class="card-head">
<div class="card-title">Ideal frequency / length</div>
<div class="card-index">03 / LOG PLOT</div>
</div>
<div class="chart-wrap">
<svg
id="curveChart"
viewBox="0 0 330 205"
role="img"
aria-label="Logarithmic graph of harmonic frequency against speaking length"
></svg>
</div>
<p class="chart-note">
All six ideal harmonic curves follow
<strong>fₙ = nv / 2L</strong>.
Click the plot to move the stop.
</p>
</section>
<section class="card">
<div class="card-head">
<div class="card-title">Node positions</div>
<div class="card-index">04 / FROM THE NUT</div>
</div>
<div class="node-list" id="nodeList"></div>
<div class="assumption">
<strong>Model assumptions:</strong> lossless ideal string, constant wave
speed <strong>v = 100 m/s</strong>, no bridge or end-mass correction.
Endpoint markers include the fixed nut and movable stop.
</div>
</section>
</aside>
</main>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const $ = (id) => document.getElementById(id);
const viewport = $("viewport");
const stage = $("stage");
const lengthSlider = $("lengthSlider");
const curveChart = $("curveChart");
const modeButtons = [...document.querySelectorAll(".mode-button")];
const WAVE_SPEED = 100;
const MIN_LENGTH = 30;
const MAX_LENGTH = 100;
const NUT_X = -5.6;
const END_X = 5.8;
const STRING_Y = 1.47;
const MODE_AMPLITUDE = 0.59;
const state = {
length: 62,
mode: 3
};
const modeInfo = {
1: {
title: "Fundamental",
detail: "The lowest natural frequency. One half-wave spans the entire speaking length."
},
2: {
title: "Second harmonic",
detail: "Two half-waves occupy the speaking length, producing a frequency one octave above the fundamental."
},
3: {
title: "Third harmonic",
detail: "Three half-waves create two internal nodes and a frequency at the octave plus a perfect fifth."
},
4: {
title: "Fourth harmonic",
detail: "Four half-waves divide the string evenly, with three internal nodes and two octaves above the fundamental."
},
5: {
title: "Fifth harmonic",
detail: "Five half-waves produce four internal nodes, combining the third harmonic with the octave."
},
6: {
title: "Sixth harmonic",
detail: "Six half-waves create five internal nodes and a frequency at two octaves plus a perfect fifth."
}
};
function fundamentalFrequency(lengthCm) {
return WAVE_SPEED / (2 * (lengthCm / 100));
}
function harmonicFrequency(lengthCm, mode) {
return mode * fundamentalFrequency(lengthCm);
}
// ---------------------------------------------------------------------
// Renderer and scene
// ---------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0b111b);
scene.fog = new THREE.FogExp2(0x0b111b, 0.026);
const camera = new THREE.PerspectiveCamera(38, 1, 0.1, 100);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
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 three-dimensional voxel monochord");
renderer.domElement.setAttribute("tabindex", "0");
viewport.appendChild(renderer.domElement);
const controlsTarget = new THREE.Vector3(0.15, 0.58, 0);
const spherical = new THREE.Spherical(16.2, 1.08, 0.58);
function updateCamera() {
camera.position.setFromSpherical(spherical).add(controlsTarget);
camera.lookAt(controlsTarget);
}
updateCamera();
const hemisphere = new THREE.HemisphereLight(0xc2eaff, 0x21130f, 2.1);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff1d6, 3.2);
keyLight.position.set(4.5, 10, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -11;
keyLight.shadow.camera.right = 11;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.0002;
scene.add(keyLight);
const cyanLight = new THREE.PointLight(0x65e5dc, 24, 18, 2);
cyanLight.position.set(-5, 3.5, -3.5);
scene.add(cyanLight);
const orangeLight = new THREE.PointLight(0xff6e48, 18, 16, 2);
orangeLight.position.set(5, 2.8, 3);
scene.add(orangeLight);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(50, 50),
new THREE.MeshStandardMaterial({
color: 0x0c131c,
roughness: 0.94,
metalness: 0.05
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.505;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(34, 34, 0x334455, 0x1c2935);
grid.position.y = -0.495;
grid.material.transparent = true;
grid.material.opacity = 0.24;
scene.add(grid);
const model = new THREE.Group();
scene.add(model);
const darkMaterial = new THREE.MeshStandardMaterial({
color: 0x202a34,
roughness: 0.72,
metalness: 0.18
});
const nearBlackMaterial = new THREE.MeshStandardMaterial({
color: 0x111923,
roughness: 0.65,
metalness: 0.25
});
const stopMaterial = new THREE.MeshStandardMaterial({
color: 0xff7454,
emissive: 0x4d1208,
emissiveIntensity: 0.38,
roughness: 0.42,
metalness: 0.16
});
const brassMaterial = new THREE.MeshStandardMaterial({
color: 0xc9b68e,
emissive: 0x251b0d,
emissiveIntensity: 0.18,
roughness: 0.36,
metalness: 0.62
});
const nodeMaterial = new THREE.MeshStandardMaterial({
color: 0xffd166,
emissive: 0xffa51f,
emissiveIntensity: 1.7,
roughness: 0.35
});
const antinodeMaterial = new THREE.MeshStandardMaterial({
color: 0xff9b79,
emissive: 0x8a2e16,
emissiveIntensity: 1.2,
roughness: 0.4
});
function box(width, height, depth, material, x, y, z, parent = model) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// Voxel wooden base.
const baseCount = 50;
const baseWidth = 0.252;
const baseStart = -6.4;
const baseEnd = 6.4;
const baseMesh = new THREE.InstancedMesh(
new THREE.BoxGeometry(baseWidth, 0.5, 4.15),
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.88,
metalness: 0.02
}),
baseCount
);
baseMesh.castShadow = true;
baseMesh.receiveShadow = true;
const dummy = new THREE.Object3D();
const woodColor = new THREE.Color();
for (let i = 0; i < baseCount; i++) {
const x = THREE.MathUtils.lerp(baseStart, baseEnd, i / (baseCount - 1));
dummy.position.set(x, -0.25, 0);
dummy.scale.set(1, 1, 1);
dummy.updateMatrix();
baseMesh.setMatrixAt(i, dummy.matrix);
const variation = Math.sin(i * 17.173) * 0.5 + 0.5;
woodColor.setHSL(
0.073 + variation * 0.018,
0.39 + variation * 0.12,
0.29 + variation * 0.09
);
baseMesh.setColorAt(i, woodColor);
}
baseMesh.instanceMatrix.needsUpdate = true;
baseMesh.instanceColor.needsUpdate = true;
model.add(baseMesh);
// Fixed nut and tail support.
function createSupport(x, labelColor) {
const group = new THREE.Group();
group.position.x = x;
model.add(group);
box(0.58, 0.9, 2.45, darkMaterial, 0, 0.45, 0, group);
box(0.78, 0.24, 2.9, nearBlackMaterial, 0, 1.04, 0, group);
box(0.2, 0.2, 1.1, brassMaterial, 0, 1.28, 0, group);
const marker = box(
0.055,
0.12,
2.15,
new THREE.MeshStandardMaterial({
color: labelColor,
emissive: labelColor,
emissiveIntensity: 0.45,
roughness: 0.5
}),
0,
0.68,
1.24,
group
);
return group;
}
createSupport(NUT_X, 0x78e4d5);
createSupport(END_X, 0xff7454);
// Movable finger stop.
const stopGroup = new THREE.Group();
model.add(stopGroup);
const stopPedestal = box(0.58, 0.82, 1.7, darkMaterial, 0, 0.41, 0, stopGroup);
const stopCap = box(0.82, 0.2, 2.25, nearBlackMaterial, 0, 0.91, 0, stopGroup);
const stopPad = box(0.48, 0.28, 1.08, stopMaterial, 0, 1.2, 0, stopGroup);
const stopGrip = box(0.34, 0.25, 0.72, stopMaterial, 0, 0.51, 1.07, stopGroup);
const stopHitMeshes = [stopPedestal, stopCap, stopPad, stopGrip];
const stopLight = new THREE.PointLight(0xff6b45, 0.75, 3.2, 2);
stopLight.position.set(0, 1.7, 0);
stopGroup.add(stopLight);
// Active speaking-length indicator.
const activeSpanMaterial = new THREE.MeshStandardMaterial({
color: 0x78e4d5,
emissive: 0x3cc8b7,
emissiveIntensity: 1.05,
roughness: 0.4,
transparent: true,
opacity: 0.78
});
const activeSpan = new THREE.Mesh(
new THREE.BoxGeometry(1, 0.035, 0.12),
activeSpanMaterial
);
activeSpan.position.set(0, 0.055, 0);
model.add(activeSpan);
// Length scale blocks.
const tickMaterial = new THREE.MeshStandardMaterial({
color: 0xa69578,
emissive: 0x21170d,
emissiveIntensity: 0.2,
roughness: 0.6
});
for (let cm = 0; cm <= 100; cm += 5) {
const x = THREE.MathUtils.lerp(NUT_X, END_X, cm / 100);
const major = cm % 25 === 0;
box(
major ? 0.045 : 0.025,
major ? 0.065 : 0.04,
major ? 0.43 : 0.26,
tickMaterial,
x,
0.035,
2.16
);
}
function createTextSprite(text, color = "#a7b3c0") {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 64;
const context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
context.fillStyle = color;
context.font = "700 26px ui-monospace, monospace";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, canvas.width / 2, canvas.height / 2);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
opacity: 0.72,
depthTest: false
})
);
sprite.scale.set(1.2, 0.3, 1);
sprite.renderOrder = 4;
return sprite;
}
[0, 50, 100].forEach((cm) => {
const sprite = createTextSprite(`${cm} cm`);
sprite.position.set(
THREE.MathUtils.lerp(NUT_X, END_X, cm / 100),
0.18,
2.5
);
model.add(sprite);
});
// ---------------------------------------------------------------------
// Voxel string and standing-wave markers
// ---------------------------------------------------------------------
const stringSegments = 220;
const stringSpacing = (END_X - NUT_X) / (stringSegments - 1);
const stringMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
emissive: 0x092622,
emissiveIntensity: 0.55,
roughness: 0.3,
metalness: 0.22
});
const stringMesh = new THREE.InstancedMesh(
new THREE.BoxGeometry(1, 1, 1),
stringMaterial,
stringSegments
);
stringMesh.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
stringMesh.castShadow = true;
stringMesh.receiveShadow = true;
stringMesh.frustumCulled = false;
model.add(stringMesh);
const nodeGroup = new THREE.Group();
model.add(nodeGroup);
const nodeGeometry = new THREE.BoxGeometry(0.17, 0.17, 0.17);
const antinodeGeometry = new THREE.BoxGeometry(0.115, 0.115, 0.115);
let nodeMarkers = [];
function stopXForLength(lengthCm) {
return THREE.MathUtils.lerp(NUT_X, END_X, lengthCm / 100);
}
function updateStringAndNodes() {
const stopX = stopXForLength(state.length);
const activeLength = stopX - NUT_X;
const color = new THREE.Color();
for (let i = 0; i < stringSegments; i++) {
const x = NUT_X + i * stringSpacing;
const isActive = x <= stopX + stringSpacing * 0.5;
const s = THREE.MathUtils.clamp((x - NUT_X) / activeLength, 0, 1);
const displacement = isActive
? MODE_AMPLITUDE * Math.sin(Math.PI * state.mode * s)
: 0;
dummy.position.set(x, STRING_Y + displacement, 0);
dummy.scale.set(stringSpacing * 0.76, 0.085, 0.085);
dummy.updateMatrix();
stringMesh.setMatrixAt(i, dummy.matrix);
if (!isActive) {
color.set(0x34414d);
} else if (displacement >= 0) {
color.set(0x78e4d5);
} else {
color.set(0xff795b);
}
stringMesh.setColorAt(i, color);
}
stringMesh.instanceMatrix.needsUpdate = true;
stringMesh.instanceColor.needsUpdate = true;
nodeGroup.clear();
nodeMarkers = [];
for (let k = 0; k <= state.mode; k++) {
const x = NUT_X + (activeLength * k) / state.mode;
const node = new THREE.Mesh(nodeGeometry, nodeMaterial);
node.position.set(x, STRING_Y + 0.035, 0);
node.castShadow = true;
nodeGroup.add(node);
nodeMarkers.push(node);
}
for (let k = 0; k < state.mode; k++) {
const s = (k + 0.5) / state.mode;
const x = NUT_X + activeLength * s;
const displacement = MODE_AMPLITUDE * Math.sin(Math.PI * state.mode * s);
const antinode = new THREE.Mesh(antinodeGeometry, antinodeMaterial);
antinode.position.set(x, STRING_Y + displacement, 0);
antinode.castShadow = true;
nodeGroup.add(antinode);
}
stopGroup.position.x = stopX;
activeSpan.position.x = (NUT_X + stopX) / 2;
activeSpan.scale.x = activeLength;
}
// Decorative voxel motes.
const dustCount = 26;
const dustMesh = new THREE.InstancedMesh(
new THREE.BoxGeometry(0.075, 0.075, 0.075),
new THREE.MeshBasicMaterial({
color: 0x416275,
transparent: true,
opacity: 0.35
}),
dustCount
);
for (let i = 0; i < dustCount; i++) {
dummy.position.set(
THREE.MathUtils.lerp(-9, 9, (Math.sin(i * 91.7) + 1) / 2),
THREE.MathUtils.lerp(0.3, 5.2, (Math.sin(i * 31.1) + 1) / 2),
THREE.MathUtils.lerp(-5, 3, (Math.cos(i * 47.3) + 1) / 2)
);
dummy.scale.setScalar(0.7 + ((i * 13) % 5) * 0.13);
dummy.updateMatrix();
dustMesh.setMatrixAt(i, dummy.matrix);
}
dustMesh.instanceMatrix.needsUpdate = true;
scene.add(dustMesh);
// ---------------------------------------------------------------------
// Interface and chart
// ---------------------------------------------------------------------
function updateRangeFill() {
const percent = ((state.length - MIN_LENGTH) / (MAX_LENGTH - MIN_LENGTH)) * 100;
lengthSlider.style.background = `linear-gradient(
to right,
var(--orange) 0%,
var(--orange) ${percent}%,
#2a3543 ${percent}%,
#2a3543 100%
)`;
}
function updateUI() {
const fundamental = fundamentalFrequency(state.length);
const frequency = harmonicFrequency(state.length, state.mode);
const info = modeInfo[state.mode];
const positions = [];
for (let k = 0; k <= state.mode; k++) {
positions.push((state.length * k) / state.mode);
}
lengthSlider.value = state.length.toFixed(1);
$("lengthValue").textContent = `${state.length.toFixed(1)} cm`;
$("frequencyBig").textContent = frequency.toFixed(1);
$("modeTitle").textContent = info.title;
$("modeDetail").textContent = info.detail;
$("fundamentalValue").textContent = `${fundamental.toFixed(1)} Hz`;
$("ratioValue").textContent = `${state.mode}×`;
$("halfWaveValue").textContent = `${((2 * state.length) / state.mode).toFixed(1)} cm`;
$("stageMode").textContent = `HARMONIC ${String(state.mode).padStart(2, "0")}`;
$("stageFrequency").textContent = `${frequency.toFixed(1)} Hz`;
$("stageNodeCount").textContent = String(state.mode + 1);
$("stageNodePositions").textContent = `${positions
.map((position) => position.toFixed(1))
.join(" · ")} cm`;
$("formulaText").innerHTML =
`f<sub>${state.mode}</sub> = ${state.mode} × ${WAVE_SPEED} ` +
`/ (2 × ${(state.length / 100).toFixed(2)}) = ${frequency.toFixed(1)} Hz`;
$("nodeList").innerHTML = positions
.map((position, index) => {
let label = `NODE ${index}`;
if (index === 0) label = "NUT";
if (index === state.mode) label = "STOP";
return `<div class="node-chip"><small>${label}</small>${position.toFixed(1)} cm</div>`;
})
.join("");
modeButtons.forEach((button) => {
const active = Number(button.dataset.mode) === state.mode;
button.classList.toggle("is-active", active);
button.setAttribute("aria-pressed", String(active));
});
updateRangeFill();
renderChart();
}
function renderChart() {
const W = 330;
const H = 205;
const margin = { left: 45, right: 14, top: 16, bottom: 35 };
const plotWidth = W - margin.left - margin.right;
const plotHeight = H - margin.top - margin.bottom;
const xOf = (length) =>
margin.left + ((length - 30) / 70) * plotWidth;
const logMin = Math.log10(50);
const logMax = Math.log10(1200);
const yOf = (frequency) =>
margin.top +
plotHeight -
((Math.log10(frequency) - logMin) / (logMax - logMin)) * plotHeight;
const xTicks = [30, 40, 50, 60, 70, 80, 90, 100];
const yTicks = [60, 100, 250, 500, 1000];
let svg = `
<defs>
<filter id="markerGlow" x="-100%" y="-100%" width="300%" height="300%">
<feGaussianBlur stdDeviation="2.6" result="blur" />
<feMerge>
<feMergeNode in="blur" />
<feMergeNode in="SourceGraphic" />
</feMerge>
</filter>
</defs>
`;
yTicks.forEach((tick) => {
const y = yOf(tick);
svg += `
<line class="chart-grid" x1="${margin.left}" y1="${y}" x2="${W - margin.right}" y2="${y}" />
<text class="chart-axis" x="${margin.left - 8}" y="${y + 3}" text-anchor="end">${tick}</text>
`;
});
xTicks.forEach((tick) => {
const x = xOf(tick);
svg += `
<line class="chart-grid" x1="${x}" y1="${margin.top}" x2="${x}" y2="${H - margin.bottom}" />
<text class="chart-axis" x="${x}" y="${H - 16}" text-anchor="middle">${tick}</text>
`;
});
for (let mode = 1; mode <= 6; mode++) {
const selected = mode === state.mode;
let path = "";
for (let length = 30; length <= 100; length += 1) {
const x = xOf(length);
const y = yOf(harmonicFrequency(length, mode));
path += `${path ? " L" : "M"}${x.toFixed(2)},${y.toFixed(2)} `;
}
svg += `
<path
d="${path}"
fill="none"
stroke="${selected ? "#ff7454" : "#78e4d5"}"
stroke-width="${selected ? 2.6 : 1.25}"
opacity="${selected ? 1 : 0.2}"
stroke-linejoin="round"
stroke-linecap="round"
/>
`;
}
const markerX = xOf(state.length);
const markerY = yOf(harmonicFrequency(state.length, state.mode));
svg += `
<line
x1="${markerX}" y1="${margin.top}"
x2="${markerX}" y2="${H - margin.bottom}"
stroke="#ff7454" stroke-width="0.8" stroke-dasharray="3 4" opacity="0.45"
/>
<circle
cx="${markerX}" cy="${markerY}" r="5.1"
fill="#ff7454" stroke="#111923" stroke-width="2"
filter="url(#markerGlow)"
/>
<text class="chart-axis" x="${W - margin.right}" y="${H - 3}" text-anchor="end">
LENGTH (cm)
</text>
<text class="chart-axis" transform="translate(11 120) rotate(-90)" text-anchor="middle">
FREQUENCY (Hz)
</text>
`;
curveChart.innerHTML = svg;
}
function setLength(lengthCm) {
state.length = THREE.MathUtils.clamp(lengthCm, MIN_LENGTH, MAX_LENGTH);
updateStringAndNodes();
updateUI();
}
function setMode(mode) {
state.mode = THREE.MathUtils.clamp(mode, 1, 6);
updateStringAndNodes();
updateUI();
if (audioOn) {
startTone();
}
}
lengthSlider.addEventListener("input", (event) => {
setLength(Number(event.target.value));
});
modeButtons.forEach((button) => {
button.addEventListener("click", () => {
setMode(Number(button.dataset.mode));
});
});
curveChart.addEventListener("pointerdown", (event) => {
const rect = curveChart.getBoundingClientRect();
const svgX = ((event.clientX - rect.left) / rect.width) * 330;
const length =
30 + ((svgX - 45) / (330 - 45 - 14)) * (100 - 30);
setLength(length);
});
// ---------------------------------------------------------------------
// Direct camera and stop controls — no external controls addon
// ---------------------------------------------------------------------
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const dragPlane = new THREE.Plane(new THREE.Vector3(0, 1, 0), -1.15);
const dragPoint = new THREE.Vector3();
let orbiting = false;
let draggingStop = false;
let stopHovered = false;
let lastPointerX = 0;
let lastPointerY = 0;
let activePointerId = null;
function updatePointer(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function setStopHover(hovered) {
stopHovered = hovered;
stopMaterial.emissiveIntensity = draggingStop
? 1.15
: hovered
? 0.72
: 0.38;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.pointerType === "mouse" && event.button !== 0) return;
updatePointer(event);
raycaster.setFromCamera(pointer, camera);
const hit = raycaster.intersectObjects(stopHitMeshes, false);
activePointerId = event.pointerId;
renderer.domElement.setPointerCapture(event.pointerId);
if (hit.length) {
draggingStop = true;
setStopHover(true);
renderer.domElement.style.cursor = "ew-resize";
} else {
orbiting = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.style.cursor = "grabbing";
}
event.preventDefault();
});
renderer.domElement.addEventListener("pointermove", (event) => {
updatePointer(event);
if (draggingStop) {
raycaster.setFromCamera(pointer, camera);
if (raycaster.ray.intersectPlane(dragPlane, dragPoint)) {
const length =
((dragPoint.x - NUT_X) / (END_X - NUT_X)) * 100;
setLength(length);
}
return;
}
if (orbiting) {
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
spherical.theta -= dx * 0.006;
spherical.phi = THREE.MathUtils.clamp(
spherical.phi - dy * 0.005,
0.38,
1.46
);
updateCamera();
return;
}
raycaster.setFromCamera(pointer, camera);
const hit = raycaster.intersectObjects(stopHitMeshes, false);
setStopHover(hit.length > 0);
renderer.domElement.style.cursor = hit.length ? "ew-resize" : "grab";
});
function endPointer(event) {
orbiting = false;
draggingStop = false;
setStopHover(false);
renderer.domElement.style.cursor = "grab";
if (
activePointerId !== null &&
renderer.domElement.hasPointerCapture(activePointerId)
) {
renderer.domElement.releasePointerCapture(activePointerId);
}
activePointerId = null;
if (event) event.preventDefault();
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("lostpointercapture", () => {
orbiting = false;
draggingStop = false;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
spherical.radius = THREE.MathUtils.clamp(
spherical.radius + event.deltaY * 0.008,
8.5,
24
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.style.cursor = "grab";
$("resetView").addEventListener("click", () => {
spherical.set(16.2, 1.08, 0.58);
controlsTarget.set(0.15, 0.58, 0);
updateCamera();
});
window.addEventListener("keydown", (event) => {
const tag = event.target.tagName;
if (tag === "INPUT" || tag === "BUTTON") return;
if (event.key === "ArrowRight") {
setLength(state.length + (event.shiftKey ? 5 : 1));
} else if (event.key === "ArrowLeft") {
setLength(state.length - (event.shiftKey ? 5 : 1));
} else if (/^[1-6]$/.test(event.key)) {
setMode(Number(event.key));
} else if (event.code === "Space") {
event.preventDefault();
toggleAudio();
} else if (event.key.toLowerCase() === "r") {
spherical.set(16.2, 1.08, 0.58);
updateCamera();
}
});
// ---------------------------------------------------------------------
// Optional Web Audio audition
// ---------------------------------------------------------------------
let audioContext = null;
let oscillator = null;
let gainNode = null;
let audioOn = false;
let soundToken = 0;
function updateAudioButton() {
const frequency = harmonicFrequency(state.length, state.mode);
$("audioButton").classList.toggle("is-playing", audioOn);
$("audioText").textContent = audioOn
? `Playing ${frequency.toFixed(0)} Hz`
: "Audition";
}
function stopTone() {
soundToken++;
if (oscillator) {
try {
oscillator.stop();
} catch (error) {
// The oscillator may already have ended.
}
}
oscillator = null;
gainNode = null;
audioOn = false;
updateAudioButton();
}
function startTone() {
const AudioContextClass =
window.AudioContext || window.webkitAudioContext;
if (!AudioContextClass) {
$("audioText").textContent = "Audio unavailable";
return;
}
if (!audioContext) {
audioContext = new AudioContextClass();
}
audioContext.resume();
stopTone();
const token = soundToken;
const now = audioContext.currentTime;
const frequency = harmonicFrequency(state.length, state.mode);
oscillator = audioContext.createOscillator();
gainNode = audioContext.createGain();
oscillator.type = "sine";
oscillator.frequency.setValueAtTime(frequency, now);
gainNode.gain.setValueAtTime(0.0001, now);
gainNode.gain.exponentialRampToValueAtTime(0.17, now + 0.025);
gainNode.gain.exponentialRampToValueAtTime(0.0001, now + 2.4);
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
oscillator.start(now);
oscillator.stop(now + 2.5);
audioOn = true;
updateAudioButton();
oscillator.onended = () => {
if (token === soundToken) {
audioOn = false;
updateAudioButton();
}
};
}
async function toggleAudio() {
if (audioOn) {
stopTone();
} else {
startTone();
}
}
$("audioButton").addEventListener("click", toggleAudio);
// ---------------------------------------------------------------------
// Projected labels, resizing, and animation
// ---------------------------------------------------------------------
function placeLabel(element, worldPosition) {
const projected = worldPosition.clone().project(camera);
const width = viewport.clientWidth;
const height = viewport.clientHeight;
const visible = projected.z > -1 && projected.z < 1;
element.style.display = visible ? "block" : "none";
if (!visible) return;
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
element.style.transform =
`translate(-50%, -50%) translate(${x.toFixed(1)}px, ${y.toFixed(1)}px)`;
}
function resize() {
const width = Math.max(1, viewport.clientWidth);
const height = Math.max(1, viewport.clientHeight);
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.fov = width < 560 ? 44 : 38;
camera.updateProjectionMatrix();
updateCamera();
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(viewport);
const clock = new THREE.Clock();
const labelPosition = new THREE.Vector3();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
dustMesh.rotation.y = elapsed * 0.014;
dustMesh.position.y = Math.sin(elapsed * 0.24) * 0.06;
nodeMarkers.forEach((node, index) => {
const pulse = 1 + Math.sin(elapsed * 2.8 + index * 0.7) * 0.1;
node.scale.setScalar(pulse);
});
activeSpanMaterial.emissiveIntensity =
0.88 + Math.sin(elapsed * 2.1) * 0.17;
stopLight.intensity =
0.65 + Math.sin(elapsed * 2.4) * 0.12;
labelPosition.set(stopGroup.position.x, 2.2, 0);
placeLabel($("stopLabel"), labelPosition);
labelPosition.set(NUT_X, 1.95, 0);
placeLabel($("nutLabel"), labelPosition);
renderer.render(scene, camera);
}
updateStringAndNodes();
updateUI();
resize();
animate();
</script>
</body>
</html>
```