diff --git a/Cargo.lock b/Cargo.lock index 6aed92a..cb255e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2284,7 +2284,9 @@ dependencies = [ "strafesnet_deferred_loader", "strafesnet_rbx_loader", "strafesnet_snf", + "wasm-bindgen", "wasm-bindgen-futures", + "web-sys", "wgpu", "winit", ] diff --git a/strafe-client/Cargo.toml b/strafe-client/Cargo.toml index 910f22e..7c4c0b7 100644 --- a/strafe-client/Cargo.toml +++ b/strafe-client/Cargo.toml @@ -28,6 +28,8 @@ strafesnet_common = { path = "../lib/common", registry = "strafesnet" } strafesnet_deferred_loader = { path = "../lib/deferred_loader", features = ["legacy"], registry = "strafesnet", optional = true } strafesnet_rbx_loader = { path = "../lib/rbx_loader", registry = "strafesnet", optional = true } strafesnet_snf = { path = "../lib/snf", registry = "strafesnet", optional = true } +wasm-bindgen = "0.2.99" wasm-bindgen-futures = "0.4.49" +web-sys = { version = "0.3.76", features = ["console"] } wgpu = "23.0.1" winit = "0.30.7" diff --git a/strafe-client/src/setup.rs b/strafe-client/src/setup.rs index be0601c..ee8b256 100644 --- a/strafe-client/src/setup.rs +++ b/strafe-client/src/setup.rs @@ -34,8 +34,13 @@ fn create_window(title:&str,event_loop:&winit::event_loop::EventLoop<()>)->Resul } #[cfg(target_arch="wasm32")] { + use wasm_bindgen::JsCast; use winit::platform::web::WindowAttributesExtWebSys; - attr=attr.with_append(true); + let canvas=web_sys::window().unwrap() + .document().unwrap() + .get_element_by_id("canvas").unwrap() + .dyn_into::().unwrap(); + attr=attr.with_canvas(Some(canvas)); } event_loop.create_window(attr) } diff --git a/web-client/index.html b/web-client/index.html index b1f1d97..054522e 100644 --- a/web-client/index.html +++ b/web-client/index.html @@ -6,8 +6,32 @@ Strafe Client + +
+ +