function initialize()

in src/Layer/NativeMetaballs/NativeMetaballs.js [42:100]


    function initialize(target, width, height) {

      canvas = target;
      canvas.width = width;
      canvas.height = height;
      canvas.className = 'layer';

      const glConfig = {
        premultipliedAlpha: true,
        antialias: true,
        depth: true,
        alpha: true
      };

      gl = canvas.getContext('webgl', glConfig) || canvas.getContext('experimental-webgl', glConfig);
      gl.getExtension('OES_standard_derivatives');

      if (!gl) {
        console.error('cannot find gl', gl);
        return;
      }

      displayWidth = Math.floor(gl.canvas.clientWidth);
      displayHeight = Math.floor(gl.canvas.clientHeight);
      var scale = displayHeight / model.atHeight;

      const groups = model.groups.map(
        group => ({
          metaballs: group.balls.map(
            ball => ({
              center: {
                x: ball.x,
                y: ball.y
              },
              offset: group.origin,
              radius: ball.r,
              speed: ball.speed / 300,
              t: ball.phase,
              arcMult: { x: ball.ax / 15, y: ball.ay / 15 }
            })
          ),
          texture: generateGradientTexture(
            group.gradient.stops.map( stop => ({ color: stop.color, stop: stop.pos })),
            group.gradient.orientation === "vertical",
            false
          )
        })
      );

      groups.map(function (group) {
        createdMetaballs.push(new Metaballs(gl, group, scale));
      });

      target.addEventListener('mousemove', onMouseMove);

      resizeGL(gl);

      requestAnimationFrame(step);
    }