Spawn Bevy canvas at full viewport size

This commit is contained in:
Danny McGee
2023-09-29 20:36:23 -04:00
parent bed97cff47
commit c1f92cc2d6
6 changed files with 64 additions and 429 deletions
+37
View File
@@ -0,0 +1,37 @@
use bevy::window::WindowResolution;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct ViewportSize {
pub width: f32,
pub height: f32,
}
#[wasm_bindgen]
impl ViewportSize {
#[wasm_bindgen(constructor)]
pub fn new(width: f32, height: f32) -> Self {
Self { width, height }
}
}
impl Default for ViewportSize {
fn default() -> Self {
WindowResolution::default().into()
}
}
impl From<ViewportSize> for WindowResolution {
fn from(value: ViewportSize) -> Self {
Self::new(value.width, value.height)
}
}
impl From<WindowResolution> for ViewportSize {
fn from(value: WindowResolution) -> Self {
Self {
width: value.width(),
height: value.height(),
}
}
}