diff --git a/Cargo.lock b/Cargo.lock index 8c44ff5..7a4faef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -268,6 +268,26 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "console_log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501a375961cef1a0d44767200e66e4a559283097e91d0730b1d75dfb2f8a1494" +dependencies = [ + "log", + "web-sys", +] + [[package]] name = "core-foundation" version = "0.9.3" @@ -2241,7 +2261,10 @@ version = "0.1.0" dependencies = [ "anyhow", "bytemuck", + "cfg-if", "cgmath", + "console_error_panic_hook", + "console_log", "env_logger", "fs_extra", "glob", @@ -2252,6 +2275,9 @@ dependencies = [ "regex", "rust-embed", "tobj", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", "wgpu", "wgpu-types", "winit", diff --git a/Cargo.toml b/Cargo.toml index 82bba38..57e952d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,12 @@ name = "wgpu-renderer" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +crate-type = ["cdylib", "rlib"] + +[[bin]] +name = "wgpu-renderer" +path = "src/main.rs" [dependencies] winit = "0.27.5" @@ -20,6 +25,19 @@ gltf = "1.0.0" wgpu-types = "0.14.1" regex = "1.7.1" rust-embed = "6.4.2" +cfg-if = "1" + +[target.'cfg(target_arch = "wasm32")'.dependencies] +console_error_panic_hook = "0.1.6" +console_log = "0.2.0" +wgpu = { version = "0.14", features = ["webgl"]} +wasm-bindgen = "0.2" +wasm-bindgen-futures = "0.4.30" +web-sys = { version = "0.3", features = [ + "Document", + "Window", + "Element", +]} [build-dependencies] anyhow = "1.0.68" diff --git a/index.html b/index.html new file mode 100644 index 0000000..c37a82a --- /dev/null +++ b/index.html @@ -0,0 +1,25 @@ + + + +
+ + + +