← All examples

05 Three.js · Advanced

Build a sound sculpture.

Deform a particle sphere with bass, twist it with mids and scatter its surface with highs.

bass
0.00
mid
0.00
high
0.00

What you’ll learn

Drive buffer geometry directly from audio data, without a React render per frame. Three.js is a separate renderer, not a dependency of audio-bands.

Install three separately. This example loads it on demand and disposes its geometry, material and renderer when you leave.

The complete setup, with playback and cleanup →

Download the working Three.js renderer ↓

The key idea · excerpt
const { bass, mid, high } = audio.getBands();
for (let i = 0; i < count; i++) {
  const wave = Math.sin(i * 0.17 + time);
  const radius = 1 + bass * 0.65 + wave * high * 0.3;
  positions[i * 3] = base[i * 3] * radius;
  positions[i * 3 + 1] = base[i * 3 + 1] * radius;
  positions[i * 3 + 2] = base[i * 3 + 2] * radius;
}
geometry.attributes.position.needsUpdate = true;
points.rotation.y += mid * delta;

Music: I dunno by grapes · Drive by AlexBeroza · Parametaphoriquement by gmz · nightWalk by airtone. From ccMixter, under CC BY 3.0.