Skip to main content
Public

Share visualization

Loading preview…

Plucked-String Spheres with Varied Drum Synthesis

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Viewing a saved revision (read-only)

BJBY7wW8tyzPWV19nLpiA

Plucked-String Spheres with Varied Drum Synthesis

0
CCurran Kelleher
Last edited Nov 12, 2026
Created on Nov 11, 2026

This interactive WebGL visualization displays a 4×4×4 cube of spheres with warm orange color variations. Each sphere uses Three.js MeshPhongMaterial with randomly varied HSL saturation and lightness values, creating a subtle gradient effect. The entire cube group rotates continuously in both the x and y axes through the animation loop, while OrbitControls allows users to zoom and pan around the structure. The scene uses 64 individually positioned spheres, rendered with directional and ambient lighting for depth.

Bouncing Balls Cube

A Three.js visualization of orange spheres bouncing around inside an invisible bounding box. The balls have varied sizes and independent physics, including gravity, wall bounces, and sphere-sphere collisions.

The balls stay frozen in their initial grid until the user clicks Enable Sound & Drop Balls (or presses any key). This satisfies the browser autoplay policy and makes the first frame a calm, static preview before the physics begins.

Structure

  • index.html - HTML entry point with import map for Three.js
  • main.js - Animation loop and setup orchestration
  • config.js - Tunable constants (sphere sizes, spacing, physics, bounds, audio)
  • scene.js - Scene creation and lighting
  • sphereCube.js - Creates the spheres and their physics state
  • simulation.js - Per-frame physics update (gravity, walls, collisions) and collision event reporting
  • renderer.js - WebGL renderer setup
  • camera.js - Perspective camera setup
  • controls.js - OrbitControls setup
  • audio.js - Web Audio API software synthesizer for dynamic collision sound effects

Physics

Each sphere has its own radius, position, and velocity. Once started, every frame:

  1. Gravity is applied to the vertical velocity.
  2. Velocity is dampened and capped.
  3. Position is advanced by velocity.
  4. Wall collisions reflect velocity while respecting each sphere's radius.
  5. Sphere-sphere collisions use the combined radii to detect contact and separate balls.

Sound

Sound effects are generated on the fly using software synthesis (audio.js) rather than loading audio files. The synthesis favors a synthetic, percussive attack — peaks are reached almost instantly (attackTime) and each voice gets a small random pitch offset (pitchSpread) so repeated hits don't sound identical:

  • Wall bounces trigger a sharp square-wave tick with a fast downward pitch sweep, scaled by impact speed.
  • Sphere-sphere collisions trigger a snappy synthetic "zap": a resonant noise transient plus two slightly detuned sawtooth oscillators, with pitch derived from the combined radius.
  • Impact volume is proportional to the collision's relative speed, so gentle taps are quiet and hard hits are loud.
  • A master gain node, a gentle low-pass filter, and a soft limiter keep the mix from clipping.

Because browsers require a user gesture before audio can start, an "Enable Sound & Drop Balls" overlay appears first. Click it (or press any key) to unlock the audio context and release the balls.

Controls

  • Drag to orbit the view and scroll to zoom.
  • Click Enable Sound & Drop Balls to start the audio engine (required by browser autoplay policies) and begin the physics.
  • Use the Sound checkbox in the top-right corner to mute/unmute.
  • Adjust the Volume slider to taste.
  • Press M to toggle mute at any time.

References

MIT Licensed