Visualizations
324 / 500

324 · Physics

Shattered Pane

A sunny window breaks into radial and ring cracks, then shards tumble and glint.

Ordinary annealed glass fails in two stages: radial cracks race out from the impact and fork whenever the strip of glass between two of them gets too wide, then concentric cracks join neighboring radials in rings that spread farther apart away from the impact. The program grows that structure in polar form, with radials as forking random walks and rings as bowed chords, some of which never crack so cells merge into long daggers. Every cell becomes a rigid shard with a position, velocity, rotation matrix and spin, projected with perspective into the room, bouncing off the sill and settling on the floor. Shading comes from each shard's normal: a Fresnel term for reflection, a thickness edge, and a sun highlight only for glass standing in the beam of light. Tempered glass instead dices into a Voronoi crumble of small cubes.

Try it. Click the glass to strike it; hold or drag before releasing to hit harder. Click again after it breaks for a new pane. T switches between annealed and tempered glass, R installs a new pane, and space toggles extra slow motion.

  • Fracture patterns
  • Rigid body dynamics
  • Perspective projection
  • Voronoi tessellation
  • Fresnel and specular shading

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a breaking window with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Make a canvas that fills the window and stays sharp on high-DPI screens. Draw a wall, a window frame, and a simple sky and lawn through the glass.
- When I click the glass, generate a crack pattern around the click point. Shoot out 8 to 14 radial cracks at roughly even angles, each a polyline whose angle wanders a little, long enough to reach past the frame.
- Add concentric rings at radii that grow apart as they go outward (for example each gap 1.3 times the last). Between each pair of neighboring radials, a ring is a slightly bowed chord, with a little random jitter.
- Each cell between two radials and two rings is a polygon. Clip each one to the glass rectangle with Sutherland-Hodgman.
- Animate the cracks growing outward first, then turn each polygon into a shard with a velocity and a spin and let gravity pull it to the floor.

Once that works, make it beautiful:
- Fake 3D: give each shard a rotation matrix and an angular velocity, rotate its corners in 3D, and project them with a simple perspective divide so pieces tumble toward the viewer.
- Shade by the shard's normal: more reflection when it is tilted (Fresnel), and a sharp sun highlight with a little star glint when the normal lines up with the light.
- Show the crack growth and the first burst in slow motion, then ease back to real time.
- Let a few edge pieces stay stuck in the frame, and let shards bounce once and settle flat on the floor.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as forking radial cracks, a tempered glass mode that crumbles into small cubes, or a beam of sunlight that only lights the shards inside it.
PreviousEdge DetectionThe full Canny pipeline, ending in Hough-detected lines and circles. NextSelf-Organizing QuiltKohonen maps sew a quilt from fabric dyes and drape a sheet over 3D point clouds.

Related visualizations

  • KintsugiGenerative art A glazed tea bowl shatters along branching cracks, then is mended with flowing gold.
  • Glenz VectorsRetro Nested glassy checkered polyhedra bounce on a glossy floor, then shatter and rebuild.
  • Basalt ColumnsNature Cooling lava cracks into columns that drift toward hexagons, on an isometric causeway.
  • Drying MudSimulation Wet clay dries and cracks into a lakebed of curling plates, primaries first.
  • Optical BenchPhysics A blueprint ray tracer: prisms, lenses, mirrors and a fiber with real glass dispersion.
  • Rain on GlassFluids Raindrops bead, merge and run down a fogged window, each a tiny upside-down city.
  • Pool CausticsPhysics Sunlight bent by a rippling pool surface draws a living net of light on the tiles.
  • Rigid BodiesPhysics Stacked towers of boxes knocked down by a swinging wrecking ball.
  • Glass HarpSound Ray-traced wine glasses, tuned with water and sung by stick-slip friction on the rim.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs