From 257cf11986794a5098d1b3c51ef7a3a387a25a39 Mon Sep 17 00:00:00 2001 From: evolvedexperiment <55178666+evolvedexperiment@users.noreply.github.com> Date: Mon, 11 Nov 2019 21:53:23 +0200 Subject: [PATCH] Fix for 3d heightmap / 3d view conflict (#360) --- modules/ui/heightmap-editor.js | 7 ++++++- modules/ui/options.js | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/modules/ui/heightmap-editor.js b/modules/ui/heightmap-editor.js index 95a174c6..fb867b7a 100644 --- a/modules/ui/heightmap-editor.js +++ b/modules/ui/heightmap-editor.js @@ -9,7 +9,7 @@ function editHeightmap() {

If you need to change the coastline and keep the data, you may try the risk edit option. The data will be restored as much as possible, but the coastline change can cause unexpected fluctuations and errors.

Check out ${link("https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Heightmap-customization", "wiki")} for guidance.

-

Please save the map before edditing the heightmap!

`; +

Please save the map before editing the heightmap!

`; $("#alert").dialog({resizable: false, title: "Edit Heightmap", width: "28em", buttons: { @@ -43,6 +43,9 @@ function editHeightmap() { editHeightmap.layers = Array.from(mapLayers.querySelectorAll("li:not(.buttonoff)")).map(node => node.id); // store layers preset editHeightmap.layers.forEach(l => document.getElementById(l).click()); // turn off all layers + enterStandardView(); + disable3dViews(); + customization = 1; closeDialogs(); tip('Heightmap edit mode is active. Click on "Exit Customization" to finalize the heightmap', true); @@ -109,6 +112,8 @@ function editHeightmap() { return; } + enable3dViews(); + customization = 0; customizationMenu.style.display = "none"; toolsContent.style.display = "block"; diff --git a/modules/ui/options.js b/modules/ui/options.js index 04364680..83bd4273 100644 --- a/modules/ui/options.js +++ b/modules/ui/options.js @@ -432,6 +432,7 @@ function changeViewMode(event) { const button = event.target; enterStandardView(); + if (button.classList.contains("pressed")) { button.classList.remove("pressed"); viewStandard.classList.add("pressed"); @@ -442,7 +443,20 @@ function changeViewMode(event) { } } +function disable3dViews() { + viewMesh.disabled = true; + viewGlobe.disabled = true; +} + +function enable3dViews() { + viewMesh.disabled = false; + viewGlobe.disabled = false; +} + function enterStandardView() { + viewMode.querySelectorAll(".pressed").forEach(button => button.classList.remove("pressed")); + viewStandard.classList.add("pressed"); + if (!document.getElementById("canvas3d")) return; ThreeD.stop(); document.getElementById("canvas3d").remove(); @@ -555,4 +569,4 @@ function toggle3dOptions() { function changeResolution() { ThreeD.setResolution(this.value); } -} \ No newline at end of file +}