Polyhedral snowflakes

The following program is like the one on the previous page but with a few differences. First, it builds polyhedral fractals ‘inward’ to occupy the volume of the level 0 polyhedron (as in the previous program), but it also builds them outward into unbounded space. Use the involute checkbox to choose one or the other. 1 When involute is checked, decrease the opacity to see into the fractal.

Second, our previous program retains only one level set at time. Here, we choose to relax this so that all the level sets are retained in the scene graph at once.

Polyhedral snowflakes

The function makePolyhedralSnowflake gets called with the geometry of the current polyhedron. The geometry gets passed through the recursive calls so that it can be shared by every polyhedron. The global array materials is used to assign each level set its own color.

function makePolyhedralSnowflake(level, scale, geom, involute) {
    let fractal = new THREE.Mesh(geom, materials[level]);
    if (level > 0) {
        let root = new THREE.Object3D();
        fractal.add(root);
        root.scale.set(scale, scale, scale);
        let tf;
        if (!involute) tf = (1 + scale) / scale;
        else tf =  (1 - scale) / scale;
        for (let v of geom.vertices) {
            let root2 = new THREE.Object3D();
            let v2 = v.clone().multiplyScalar(tf);
            root2.position.set(v2.x, v2.y, v2.z);
            root2.add(makePolyhedralSnowflake(level-1, scale, geom, involute));
            root.add(root2);
        }
    }
    return fractal;
}

  1. Word has it that introverts prefer involutes and extraverts prefer exvolutes.