This commit is contained in:
Danny McGee
2023-11-14 22:15:23 -05:00
parent 0d712c9627
commit 2f37dad5ce
2 changed files with 50 additions and 46 deletions
+5 -5
View File
@@ -18,7 +18,10 @@ pub fn save_scene() {
} }
pub(super) fn save_scene_system(world: &mut World) -> Result<(), String> { pub(super) fn save_scene_system(world: &mut World) -> Result<(), String> {
wasm::read_buffer!(SCENE_REQUEST, |_| { if wasm::read_buffer!(SCENE_REQUEST).is_none() {
return Ok(());
}
let mut scene = DynamicScene::from_world(world); let mut scene = DynamicScene::from_world(world);
let type_registry = world.resource::<AppTypeRegistry>(); let type_registry = world.resource::<AppTypeRegistry>();
@@ -67,10 +70,7 @@ pub(super) fn save_scene_system(world: &mut World) -> Result<(), String> {
}) })
.ok_or_else(|| "Failed to get Window from &mut World".to_string())?; .ok_or_else(|| "Failed to get Window from &mut World".to_string())?;
wasm::dispatch_to_js(window, "scene-download-ready", &serialized)?; wasm::dispatch_to_js(window, "scene-download-ready", &serialized)
});
Ok(())
} }
#[wasm_bindgen(typescript_custom_section)] #[wasm_bindgen(typescript_custom_section)]
+4
View File
@@ -91,6 +91,10 @@ macro_rules! read_buffer {
} }
} }
}}; }};
($buffer:ident) => {{
let buffer = crate::wasm::get_buffer!($buffer);
buffer.try_lock().and_then(|lock| lock.borrow_mut().take())
}};
} }
pub(crate) use get_buffer; pub(crate) use get_buffer;