random function
Generates a random vector with the given scale
@param {vec3} out the receiving vector
@param {Number} scale
Length of the resulting vector. If omitted, a unit vector will be returned
@returns {vec3} out
Implementation
List<double> random(List<double> out, double? scale) {
scale ??= 1.0;
final r = GlMatrix.random() * 2.0 * math.pi;
final z = GlMatrix.random() * 2.0 - 1.0;
final zScale = math.sqrt(1.0 - z * z) * scale;
out[0] = math.cos(r) * zScale;
out[1] = math.sin(r) * zScale;
out[2] = z * scale;
return out;
}