From d1e40b62776ffd44e7ce113c3df798150cb2b873 Mon Sep 17 00:00:00 2001 From: StempunkDev Date: Wed, 14 Jan 2026 21:23:03 +0100 Subject: [PATCH] refactor: streamline ice generation process and clean up rendering functions --- public/main.js | 1 - public/modules/ice.js | 13 ++++--------- public/modules/renderers/draw-ice.js | 27 ++++++--------------------- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/public/main.js b/public/main.js index 16f0b302..7dbb9585 100644 --- a/public/main.js +++ b/public/main.js @@ -632,7 +632,6 @@ async function generate(options) { Biomes.define(); Features.defineGroups(); - Ice.initialize(); Ice.generate(); rankCells(); diff --git a/public/modules/ice.js b/public/modules/ice.js index 31e98232..d3d7ab36 100644 --- a/public/modules/ice.js +++ b/public/modules/ice.js @@ -12,9 +12,9 @@ window.Ice = (function () { // Generate glaciers and icebergs based on temperature and height function generate() { - clear(); - const {cells, features} = grid; - const {temp, h} = cells; + initialize(); + const { cells, features } = grid; + const { temp, h } = cells; Math.random = aleaPRNG(seed); const ICEBERG_MAX_TEMP = 0; @@ -26,7 +26,7 @@ window.Ice = (function () { const type = "iceShield"; const getType = cellId => h[cellId] >= 20 && temp[cellId] <= GLACIER_MAX_TEMP ? type : null; - const isolines = getIsolines(grid, getType, {polygons: true}); + const isolines = getIsolines(grid, getType, { polygons: true }); if (isolines[type]?.polygons) { isolines[type].polygons.forEach(points => { @@ -148,10 +148,6 @@ window.Ice = (function () { iceberg.size = newSize; } - function getData() { - return pack.ice; - } - // Clear all ice function clear() { pack.ice.glaciers = []; @@ -166,7 +162,6 @@ window.Ice = (function () { updateIceberg, randomizeIcebergShape, changeIcebergSize, - getData, clear }; })(); diff --git a/public/modules/renderers/draw-ice.js b/public/modules/renderers/draw-ice.js index 2598e77d..cf946af6 100644 --- a/public/modules/renderers/draw-ice.js +++ b/public/modules/renderers/draw-ice.js @@ -22,14 +22,6 @@ function drawIce() { ice.html(html); TIME && console.timeEnd("drawIce"); - - function getGlacierHtml(glacier, index) { - return ``; - } - - function getIcebergHtml(iceberg, index) { - return ``; - } } function redrawIceberg(index) { @@ -46,15 +38,9 @@ function redrawIceberg(index) { el = ice.selectAll(`.iceberg[data-index="${index}"]`); } el.attr("points", iceberg.points); - el.attr("size", iceberg.size); - el.attr("cell", iceberg.cellId); el.attr("transform", iceberg.offset ? `translate(${iceberg.offset[0]},${iceberg.offset[1]})` : null); } TIME && console.timeEnd("redrawIceberg"); - - function getIcebergHtml(iceberg, index) { - return ``; - } } function redrawGlacier(index) { @@ -74,13 +60,12 @@ function redrawGlacier(index) { el.attr("transform", glacier.offset ? `translate(${glacier.offset[0]},${glacier.offset[1]})` : null); } TIME && console.timeEnd("redrawGlacier"); - - function getGlacierHtml(glacier, index) { - return ``; - } } -// Re-render ice layer from data model -function redrawIce() { - drawIce(); +function getGlacierHtml(glacier, index) { + return ``; } + +function getIcebergHtml(iceberg, index) { + return ``; +} \ No newline at end of file