tessellated icosahedron with a texture

processing.js

by Darby Rathbone

HTML

<canvas id="canvas1"></canvas>

JavaScript

// this code was autogenerated from PJS
var sketchProc = (function ($p) {
    var VertexNode = (function () {
        function VertexNode() {
            var $this_1 = this;

            function $superCstr() {
                $p.extendClassChain($this_1);
            }
            $this_1.x = 0;
            $this_1.y = 0;
            $this_1.z = 0;
            $this_1.u = 0;
            $this_1.v = 0;

            function normalize$0() {
                var a = 0;
                a = $p.abs($p.sqrt($p.sq($this_1.x) + $p.sq($this_1.y) + $p.sq($this_1.z)));
                $this_1.x /= a;
                $this_1.y /= a;
                $this_1.z /= a;
            }
            $p.addMethod($this_1, 'normalize', normalize$0);

            function mult$1(a) {
                $this_1.x *= a;
                $this_1.y *= a;
                $this_1.z *= a;
            }
            $p.addMethod($this_1, 'mult', mult$1);

            function $constr_5(x, y, z, u, v) {
                $superCstr();

                $this_1.x = x;
                $this_1.y = y;
                $this_1.z = z;
                $this_1.u = u;
                $this_1.v = v;
            }

            function $constr() {
                if (arguments.length === 5) {
                    $constr_5.apply($this_1, arguments);
                } else $superCstr();
            }
            $constr.apply(null, arguments);
        }
        return VertexNode;
    })();
    $p.VertexNode = VertexNode;

    var ImageArrayList_ball = new $p.ArrayList();
    var pImage = null;
    var pGraphics = null;
    var ax = 0,
        ay = 0;

    var nodeArrayList = new $p.ArrayList();

    function setup() {
        $p.size(500, 500, $p.OPENGL);
        ax = 0;
        ay = 0;
        pGraphics = $p.createGraphics(200, 100);
        pGraphics.beginDraw();
        pGraphics.background(0xFFFAEE05);
        pGraphics.textAlign($p.CENTER);
        pGraphics.fill(255);
        pGraphics.ellipse(pGraphics.height /...