From de0f9dac2e678e5df21915ae0bcc07404f3f9fb9 Mon Sep 17 00:00:00 2001 From: Frank Force Date: Tue, 16 Apr 2024 15:06:19 -0500 Subject: [PATCH] fix RandomGenerator --- src/engineUtilities.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/engineUtilities.js b/src/engineUtilities.js index f56b3941..d4859a83 100644 --- a/src/engineUtilities.js +++ b/src/engineUtilities.js @@ -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 { @@ -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; } } ///////////////////////////////////////////////////////////////////////////////