threejs-worldgen
    Preparing search index...

    Function poissonDisk

    • Seamless, deterministic Poisson-disk (blue-noise) points inside the square tile [x0, x0 + size) × [z0, z0 + size).

      Every point is at least spacing from every other point, including points of neighbouring tiles, and a tile's points never depend on which other tiles were generated or in which order:

      1. A global grid of cells (size spacing / 2) each holds one candidate, jittered and given a random priority by hashing the cell's integer coordinates with seed.
      2. In each of a few rounds, a candidate survives if no other live candidate within spacing has a higher priority (a Matérn type-II hard-core process); survivors are accepted and remove their neighbours. Repeating the round on the leftovers fills most gaps, approaching random sequential packing.
      3. Whether a candidate is accepted after k rounds depends only on candidates within (2k + 1) · spacing, so the tile evaluates that margin around itself and keeps only its own points. Tiles therefore stitch exactly.

      Parameters

      • x0: number
      • z0: number
      • size: number
      • spacing: number
      • seed: number

      Returns Float32Array

      Interleaved [x, z, random] triples; random is a stable per-point number in [0, 1).