Viewing a saved revision (read-only)
GTeYrE5v_uDHrswP7gECC
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 a 4×4×4 grid of orange spheres that bounce around inside an invisible bounding box. Each sphere has independent physics — gravity pulls them down, they collide with the walls of the box, and they bounce with energy damping. Drag with the mouse to orbit the camera.
Structure
index.html- HTML entry point with import map for Three.jsmain.js- Animation loop and setup orchestrationconfig.js- Tunable constants (radius, spacing, physics)scene.js- Scene creation and lightingsphereCube.js- Creates the cube of spheres and their physics statesimulation.js- Per-frame physics update (gravity, walls, collisions)renderer.js- WebGL renderer setupcamera.js- Perspective camera setupcontrols.js- OrbitControls setup
Physics
Each sphere has a position and velocity vector. Every frame:
- Gravity is applied to the vertical velocity.
- Velocity is dampened.
- Position is advanced by velocity.
- Wall collisions reflect velocity and dampen energy.
- Sphere-sphere collisions apply a repulsion impulse.