| @@ -114,6 +114,7 @@ const unitChoices = { | |||||
| "humans", | "humans", | ||||
| "stories", | "stories", | ||||
| "miles", | "miles", | ||||
| "earths", | |||||
| "solarradii", | "solarradii", | ||||
| "AUs", | "AUs", | ||||
| "lightyears", | "lightyears", | ||||
| @@ -1166,12 +1167,27 @@ function toggleFullScreen() { | |||||
| } | } | ||||
| function handleResize() { | function handleResize() { | ||||
| const oldEntityX = entityX; | |||||
| entityX = document.querySelector("#entities").getBoundingClientRect().x; | entityX = document.querySelector("#entities").getBoundingClientRect().x; | ||||
| const change = oldEntityX / entityX; | |||||
| doHorizReposition(change); | |||||
| canvasWidth = document.querySelector("#display").clientWidth - 100; | canvasWidth = document.querySelector("#display").clientWidth - 100; | ||||
| canvasHeight = document.querySelector("#display").clientHeight - 50; | canvasHeight = document.querySelector("#display").clientHeight - 50; | ||||
| updateSizes(); | updateSizes(); | ||||
| } | } | ||||
| function doHorizReposition(change) { | |||||
| Object.keys(entities).forEach(key => { | |||||
| const element = document.querySelector("#entity-" + key); | |||||
| const x = element.dataset.x; | |||||
| element.dataset.x = (x - 0.5) * change + 0.5; | |||||
| }); | |||||
| } | |||||
| function prepareMenu() { | function prepareMenu() { | ||||
| const menubar = document.querySelector("#popout-menu"); | const menubar = document.querySelector("#popout-menu"); | ||||
| @@ -2084,6 +2100,8 @@ function exportScene() { | |||||
| unit: unit | unit: unit | ||||
| } | } | ||||
| results.entityX = entityX; | |||||
| return results; | return results; | ||||
| } | } | ||||
| @@ -2160,5 +2178,9 @@ function importScene(data) { | |||||
| config.height = math.unit(data.world.height, data.world.unit); | config.height = math.unit(data.world.height, data.world.unit); | ||||
| document.querySelector("#options-height-unit").value = data.world.unit; | document.querySelector("#options-height-unit").value = data.world.unit; | ||||
| if (data.entityX) { | |||||
| doHorizReposition(data.entityX / entityX); | |||||
| } | |||||
| updateSizes(); | updateSizes(); | ||||
| } | } | ||||