From 89386f12a023c0b9fd5a76ebc2e97cfef4623dcd Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Wed, 18 Feb 2026 07:20:40 -0800 Subject: [PATCH] fix resize --- lib/src/graphics.rs | 3 --- wasm-module/src/lib.rs | 4 ++++ web-demo/index.html | 15 +++++++-------- web-demo/player.js | 8 ++++++++ 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/src/graphics.rs b/lib/src/graphics.rs index 2df6d76..61b2dfa 100644 --- a/lib/src/graphics.rs +++ b/lib/src/graphics.rs @@ -48,13 +48,10 @@ impl Graphics{ self.graphics.generate_models(&self.device,&self.queue,&map); }, Instruction::Resize(size)=>{ - println!("Resizing to {:?}",size); - let t0=std::time::Instant::now(); self.config.width=size.x.max(1); self.config.height=size.y.max(1); surface.configure(&self.device,&self.config); self.graphics.resize(&self.device,&self.config,glam::Vec2::ONE); - println!("Resize took {:?}",t0.elapsed()); } Instruction::Render{pos,angles}=>{ //this has to go deeper somehow diff --git a/wasm-module/src/lib.rs b/wasm-module/src/lib.rs index 9dc14c6..2d4fcba 100644 --- a/wasm-module/src/lib.rs +++ b/wasm-module/src/lib.rs @@ -38,6 +38,10 @@ impl Graphics{ let (pos,angles)=head.head.get_position_angles(&bot.bot,time); self.graphics.send(&self.surface,strafesnet_roblox_bot_player::graphics::Instruction::Render{pos,angles}); } + #[wasm_bindgen] + pub fn resize(&mut self,width:u32,height:u32){ + self.graphics.send(&self.surface,strafesnet_roblox_bot_player::graphics::Instruction::Resize([width,height].into())); + } } #[wasm_bindgen] diff --git a/web-demo/index.html b/web-demo/index.html index 8c1c34a..57f80b7 100644 --- a/web-demo/index.html +++ b/web-demo/index.html @@ -13,16 +13,15 @@ } html, body { - margin: 0; /* remove default margin */ - height: 100%; /* make body fill the browser window */ - display: flex; - place-content: center center; + margin: 0px; + width: 100%; + height: 100%; + overflow: hidden; } canvas { - width: 600px; - height: 600px; - max-width: 100%; - display: block; + margin: 0; + width: 100%; + height: 100%; } diff --git a/web-demo/player.js b/web-demo/player.js index 56db786..5fb0770 100644 --- a/web-demo/player.js +++ b/web-demo/player.js @@ -34,3 +34,11 @@ function animate(now) { } requestAnimationFrame(animate); + +function resize() { + canvas.width = canvas.clientWidth; + canvas.height = canvas.clientHeight; + graphics.resize(canvas.width, canvas.height); +} +window.addEventListener("resize", resize); +resize();