heightmap - fix issues

This commit is contained in:
Azgaar 2022-05-24 23:27:06 +03:00
parent 27a045b709
commit ff31e23a27
5 changed files with 60 additions and 44 deletions

View file

@ -136,7 +136,10 @@ function insertEditorHtml() {
const templatesHtml = templates
.map(({id, name}) => {
Math.random = aleaPRNG(seed);
HeightmapGenerator.resetHeights();
const heights = HeightmapGenerator.fromTemplate(id);
HeightmapGenerator.cleanup();
const dataUrl = drawHeights(heights);
return /* html */ `<article data-id="${id}" data-seed="${seed}">
@ -224,7 +227,9 @@ function regeneratePreview(article, id) {
article.dataset.seed = seed;
Math.random = aleaPRNG(seed);
HeightmapGenerator.resetHeights();
const heights = HeightmapGenerator.fromTemplate(id);
HeightmapGenerator.cleanup();
const dataUrl = drawHeights(heights);
article.querySelector("img").src = dataUrl;
}