Instead of building snowflakes negatively, by recursively removing subcubes from a cube, we can build ‘positive’ snowflakes by adding subcubes.1 Given a cube aligned with the principal axes, we’ll call the face that the negative y-axis pierces its inactive face, and call its remaining five faces active. A level 0 set is just a cube aligned with the principal axes. To construct a level set, we construct a level 0 set (an axis-aligned cube), and then attach a scaled-down level snowflake to each of the cube’s five active faces. To get the main idea, select Box and set level to 1 in the following program.
The following function gets called with the level of the target snowflake, a mesh (such as a box), and the mesh’s diameter len. Since the same process can be applied to any solid, the program has a dropdown with a few choices for mesh. I’ve chosen solids that have the same rotational symmetry when viewed along all three principal axes.
function makePosSnowflake(level, mesh, len=1) { let base = mesh.clone(); if (level > 0) { let root1 = new THREE.Object3D(); root1.scale.set(0.5, 0.5, 0.5); base.add(root1); let sf = makePosSnowflake(level-1, mesh, len); sf.position.y = 1.5 * len; root1.add(sf); for (let i = 0; i < 4; i++) { let root2 = new THREE.Object3D(); root2.rotation.x = Math.PI / 2; root2.rotation.z = i * Math.PI / 2; root1.add(root2); let sf = makePosSnowflake(level-1, mesh, len); sf.position.y = 1.5 * len; root2.add(sf); } } return base; }
If you click awesome, a box is placed in the center, and then a snowflake is constructed on each of its six faces. This is done by calling makePosSnowflake
six times and placing each resulting snowflake in a suitably translated, rotated space. The center checkbox toggles creation of this center box when things are awesome. The offset slider translates each level set toward or away from the center box. In makePosSnowflake,
offset is a factor on the right side of the assignment on lines 8 and 16 though I’ve removed it from the above code.
- This and other fractals on these pages appear in Eric Baird’s beautiful book Alt.Fractals: A Visual Guide to Fractal Geometry and Design. ↩