Skip to content

Commit

Permalink
feat: load terrain data
Browse files Browse the repository at this point in the history
  • Loading branch information
manankarnik committed Jan 15, 2024
1 parent 2bea472 commit 9b04c1b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion utils/terrain/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ extern "C" {
fn send_asset(asset: &str, thumbnail: &[u8]);
}

#[wasm_bindgen(raw_module = "../../routes/generate/[util]/+page.svelte")]
extern "C" {
fn recieve_asset() -> Option<String>;
}

fn main() {
App::new()
.add_plugins(
Expand Down Expand Up @@ -77,7 +82,13 @@ fn setup(mut commands: Commands) {
},
PanOrbitCamera::default(),
));
commands.spawn(TerrainBundle::default());
commands.spawn(TerrainBundle {
terrain: match recieve_asset() {
Some(terrain) => serde_json::from_str(&terrain).expect("Could not deserialize terrain"),
None => Terrain::default(),
},
..default()
});
}

fn gui(mut contexts: EguiContexts, mut query: Query<&mut Terrain>) {
Expand Down

0 comments on commit 9b04c1b

Please sign in to comment.