| @@ -406,6 +406,10 @@ function drawScale(ifDirty = false) { | |||||
| pixelsPer /= factor; | pixelsPer /= factor; | ||||
| } | } | ||||
| if (heightPer == 0) { | |||||
| console.error("The world size is invalid! Refusing to draw the scale..."); | |||||
| return; | |||||
| } | |||||
| heightPer = math.unit(heightPer, document.querySelector("#options-height-unit").value); | heightPer = math.unit(heightPer, document.querySelector("#options-height-unit").value); | ||||
| @@ -1044,7 +1048,6 @@ function arrangeEntities(order) { | |||||
| fitWorld(); | fitWorld(); | ||||
| const worldWidth = config.height.toNumber("meters") / canvasHeight * canvasWidth; | const worldWidth = config.height.toNumber("meters") / canvasHeight * canvasWidth; | ||||
| let x = -worldWidth * 0.45 + config.x; | let x = -worldWidth * 0.45 + config.x; | ||||
| console.log(x); | |||||
| order.forEach(key => { | order.forEach(key => { | ||||
| document.querySelector("#entity-" + key).dataset.x = x; | document.querySelector("#entity-" + key).dataset.x = x; | ||||
| document.querySelector("#entity-" + key).dataset.y = config.y; | document.querySelector("#entity-" + key).dataset.y = config.y; | ||||
| @@ -1726,12 +1729,12 @@ function doSize() { | |||||
| if (selected) { | if (selected) { | ||||
| const entity = entities[selected.dataset.key]; | const entity = entities[selected.dataset.key]; | ||||
| const oldHeight = entity.views[entity.view].height; | const oldHeight = entity.views[entity.view].height; | ||||
| entity.views[entity.view].height = math.multiply(oldHeight, 1 + sizeDirection / 20); | |||||
| entity.views[entity.view].height = math.multiply(oldHeight, sizeDirection < 0 ? -1/sizeDirection : sizeDirection); | |||||
| entity.dirty = true; | entity.dirty = true; | ||||
| updateEntityOptions(entity, entity.view); | updateEntityOptions(entity, entity.view); | ||||
| updateViewOptions(entity, entity.view); | updateViewOptions(entity, entity.view); | ||||
| updateSizes(true); | updateSizes(true); | ||||
| sizeDirection *= 1.05; | |||||
| sizeDirection *= 1.01; | |||||
| const ownHeight = entity.views[entity.view].height.toNumber("meters"); | const ownHeight = entity.views[entity.view].height.toNumber("meters"); | ||||
| const worldHeight = config.height.toNumber("meters"); | const worldHeight = config.height.toNumber("meters"); | ||||
| @@ -2862,7 +2865,6 @@ document.addEventListener("mousemove", (e) => { | |||||
| config.y += (e.clientY - panOffsetY) / canvasHeight * worldHeight; | config.y += (e.clientY - panOffsetY) / canvasHeight * worldHeight; | ||||
| panOffsetX = e.clientX; | panOffsetX = e.clientX; | ||||
| panOffsetY = e.clientY; | panOffsetY = e.clientY; | ||||
| console.log(config.x, config.y) | |||||
| updateSizes(); | updateSizes(); | ||||
| panReady = false; | panReady = false; | ||||
| setTimeout(() => panReady=true, 50); | setTimeout(() => panReady=true, 50); | ||||
| @@ -2897,7 +2899,6 @@ document.addEventListener("touchmove", (e) => { | |||||
| config.y += (e.touches[0].clientY - panOffsetY) / canvasHeight * worldHeight; | config.y += (e.touches[0].clientY - panOffsetY) / canvasHeight * worldHeight; | ||||
| panOffsetX = e.touches[0].clientX; | panOffsetX = e.touches[0].clientX; | ||||
| panOffsetY = e.touches[0].clientY; | panOffsetY = e.touches[0].clientY; | ||||
| console.log(config.x, config.y) | |||||
| updateSizes(); | updateSizes(); | ||||
| panReady = false; | panReady = false; | ||||
| setTimeout(() => panReady=true, 50); | setTimeout(() => panReady=true, 50); | ||||
| @@ -2943,10 +2944,6 @@ function fitWorld(manual = false, factor = 1.1) { | |||||
| if (width == 0) { | if (width == 0) { | ||||
| width = height; | width = height; | ||||
| } | } | ||||
| console.log(image) | |||||
| console.log(image.width, image.height) | |||||
| const xBottom = x - entity.views[view].height.toNumber("meters") * width / height / 2; | const xBottom = x - entity.views[view].height.toNumber("meters") * width / height / 2; | ||||
| const xTop = x + entity.views[view].height.toNumber("meters") * width / height / 2; | const xTop = x + entity.views[view].height.toNumber("meters") * width / height / 2; | ||||
| @@ -2965,7 +2962,6 @@ function fitWorld(manual = false, factor = 1.1) { | |||||
| let ySize = (maxY - minY) * factor; | let ySize = (maxY - minY) * factor; | ||||
| let xSize = (maxX - minX) * factor; | let xSize = (maxX - minX) * factor; | ||||
| console.log(xSize, ySize, worldWidth, worldHeight) | |||||
| if (xSize / ySize > worldWidth / worldHeight) { | if (xSize / ySize > worldWidth / worldHeight) { | ||||
| ySize *= ((xSize / ySize) / (worldWidth / worldHeight)); | ySize *= ((xSize / ySize) / (worldWidth / worldHeight)); | ||||
| } | } | ||||