% modified from Professor Militzer's code for a Menger Sponge

function cube(r,L,color)

x = [ L; 0; 0];
y = [ 0; L; 0];
z = [ 0; 0; L];

square(r,x,y,color);
square(r,y,z,color);
square(r,z,x,color);
square(r+x+y+z,-x,-y,color);
square(r+x+y+z,-y,-z,color);
square(r+x+y+z,-z,-x,color);

end
