Skip to content

Commit 81c1ba2

Browse files
fix: initialize heights array if not already set in HeightmapGenerator (#1277)
1 parent b228a8f commit 81c1ba2

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/modules/heightmap-generator.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,7 @@ class HeightmapGenerator {
560560
if(!ctx) {
561561
throw new Error("Could not get canvas context");
562562
}
563-
if(!this.heights) {
564-
throw new Error("Heights array is not initialized");
565-
}
563+
this.heights = this.heights || new Uint8Array(cellsX * cellsY);
566564
ctx.drawImage(img, 0, 0, cellsX, cellsY);
567565
const imageData = ctx.getImageData(0, 0, cellsX, cellsY);
568566
this.setGraph(graph);

src/utils/stringUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { rn } from "./numberUtils";
66
* @param {number} decimals - Number of decimal places (default is 1)
77
* @returns {string} - The string with rounded numbers
88
*/
9-
export const round = (inputString: string, decimals: number = 1) => {
9+
export const round = (inputString: string = "", decimals: number = 1) => {
1010
return inputString.replace(/[\d\.-][\d\.e-]*/g, (n: string) => {
1111
return rn(parseFloat(n), decimals).toString();
1212
});

0 commit comments

Comments
 (0)