Script Monkey Blog – The Sierpinski Gasket

When rendered in 3D the Sierpinski 'solid' has Infinite surface area and Zero volume.

12th August 2021

This should be 'impossible' for a 3d shape, and yet at the limiting case of iterations, it is true. Just look below to see one rendered in 3D.

I have always been fascinated by geometry and fractals since first seeing the Mandlebrot set back in the Triassic period. As 3d libraries have become more and more accessible, it has been possible to render 3d environments entirely 'in browser' using tools like Three.js, a personal favourite.

These geometries are incredibly simple to define, a little harder to code. For the triangle, you start by naming the three vertices 1 to 3, and assign x, y coordinates to each. You then choose a random number from 1 to 3 representing a vertex and plot a point halfway between your current position and the randomly selected vertex. Repeat a few thousand times and you create the Sierpinski gasket.

If you then think in three dimensions and assign x, y, z coordinates to the eight vertices of a containing cube, a 3d version of the triangular gasket is created after 1,000,000 iterations. I am pondering trying this with 5, 6, 7, .. n sided solids but have yet to find the time. Do let me know if you would like to see this and I may prioritise it!

Part of me wonders that if we did the same in four dimensions, arbitrarily considering time as the 4th dimesnion, we may end up mapping the structure of hyperspace.

With Three.js, it is possible render a 3d environment and then navigate it in real time.

Here is a 2D Sierpinski Gasket

How do we go about rendering these in 3d using Three.js?

1 million points are rendered in the below example. (Tip: left or right drag the mouse slowly near the image and wheel to zoom to seedetailed structure)