Viewing a saved revision (read-only)
mdMDU00G0kJChYqnh26rX
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 bounce area is enlarged to give them more room to move.
Structure
index.html- HTML entry point with import map for Three.jsmain.js- Animation loop and setup orchestrationconfig.js- Tunable constants (sphere sizes, spacing, physics, bounds)scene.js- Scene creation and lightingsphereCube.js- Creates the 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 its own radius, position, and velocity. Every frame:
- Gravity is applied to the vertical velocity.
- Velocity is dampened and capped.
- Position is advanced by velocity.
- Wall collisions reflect velocity while respecting each sphere's radius.
- Sphere-sphere collisions use the combined radii to detect contact and separate balls.
Controls
Drag to orbit the view and scroll to zoom. The enlarged bounce area can be explored by orbiting or zooming out.