diff --git a/src/js/lib/application.tsx b/src/js/lib/application.tsx index 848e78b..7e9d969 100644 --- a/src/js/lib/application.tsx +++ b/src/js/lib/application.tsx @@ -29,18 +29,31 @@ export function Interface() { ) - const handleSeedClick = () => { + const handleInitClick = () => { if (wasmModule === null) { console.error("wasm not yet loaded"); } else { galaxyFrontend = new galaxy.Frontend(galaxySize); + } + }; + + const initButton = ( + + ) + + const handleSeedClick = () => { + if (wasmModule === null) { + console.error("wasm not yet loaded"); + } else { galaxyFrontend.seed(); } }; const seedButton = ( ) @@ -60,6 +73,7 @@ export function Interface() {

( rust => wasm => js ) galaxy generation simulation

{galaxySizeInput}
+ {initButton} {seedButton} {tickButton}
diff --git a/src/rust/galaxy.rs b/src/rust/galaxy.rs index 0ca7f60..4828e14 100644 --- a/src/rust/galaxy.rs +++ b/src/rust/galaxy.rs @@ -2,6 +2,8 @@ use cell::*; use rand::Rng; use wasm_bindgen::prelude::*; +use crate::utils; + // types #[wasm_bindgen] pub struct Galaxy { @@ -14,6 +16,7 @@ pub struct Galaxy { impl Galaxy { #[wasm_bindgen(constructor)] pub fn new(size: u16, mass: u16) -> Galaxy { + utils::set_panic_hook(); return Galaxy { size, cells: vec![