Export Code

Bouncing Spheres

Curran Kelleher

Last edited Mar 19, 2025
Created on Mar 19, 2025
Forked from 3D Cube of Spheres

Manifested using Claude 3.7 Sonnet with VizHub's "Edit with AI" feature. It's truly incredible how good it is with ThreeJS! I gave it this older example Bouncing Balls and told it to make it work in 3D!

Here's the full description Claude wrote:

3D Physics Simulation with Sound

This project demonstrates a 3D physics simulation with gravity, bouncing spheres, and audio feedback.

Features

  • 3D spheres with realistic physics
  • Gravity and bouncing
  • Sphere-to-sphere collision detection
  • Interactive container walls
  • Mouse interaction to grab and pull spheres
  • Camera controls for 3D navigation (orbit, zoom, pan)
  • Audio feedback for collisions with different sounds

Physics Features

  • Gravity pulls spheres downward
  • Dampening factor reduces velocity over time
  • Spheres bounce off container walls
  • Spheres collide and repel each other
  • Mouse interaction allows pulling spheres

Audio Features

  • Distinct sounds for wall collisions and ball-to-ball collisions
  • Wall collisions produce a higher-pitched sine wave
  • Ball collisions produce a lower-pitched triangle wave
  • Sound volume varies with impact velocity
  • Ability to mute/unmute sounds

Technologies Used

  • Three.js for 3D rendering
  • JavaScript ES modules
  • Custom physics implementation
  • Interactive camera controls
  • Web Audio API for sound generation
MIT Licensed

Comments

User avatar
Nita
commented on
Mar 19, 2025

Wow