fibDir function
Stable directions on a unit sphere (Fibonacci lattice), written to out.
Implementation
void fibDir(int i, int n, Vec3 out) {
const golden = math.pi * (3 - 2.23606797749979);
final y = 1 - (2 * (i + 0.5)) / n;
final rad = math.sqrt(math.max(0, 1 - y * y));
final a = i * golden;
out
..x = rad * math.cos(a)
..y = y
..z = rad * math.sin(a);
}