Skip to content

Commit

Permalink
View Mode switch refactored.
Browse files Browse the repository at this point in the history
  • Loading branch information
Smoren committed Apr 29, 2024
1 parent ac3be24 commit 5d002ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ watch(() => configStore.worldConfig.VIEW_MODE, () => {
});
watch(viewMode, async () => {
if (configStore.worldConfig.VIEW_MODE === viewMode.value) {
return;
}
await simulation.stop();
configStore.setViewMode(viewMode.value);
await simulation.restart();
await simulation.setViewMode(viewMode.value);
});
</script>
Expand Down
7 changes: 7 additions & 0 deletions src/store/simulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ export const useSimulationStore = defineStore("simulation", () => {
return getCurrentSimulation().togglePause();
}

const setViewMode = async (viewMode: ViewMode) => {
await stop();
configStore.setViewMode(viewMode);
await restart();
}

// watch(() => configStore.worldConfig.VIEW_MODE, async () => {
// await restart();
// });
Expand All @@ -156,5 +162,6 @@ export const useSimulationStore = defineStore("simulation", () => {
stop,
isPaused,
togglePause,
setViewMode,
}
});

0 comments on commit 5d002ed

Please sign in to comment.