randiny
Version:
<h1 style="margin-bottom: 0">Randiny</h1> <h2 style="font-size: 14px; margin-top: 0">A pseudo random number generator, capable of generating random numbers, and noise maps.</h2>
61 lines • 2.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PerlinMap3D = exports.PerlinMap2D = exports.PerlinMap1D = void 0;
class PerlinMap1D {
constructor(rng, length, options) {
const { frequency = 0.01, octaves = 4, lacunarity = 2, gain = 0.5 } = options !== null && options !== void 0 ? options : {};
this.map = Array.from({ length }, (_, x) => rng.fbm1D(x, octaves, frequency, lacunarity, gain));
}
get(index) {
return this.map[index];
}
getRange(start, end) {
return this.map.slice(start, end + 1);
}
getFullMap() {
return this.map;
}
}
exports.PerlinMap1D = PerlinMap1D;
class PerlinMap2D {
constructor(rng, width, height, options) {
const { frequency = 0.01, octaves = 4, lacunarity = 2, gain = 0.5 } = options !== null && options !== void 0 ? options : {};
this.map = Array.from({ length: height }, (_, y) => Array.from({ length: width }, (_, x) => rng.fbm2D(x, y, octaves, frequency, lacunarity, gain)));
}
get(x, y) {
return this.map[y][x];
}
getRow(y) {
return this.map[y];
}
getCol(x) {
return this.map.map(row => row[x]);
}
getFullMap() {
return this.map;
}
}
exports.PerlinMap2D = PerlinMap2D;
class PerlinMap3D {
constructor(rng, width, height, depth, options) {
const { frequency = 0.01, octaves = 4, lacunarity = 2, gain = 0.5 } = options !== null && options !== void 0 ? options : {};
this.map = Array.from({ length: height }, (_, y) => Array.from({ length: width }, (_, x) => Array.from({ length: depth }, (_, z) => rng.fbm3D(x, y, z, octaves, frequency, lacunarity, gain))));
}
get(x, y, z) {
return this.map[y][x][z];
}
getRow(y) {
return this.map[y];
}
getCol(x) {
return this.map.map(row => row[x]);
}
getDepths(x, y) {
return this.map[y][x];
}
getFullMap() {
return this.map;
}
}
exports.PerlinMap3D = PerlinMap3D;
//# sourceMappingURL=PerlinMap.js.map