@osbjs/math
Version:
math helper
29 lines (28 loc) • 982 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.randFloat = exports.randInt = exports.noise4D = exports.noise3D = exports.noise2D = void 0;
const simplex_noise_1 = __importDefault(require("simplex-noise"));
const simplex = new simplex_noise_1.default('177013');
function noise2D(x, y) {
return simplex.noise2D(x, y);
}
exports.noise2D = noise2D;
function noise3D(x, y, z) {
return simplex.noise3D(x, y, z);
}
exports.noise3D = noise3D;
function noise4D(x, y, z, w) {
return simplex.noise4D(x, y, z, w);
}
exports.noise4D = noise4D;
function randInt(low, high) {
return low + Math.floor(Math.random() * (high - low + 1));
}
exports.randInt = randInt;
function randFloat(low, high) {
return low + Math.random() * (high - low);
}
exports.randFloat = randFloat;