forked from StrafesNET/roblox-bot-player
fix resize
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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%;
|
||||
}
|
||||
</style>
|
||||
<script defer src="player.js" type="module"></script>
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user