Last active
January 27, 2021 03:26
-
-
Save kmcallister/c8d9975fd0733d9453ceec527db14bd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module menger_sponge(n) { | |
if (n <= 0) { | |
cube(center=true); | |
} else { | |
for (x=[-1:1]) { | |
for (y=[-1:1]) { | |
for (z=[-1:1]) { | |
if (abs(x)+abs(y)+abs(z) >= 2) { | |
scale(1/3) | |
translate([x,y,z]) | |
menger_sponge(n-1); | |
} | |
} | |
} | |
} | |
} | |
} | |
scale(30) | |
menger_sponge(3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment