Skip to content

Commit

Permalink
fix: wasm-bindgen called on non-wasm targets
Browse files Browse the repository at this point in the history
  • Loading branch information
manankarnik committed Jan 12, 2024
1 parent 490519d commit 3aa437e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ use gltf::{export_gltf, Output, Vertex};
use image::{codecs::png::PngEncoder, save_buffer, DynamicImage, ImageBuffer, ImageEncoder, Rgba};
#[cfg(not(target_arch = "wasm32"))]
use rfd::FileDialog;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::wasm_bindgen;

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen(module = "/src/util/save.js")]
extern "C" {
fn save(data: &[u8], filename: &str, r#type: &str);
Expand All @@ -24,6 +26,7 @@ pub fn export_asset(image_buffer: ImageBuffer<Rgba<u8>, Vec<u8>>) {
)
.expect("Failed to write to png");

#[cfg(target_arch = "wasm32")]
save(&png_buffer, "asset.png", "image/png");
}
#[cfg(not(target_arch = "wasm32"))]
Expand Down

0 comments on commit 3aa437e

Please sign in to comment.