~/todd-fleeman/case-study — session log entry

~/WebGL Shapes

started 2026-10-10 · last touched 2026-10-10
why this exists

Five wireframe shapes spinning in WebGL: a cube, a sphere, a circle, a cone, and a plane. Pick one from the menu and it spins in 3D. This was my first time using plain Three.js, with no React wrapper, so I could learn the raw pieces a 3D scene is built from before handing any of it off to a library.

built on / learned
Three JS
Learned
  • Every 3D scene has the same three parts. A scene that holds things, a camera that looks at them, and a renderer that draws what the camera sees onto a canvas. A shape is just geometry (its form) plus material (its surface).
  • Animation is a loop you own. Nothing moves unless you move it. Each frame nudges the rotation and redraws, using requestAnimationFrame. Every shape gets its own speed, because a spinning cube and a spinning sphere don't feel the same at the same rate.
  • Cleanup isn't optional. Graphics memory doesn't clean itself up like regular JavaScript does. Every time the shape changes, the old geometry, material, and renderer have to be disposed by hand, the loop canceled, and the canvas removed. Skip that and the page gets slower with every click.
  • React and Three.js meet at a ref. React owns the menu and the container. Three.js owns everything inside the canvas. It's the same arrangement as D3: each library stays on its own side.
where this might go

Swap the wireframes for real models, and it's a product viewer: spin a sneaker, a chair, or a helmet before you buy it. Swap them for a team's trophy, a stadium, or a mascot, and it's a 3D centerpiece for a feature story. A menu that changes what's in a 3D scene is the core of every configurator and showroom out there. This version has one camera, one shape, and one dropdown, and it's still the same idea.