util_noise_noise_process.js
/**
* @module NoiseProcess
* @fileoverview Contains NoiseProcess class.
*/
/**
* @class
* Single process for manipulating noise inputs and outputs.
*/
class NoiseProcess {
/**
* Create a new noise process.
* @param {function} func Function to manipulate data with
* @param {Object.<string: number, string: number, string: number>} data Data from noise
* @constructor
*/
constructor(func = (x, y, val) => { return {x: x, y: y, val: val}; },
data = {}) {
this.func = func;
this.data = data;
}
/**
* Execute the noise process on data.
* @param {number} x Value of x position (input)
* @param {number} y Value of y position (input)
* @param {number} val Height value (output)
* @returns {Object.<string: number, string: number, string: number>} Resulting manipulated data
*/
do(x, y, val) {
return this.func(x, y, val, this.data);
}
}
export default NoiseProcess;