N
Tetrahedral sponge. Set N - sponge order.
Use your fingers or mouse to control the model (hold shift key or use mouse wheel to zoom it). Canvas is matched to your browser window.

Making fractal sponge

Fractal tetrahedron is made in the draw(N, tr_x, tr_y, tr_z, ) function by recursive translations of scaled tetrahedron
function draw(k, x, y, z){
   if (k > 0){
     k--;
     draw(k, 1 + x/2, 1 + y/2, -1 + z/2);
     draw(k, 1 + x/2,-1 + y/2,  1 + z/2);
     draw(k,-1 + x/2, 1 + y/2,  1 + z/2);
     draw(k,-1 + x/2,-1 + y/2, -1 + z/2);}
   else{
      gl.uniform3f( transLoc, x, y, z);
      gl.drawArrays(gl.TRIANGLES, 0, 12);  // render one tetrahedron
   }
}

WebGL Demos     updated 20 Jan 2011