|
|
@@ -1335,7 +1335,18 @@ function configEntityOptions(entity, view) { |
|
|
scaleInput.id = "options-entity-scale"; |
|
|
scaleInput.id = "options-entity-scale"; |
|
|
|
|
|
|
|
|
scaleInput.addEventListener("change", e => { |
|
|
scaleInput.addEventListener("change", e => { |
|
|
entity.scale = e.target.value == 0 ? 1 : e.target.value; |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
const newScale = e.target.value == 0 ? 1 : math.evaluate(e.target.value); |
|
|
|
|
|
if (typeof(newScale) !== "number") { |
|
|
|
|
|
toast("Invalid input: scale can't have any units!") |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
entity.scale = newScale; |
|
|
|
|
|
} catch { |
|
|
|
|
|
toast("Invalid input: could not parse " + e.target.value) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entity.dirty = true; |
|
|
entity.dirty = true; |
|
|
if (config.autoFit) { |
|
|
if (config.autoFit) { |
|
|
fitWorld(); |
|
|
fitWorld(); |
|
|
@@ -1350,9 +1361,6 @@ function configEntityOptions(entity, view) { |
|
|
e.stopPropagation(); |
|
|
e.stopPropagation(); |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
scaleInput.setAttribute("min", 1); |
|
|
|
|
|
scaleInput.setAttribute("type", "number"); |
|
|
|
|
|
scaleInput.setAttribute("step", "any"); |
|
|
|
|
|
setNumericInput(scaleInput, entity.scale); |
|
|
setNumericInput(scaleInput, entity.scale); |
|
|
|
|
|
|
|
|
scaleRow.appendChild(scaleInput); |
|
|
scaleRow.appendChild(scaleInput); |
|
|
@@ -1464,9 +1472,6 @@ function configViewOptions(entity, view) { |
|
|
const input = document.createElement("input"); |
|
|
const input = document.createElement("input"); |
|
|
input.classList.add("options-field-numeric"); |
|
|
input.classList.add("options-field-numeric"); |
|
|
input.id = "options-view-" + key + "-input"; |
|
|
input.id = "options-view-" + key + "-input"; |
|
|
input.setAttribute("type", "number"); |
|
|
|
|
|
input.setAttribute("step", "any"); |
|
|
|
|
|
input.setAttribute("min", 1); |
|
|
|
|
|
|
|
|
|
|
|
const select = document.createElement("select"); |
|
|
const select = document.createElement("select"); |
|
|
select.classList.add("options-field-unit"); |
|
|
select.classList.add("options-field-unit"); |
|
|
@@ -1488,7 +1493,26 @@ function configViewOptions(entity, view) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
input.addEventListener("change", e => { |
|
|
input.addEventListener("change", e => { |
|
|
const value = input.value == 0 ? 1 : input.value; |
|
|
|
|
|
|
|
|
const raw_value = input.value == 0 ? 1 : input.value; |
|
|
|
|
|
let value |
|
|
|
|
|
try { |
|
|
|
|
|
value = math.evaluate(raw_value).toNumber(select.value); |
|
|
|
|
|
} catch { |
|
|
|
|
|
try { |
|
|
|
|
|
value = math.evaluate(input.value) |
|
|
|
|
|
if (typeof(value) !== "number") { |
|
|
|
|
|
toast("Invalid input: " + value.format() + " can't convert to " + select.value) |
|
|
|
|
|
value = undefined |
|
|
|
|
|
} |
|
|
|
|
|
} catch { |
|
|
|
|
|
toast("Invalid input: could not parse: " + input.value) |
|
|
|
|
|
value = undefined |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (value === undefined) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
input.value = value |
|
|
entity.views[view][key] = math.unit(value, select.value); |
|
|
entity.views[view][key] = math.unit(value, select.value); |
|
|
entity.dirty = true; |
|
|
entity.dirty = true; |
|
|
if (config.autoFit) { |
|
|
if (config.autoFit) { |
|
|
@@ -4031,13 +4055,29 @@ function fitEntities(targetEntities, manual = false, factor = 1.1) { |
|
|
setWorldHeight(config.height, math.multiply(height, factor)); |
|
|
setWorldHeight(config.height, math.multiply(height, factor)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// TODO why am I doing this |
|
|
|
|
|
function updateWorldHeight() { |
|
|
function updateWorldHeight() { |
|
|
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 rawValue = document.querySelector("#options-height-value").value; |
|
|
|
|
|
|
|
|
|
|
|
var value |
|
|
|
|
|
try { |
|
|
|
|
|
value = math.evaluate(rawValue) |
|
|
|
|
|
if (typeof(value) !== "number") { |
|
|
|
|
|
try { |
|
|
|
|
|
value = value.toNumber(unit) |
|
|
|
|
|
} catch { |
|
|
|
|
|
toast("Invalid input: " + rawValue + " can't be converted to " + unit) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} catch { |
|
|
|
|
|
toast("Invalid input: could not parse " + rawValue) |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const newHeight = Math.max(0.000000001, value); |
|
|
const oldHeight = config.height; |
|
|
const oldHeight = config.height; |
|
|
|
|
|
|
|
|
setWorldHeight(oldHeight, math.unit(value, unit)); |
|
|
|
|
|
|
|
|
setWorldHeight(oldHeight, math.unit(newHeight, unit)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function setWorldHeight(oldHeight, newHeight) { |
|
|
function setWorldHeight(oldHeight, newHeight) { |
|
|
|