Fix for 3d heightmap / 3d view conflict (#360)

This commit is contained in:
evolvedexperiment 2019-11-11 21:53:23 +02:00 committed by Azgaar
parent 354eb74746
commit 257cf11986
2 changed files with 21 additions and 2 deletions

View file

@ -9,7 +9,7 @@ function editHeightmap() {
<p>If you need to change the coastline and keep the data, you may try the <i>risk</i> edit option.
The data will be restored as much as possible, but the coastline change can cause unexpected fluctuations and errors.</p>
<p>Check out ${link("https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Heightmap-customization", "wiki")} for guidance.</p>
<p>Please <span class="pseudoLink" onclick=saveMap(); editHeightmap();>save the map</span> before edditing the heightmap!</p>`;
<p>Please <span class="pseudoLink" onclick=saveMap(); editHeightmap();>save the map</span> before editing the heightmap!</p>`;
$("#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";

View file

@ -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();