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
+3 -5
View File
@@ -1,4 +1,5 @@
import * as studio from "@storyteller/studio";
import { ViewportSize } from "@storyteller/studio";
import "./app.element.scss";
@@ -9,11 +10,8 @@ export class AppElement extends HTMLElement {
// TODO: This siezes up the whole browser for several seconds, presumably
// while the WASM binary is loading. Is there any way to do this
// asynchronously?
// TODO: Since we're using `#[wasm_bindgen]` attributes instead of the
// CLI, we can craft our own JS API to interact with Bevy! \o/ As a start,
// we should exploit this to pass an explicit canvas size to Bevy and keep
// it up to date with the browser viewport size.
studio.init();
const { width, height } = document.body.getBoundingClientRect();
studio.init(new ViewportSize(width, height));
}
}
customElements.define("app-root", AppElement);