randomDirection method
Implementation
Vector3 randomDirection() {
// Derived from https://mathworld.wolfram.com/SpherePointPicking.html
final u = (math.Random().nextDouble() - 0.5) * 2;
final t = math.Random().nextDouble() * math.pi * 2;
final f = math.sqrt(1 - u * u);
x = f * math.cos(t);
y = f * math.sin(t);
z = u;
return this;
}