mirror of
https://github.com/photonstorm/phaser
synced 2024-12-20 10:03:50 +00:00
25 lines
620 B
JavaScript
25 lines
620 B
JavaScript
/**
|
|
* [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
|
|
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;
|
|
|
|
return vec4;
|
|
};
|
|
|
|
module.exports = RandomXYZW;
|