// Native FastNoise (Perlin/fractal) sampler. Ported from worker/src/utils/PerlinNoise.ts.

export class Noise {
  private readonly _id: number

  constructor() {
    this._id = _creator.createNoise()
  }

  /** Sample 2D noise. */
  get(x: number, y: number): number { return _creator.getNoise2D(this._id, x, y) }
  /** Sample 3D noise. */
  get3d(x: number, y: number, z: number): number { return _creator.getNoise3D(this._id, x, y, z) }

  private _frequency = 0.01
  get frequency(): number { return this._frequency }
  set frequency(v: number) { this._frequency = v; _creator.setNoiseFrequency(this._id, v) }

  private _octaves = 1
  get octaves(): number { return this._octaves }
  set octaves(v: number) { this._octaves = v; _creator.setNoiseOctaves(this._id, v) }

  private _fractalLacunarity = 2
  get fractalLacunarity(): number { return this._fractalLacunarity }
  set fractalLacunarity(v: number) { this._fractalLacunarity = v; _creator.setNoiseFractalLunacrity(this._id, v) }

  private _fractalGain = 0.5
  get fractalGain(): number { return this._fractalGain }
  set fractalGain(v: number) { this._fractalGain = v; _creator.setNoiseFractalGain(this._id, v) }
}
