-
-
Notifications
You must be signed in to change notification settings - Fork 217
Description
Maybe this is related to the: // TODO: split to gl.js and loader.js line near the top of gl.js -- I searched for issues relating to this but didn't see any but maybe I missed it.
I have a complex web app that I would like to embed a 3d view in. The web app is written in Dioxus, using Rust + WASM. I would like to just have one codebase that uses Dioxus and miniquad. Since I want Dioxus to render my 3d view as a component, the <canvas> element won't exist in the base index.html that gets rendered at first.
Here's the problem:
- my .wasm file ends up depending on the various functions inserted into the
"env"module that are defined bygl.js. It won't load at all unless they exist already. gl.jsdepends on thecanvasexisting, and sets up a bunch of things directly on that canvas, even e.g. focusing the canvas immediately.
I would like to be able to initialize just the necessary gl polyfill so that my .wasm file can be loaded, and delay the actual interaction with the webgl canvas until my component is drawn.
This structure also prevents stuff like multiple canvases rendered by miniquad since gl.js just expects to find a single canvas with id='glcanvas'.
FWIW I don't believe there is any fundamental reason this circular dependency is a problem because I have gotten similar embedded-3d-view-in-dioxus-app working with both the three-d crate and bevy.
If anyone else has figured this out I would love to hear about it.