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>
46 lines • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SimplexMap3D = exports.SimplexMap2D = void 0;
const SimplexNoise_1 = require("./SimplexNoise");
class SimplexMap2D {
constructor(rng, width, height) {
const noise = (0, SimplexNoise_1.createNoise2D)(rng);
this.map = new Array(height).fill(new Array(width).fill(0)).map((e, y) => e.map((_, x) => noise(x, y)));
}
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.SimplexMap2D = SimplexMap2D;
class SimplexMap3D {
constructor(rng, width, height, depth) {
const noise = (0, SimplexNoise_1.createNoise3D)(rng);
this.map = new Array(height).fill(new Array(width).fill(new Array(depth).fill(0))).map((e, y) => e.map((e2, x) => e2.map((_, z) => noise(x, y, z))));
}
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.SimplexMap3D = SimplexMap3D;
//# sourceMappingURL=SimplexMap.js.map