@pixi/3d
    Preparing search index...

    Function seededRandom

    • Creates a random function that returns the same sequence of numbers in [0, 1) for the same seed

      Use it wherever Math.random would go when results must repeat, such as a level generated from a shared seed or a replay. It runs mulberry32, seeded by hashing the string with xmur3, and isn't safe for cryptography.

      Parameters

      • seed: string

        Any string; the same string always gives the same sequence

      Returns () => number

      Function that can be used in place of Math.random

      const random = seededRandom(`level-${levelNumber}`);

      for (const slot of treeSlots) {
      if (random() < 0.3) plantTree(slot, 0.8 + random() * 0.4);
      }