           sc = reflect[0];
          }
        } else if (reflect[0] < 0) {
          gradNdx = 2;
          sc = -reflect[1];
        }
        const ma = Math.max(Math.abs(reflect[0]), Math.abs(reflect[1]));
        const t = 1 - .5 * (sc / ma + 1);

        gradient.addColorStop(u, hsl((gradNdx + t) / 4, 1, .5));
      }
      ctx.fillStyle = gradient;

      // draw surface
      diagram.roundedRect(ctx, surfaceWidth * -0.5, 0, surfaceWidth, 20);

      //var d  = m3.dot(0, 1, Math.sin(direction), Math