height generation - ability to pass cells number

This commit is contained in:
Azgaar 2022-05-29 14:33:07 +03:00
parent ab160e609c
commit 4f372c7a46
3 changed files with 66 additions and 42 deletions

View file

@ -282,10 +282,14 @@ function drawHeights(heights) {
}
function generateHeightmap(id) {
HeightmapGenerator.resetHeights();
const heights = HeightmapGenerator.fromTemplate(id);
const heights = new Uint8Array(grid.points.length);
// use cells number of the current graph, no matter what UI input value is
const cellsDesired = rn((graphWidth * graphHeight) / grid.spacing ** 2, -3);
HeightmapGenerator.setHeights(heights, cellsDesired);
const newHeights = HeightmapGenerator.fromTemplate(id);
HeightmapGenerator.cleanup();
return heights;
return newHeights;
}
function drawTemplatePreview(id) {