Skip to content

Commit

Permalink
fix RandomGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
KilledByAPixel committed Apr 16, 2024
1 parent ec1907e commit de0f9da
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/engineUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ function randColor(colorA=new Color, colorB=new Color(0,0,0,1), linear)
* - Can be used to create a deterministic random number sequence
* @example
* let r = new RandomGenerator(123); // random number generator with seed 123
* let a = r.rand(); // random value between 0 and 1
* let b = r.randInt(10); // random integer between 0 and 9
* let a = r.float(); // random value between 0 and 1
* let b = r.int(10); // random integer between 0 and 9
* r.seed = 123; // reset the seed
* let c = r.rand(); // the same value as a
* let c = r.float(); // the same value as a
*/
class RandomGenerator
{
Expand Down Expand Up @@ -237,11 +237,11 @@ class RandomGenerator
* @param {Number} valueA
* @param {Number} [valueB=0]
* @return {Number} */
int(valueA, valueB=0) { return Math.floor(this.rand(valueA, valueB)); }
int(valueA, valueB=0) { return Math.floor(this.float(valueA, valueB)); }

/** Randomly returns either -1 or 1 deterministically
* @return {Number} */
sign() { return this.randInt(2) * 2 - 1; }
sign() { return this.int(2) * 2 - 1; }
}

///////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit de0f9da

Please sign in to comment.