Parcourir la source

Fix auto-size showing the wrong units for the scale

tags/v0.1.0
Fen Dweller il y a 6 ans
Parent
révision
50ae84b4fd
1 fichiers modifiés avec 4 ajouts et 3 suppressions
  1. +4
    -3
      macrovision.js

+ 4
- 3
macrovision.js Voir le fichier

@@ -727,6 +727,7 @@ document.addEventListener("DOMContentLoaded", () => {
}) })


document.querySelector("#options-height-unit").addEventListener("input", e => { document.querySelector("#options-height-unit").addEventListener("input", e => {
checkFitWorld();
updateWorldHeight(); updateWorldHeight();
}) })


@@ -925,7 +926,7 @@ function checkFitWorld() {
} }
} }
function fitWorld() { function fitWorld() {
let max = math.unit(0, "meter");
let max = math.unit(0, "meters");


Object.entries(entities).forEach(([key, entity]) => { Object.entries(entities).forEach(([key, entity]) => {
const view = document.querySelector("#entity-" + key).dataset.view; const view = document.querySelector("#entity-" + key).dataset.view;
@@ -937,15 +938,15 @@ function fitWorld() {
} }


function updateWorldHeight() { function updateWorldHeight() {
const value = Math.max(1, document.querySelector("#options-height-value").value);
const unit = document.querySelector("#options-height-unit").value; const unit = document.querySelector("#options-height-unit").value;
const value = Math.max(0.000000001, document.querySelector("#options-height-value").value);
const oldHeight = config.height; const oldHeight = config.height;


setWorldHeight(oldHeight, math.unit(value, unit)); setWorldHeight(oldHeight, math.unit(value, unit));
} }


function setWorldHeight(oldHeight, newHeight) { function setWorldHeight(oldHeight, newHeight) {
config.height = newHeight;
config.height = newHeight.to(document.querySelector("#options-height-unit").value)


const unit = document.querySelector("#options-height-unit").value; const unit = document.querySelector("#options-height-unit").value;
document.querySelector("#options-height-value").value = config.height.toNumber(unit); document.querySelector("#options-height-value").value = config.height.toNumber(unit);


Chargement…
Annuler
Enregistrer