Init world position on page load

This commit is contained in:
Wuzzy 2024-11-30 15:02:00 +01:00
parent 7e978ce417
commit b7423c152b

View File

@ -63,6 +63,13 @@ const ONE_CLICK_DRAG_DROP_DISTANCE = 30
// Name to display if empty
const FALLBACK_NAME = "(no name)"
// Name of the default / initial biome
const DEFAULT_BIOME_NAME = "default"
// Default heat and humidity values
const DEFAULT_HEAT = 50
const DEFAULT_HUMIDITY = 50
// Symbol for storing the biome ID in site objects
// for the Voronoi script
const biomeIDSymbol = Symbol("Biome ID");
@ -312,7 +319,7 @@ function addBiomeRaw(biomeDef) {
}
// Add a default biome at the midpoint
addBiomeRaw({name: "default", heat: midpoint_heat, humidity: midpoint_humidity, min_x: MIN_X, max_x: MAX_X, min_y: MIN_Y, max_y: MAX_Y, min_z: MIN_Z, max_z: MAX_Z});
addBiomeRaw({name: DEFAULT_BIOME_NAME, heat: midpoint_heat, humidity: midpoint_humidity, min_x: MIN_X, max_x: MAX_X, min_y: MIN_Y, max_y: MAX_Y, min_z: MIN_Z, max_z: MAX_Z});
// Add a new random biome to the biome list with the given biome definition.
// Then select it and update widgets
@ -2217,7 +2224,7 @@ for (let n of noiseWidgetTable) {
}
n.elem.onblur = function() {
let noiseElem = n.noise + "_" + biomeMode;
let defaultValue = n["default_" + biomeMode];
let defaultValue = n[DEFAULT_BIOME_NAME + "_" + biomeMode];
blurNoiseParam(n.noise, n.noise_param, this, defaultValue);
}
}
@ -2562,9 +2569,29 @@ function disableFormSubmission() {
}
}
function initViewCoords() {
viewX = inputViewX.value;
viewY = inputViewY.value;
viewZ = inputViewZ.value;
}
function resetBiomeInputs() {
inputMinX.value = MIN_X;
inputMaxX.value = MAX_X;
inputMinY.value = MIN_Y;
inputMaxY.value = MAX_Y;
inputMinZ.value = MIN_Z;
inputMaxZ.value = MAX_Z;
inputHeat.value = DEFAULT_HEAT;
inputHumidity.value = DEFAULT_HUMIDITY;
inputBiomeName.value = DEFAULT_BIOME_NAME;
}
/* Load events */
window.addEventListener("load", initBiomeColorSelectors);
window.addEventListener("load", initViewCoords);
window.addEventListener("load", resetBiomeInputs);
window.addEventListener("load", checkboxVarsInit);
window.addEventListener("load", function() {
draw(true);