In my online undergraduate P5.js course, students are about to begin the module on motion and physics, including a bit of physics simulation using Matter.js. It suddenly occurred to me that I had never seen anybody put together this particular demo before, and I realized it had to be done. Messy source code at https://editor.p5js.org/isohedral/full/vJa5RiZWs.

@csk Wonderful!

I made your code even messier by introducing a small... let's say "typographic" improvement:

https://editor.p5js.org/lenaschimmel/full/l74GivEMb

p5.js Web Editor

A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.

@lenaschimmel @csk

This one has a lot of optional ways to destabilize the system. Pick up a tiny block from the top, don't drop it, and watch the instability move through the carefully balanced system-- over and over.