mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 20:11:24 +01:00
heightmap selection - refactor, make generation immutable to get predictable result
This commit is contained in:
parent
8ea89111fc
commit
b6a1012753
4 changed files with 18 additions and 4 deletions
|
|
@ -96,3 +96,19 @@ function deepCopy(obj) {
|
|||
|
||||
return dcAny(obj);
|
||||
}
|
||||
|
||||
function getTypedArray(maxValue) {
|
||||
console.assert(
|
||||
Number.isInteger(maxValue) && maxValue >= 0 && maxValue <= 4294967295,
|
||||
`Array maxValue must be an integer between 0 and 4294967295, got ${maxValue}`
|
||||
);
|
||||
|
||||
if (maxValue <= 255) return Uint8Array;
|
||||
if (maxValue <= 65535) return Uint16Array;
|
||||
if (maxValue <= 4294967295) return Uint32Array;
|
||||
return Uint32Array;
|
||||
}
|
||||
|
||||
function createTypedArray({maxValue, length}) {
|
||||
return new (getTypedArray(maxValue))(length);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue