Another attempt to fix high-DPI viewport jank

This commit is contained in:
Danny McGee
2024-04-11 03:45:45 -04:00
parent 351ca40612
commit 58b02a7100
2 changed files with 16 additions and 8 deletions
+8 -5
View File
@@ -71,7 +71,12 @@ pub mod wasm {
fn build(&self, app: &mut App) {
app.add_event::<ViewportResizeEvent>().add_systems(
PreUpdate,
(dispatch_resize_events, sync_window_to_viewport).chain(),
(
dispatch_resize_events,
apply_deferred,
sync_window_to_viewport,
)
.chain(),
);
}
}
@@ -88,9 +93,7 @@ pub mod wasm {
let ViewportSize { width, height } = event.0;
let mut window = window.single_mut();
let scale_factor = window.scale_factor();
window
.resolution
.set(width * scale_factor, height * scale_factor);
window.resolution.set(width, height);
q_camera.single_mut().viewport = Some(Viewport {
physical_size: UVec2::new(
(width * scale_factor) as u32,
@@ -98,7 +101,7 @@ pub mod wasm {
),
..Default::default()
});
info!("Viewport size: ({:.2}, {:.2})", width, height);
info!("Viewport size: ({width:.2}, {height:.2}) [{scale_factor}]");
}
}