|
|
|
@@ -566,6 +566,7 @@ function updateEntityElement(entity, element) { |
|
|
|
} else { |
|
|
|
topName.classList.remove("top-name-needed"); |
|
|
|
} |
|
|
|
updateRatios(); |
|
|
|
} |
|
|
|
|
|
|
|
let ratioInfo |
|
|
|
@@ -607,15 +608,35 @@ function updateRatios() { |
|
|
|
|
|
|
|
if (config.showHorizon) { |
|
|
|
if (selectedEntity !== null) { |
|
|
|
const y = document.querySelector("#entity-" + selectedEntity.index).dataset.y; |
|
|
|
const R = math.unit(1.27560e+7, "meters") |
|
|
|
const h = selectedEntity.currentView.height |
|
|
|
const h = math.add(selectedEntity.currentView.height, math.unit(y, "meters")) |
|
|
|
|
|
|
|
const first = math.multiply(2, math.multiply(R, h)) |
|
|
|
const second = math.multiply(h, h) |
|
|
|
|
|
|
|
const sightline = math.sqrt(math.add(first, second)).to(config.height.units[0].unit.name) |
|
|
|
|
|
|
|
text += selectedEntity.name + " could see for " + math.format(sightline, { precision: 3 }) |
|
|
|
text += selectedEntity.name + " could see for " + math.format(sightline, { precision: 3 }) + "\n" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (config.showRatios && config.showHorizon) { |
|
|
|
if (selectedEntity !== null && prevSelectedEntity !== null && selectedEntity !== prevSelectedEntity) { |
|
|
|
const y1 = document.querySelector("#entity-" + selectedEntity.index).dataset.y; |
|
|
|
const y2 = document.querySelector("#entity-" + prevSelectedEntity.index).dataset.y; |
|
|
|
const R = math.unit(1.27560e+7, "meters") |
|
|
|
const R2 = math.subtract(math.subtract(R, prevSelectedEntity.currentView.height), math.unit(y2, "meters")) |
|
|
|
const h = math.add(selectedEntity.currentView.height, math.unit(y1, "meters")) |
|
|
|
|
|
|
|
console.log(R, R2, h) |
|
|
|
|
|
|
|
const first = math.pow(math.add(R, h), 2) |
|
|
|
const second = math.pow(R2, 2) |
|
|
|
|
|
|
|
const sightline = math.sqrt(math.subtract(first, second)).to(config.height.units[0].unit.name) |
|
|
|
|
|
|
|
text += selectedEntity.name + " could see " + prevSelectedEntity.name + " from " + math.format(sightline, { precision: 3 }) + " away\n" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@@ -2219,6 +2240,9 @@ function removeEntity(element) { |
|
|
|
topName.parentElement.removeChild(topName); |
|
|
|
element.parentElement.removeChild(element); |
|
|
|
|
|
|
|
selectedEntity = null; |
|
|
|
prevSelectedEntity = null; |
|
|
|
updateRatios(); |
|
|
|
} |
|
|
|
|
|
|
|
function checkEntity(entity) { |
|
|
|
|