var vecNormalize = require('./normalize') var vecScale = require('./scale') module.exports = random /** * Generates a random vector with the given scale * * @param {vec4} out the receiving vector * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned * @returns {vec4} out */ function random (out, scale) { scale = scale || 1.0 // TODO: This is a pretty awful way of doing this. Find something better. out[0] = Math.random() out[1] = Math.random() out[2] = Math.random() out[3] = Math.random() vecNormalize(out, out) vecScale(out, out, scale) return out }