Class
Noise
View sourceProvides stateless deterministic noise sampling for repeatable procedural values.
A fixed seed makes samples reproducible: repeating the same numeric inputs returns the same result, while changing the sampled input or seed selects a different deterministic value.
Examples
const seed = 17
const first = Noise.get1D(12, seed)
const repeat = Noise.get1D(12, seed)
// first === repeatConstructor
Methods
staticget1D(value: number, seed: number): number
View sourceReturns a deterministic pseudo-random value for one numeric input.
value and seed are added before JavaScript’s bitwise operations
coerce the sum to a signed 32-bit integer. The resulting integer is mixed
with a fixed polynomial hash, and its low 31 bits are mapped to a value
from -1 (exclusive) through 1. Fractional inputs therefore affect the
result only through the integer produced by that bitwise coercion.
The function does not keep state: changing either argument changes the deterministic sample when their summed 32-bit input changes. Different arguments can collide when they produce the same coerced integer, while repeating both arguments always returns the same number.
Examples
const sample = Noise.get1D(12, 17)
// sample === -0.4473929377272725staticget2D(x: number, y: number, seed: number): number
View sourceReturns deterministic noise sampled from a two-dimensional coordinate.
The coordinate is split into its floored cell (intX, intY) and its
fractional offsets (tx, ty). Four cell corners are sampled with
Noise.get1D using the same seed and the integer sums
intX + intY, intX + 1 + intY, intX + intY + 1, and
intX + 1 + intY + 1. The first pair is blended with tx, the second pair
with ty, and those two results are blended with ty again. All three
blends use Interpolation.cosine.
Flooring makes negative coordinates sample the expected lower cell, so a
coordinate such as -0.25 uses cell -1 with a fractional offset of
0.75. The function is stateless and returns the same value for the same
coordinate and seed.
Examples
const sample = Noise.get2D(2.25, 3.75, 17)
// sample === -0.4253525422191263