phaser/v3/src/math/RandomXYZW.js

26 lines
620 B
JavaScript
Raw Normal View History

2017-10-06 03:52:41 +00:00
/**
* [description]
*
* @function Phaser.Math.RandomXYZW
* @since 3.0.0
*
* @param {Phaser.Math.Vector4} vec4 - [description]
* @param {float} [scale=1] - [description]
*
* @return {Phaser.Math.Vector4} [description]
*/
var RandomXYZW = function (vec4, scale)
{
if (scale === undefined) { scale = 1; }
// Not spherical; should fix this for more uniform distribution
2017-10-06 03:52:41 +00:00
vec4.x = (Math.random() * 2 - 1) * scale;
vec4.y = (Math.random() * 2 - 1) * scale;
vec4.z = (Math.random() * 2 - 1) * scale;
vec4.w = (Math.random() * 2 - 1) * scale;
2017-10-06 03:52:41 +00:00
return vec4;
};
module.exports = RandomXYZW;