Closed FreddyWordingham closed 2 years ago
Nice idea, thank you.
I think we can do this without javascript though. Bevy's WindowDescriptor
resource has a canvas
field for the web target. It gives you control over the position of the canvas element in your document.
That is a more elegant solution :)
I can't seem to find anything in the Bevy WindowDescriptor
docs and don't see a web/canvas feature flag,
Please could you point me in the right direction for more info on the WindowDescriptor.canvas
web target settings?
Thanks very much @NiklasEi
Are you planning on opening another PR for this or would you be OK with me implementing it and adding you as a co-author?
Thanks for the fantastic template! In particular, the GitHub actions are great - I like how you can manually trigger the deployments with a
workflow_dispatch
trigger :)This is a minor suggestion that should help developers customise the frontend webpage that the WASM window gets embedded within. Currently the Bevy app loads into a
<canvas>
(with no settableid
) which is injected into the<body>
- which means you can't place it before loading, and it has no identifier to help you find it afterwards.This PR adds a script
setup_display.js
which waits for the Bevy<canvas>
to load, and then moves it into a div withid="wasm-window"
, which means you can design the web page by styling thewasm-window
element.By default the template webpage's
<div id="wasm-window">
is placed within a<div class="container">
which will centre the game window within the middle of the page:It should then be straightforward to further customise the
index.html
page.