Open Schr3da opened 7 years ago
@Schr3da we haven't look into it, and don't know what the requirements/implications are. It would be much welcome for sure ;)
AFAICT, WASM has the same limitations as WebGL. If Three.rs can run using OpenGL ES 2.0, then it should compile to WASM just fine. I haven't tested this yet, but am digging into Three.rs for just this reason...
I imagine there will only be a few issues to consider (all amendable) before WASM support can be a reality.
GL_UNSIGNED_INT
indices. We would have to enable the OES_element_index_uint
extension or restrict indices to GL_UNSIGNED_SHORT
.mpsc
channels. This might have to be replaced with a WASM-friendly equivalent.cargo web
.Note that gfx-0.17 has WebGL2 support, so we may be very close to get this going. I'm planning on updating our graphics stack, and I'll test WebGL2 for three-rs on the way, will report back here.
is there any progress / timeline for this?
@ForsakenHarmony we are currently stopped in a situation where Emscripten could possibly be gotten to work. The upstream PR unblocking it has landed only recently - https://github.com/kripken/emscripten/pull/5951 . However, Rust community/ecosystem appears to be moving in the direction of using wasm-unknown-unknown
target instead (thus, no Emscripten), and we are watching a hero laying down this path in https://github.com/gfx-rs/gfx/issues/1900
Anyhow, a champion is always needed here in Three-rs to get things hooked up and tested. Jump on our gitter to chat about it if you want to lend a hand ;)
I'm not sure if I could be of any use
Any thoughts on this now that gfx-rs supports wasm-unknown-unknown
?
I'm interested and could possibly lend some time to implementing (although I'm a Rust newbie) if there is a good idea of what is required?
Likewise to LordBenjamin. I'm experienced with THREE.js via Javascript, but new to Rust & WASM. Nonetheless, would like to contribute given sufficient guidance or examples to work from.
@LordBenjamin it's an entirely different gfx-rs that now has basic support for wasm-unknown-unknown
. Three-rs uses gfx-0.17
, which we call "pre-ll" for "pre low-level rewrite". There is no straight path to upgrade to the current latest and greatest gfx-hal-0.3, see https://github.com/gfx-rs/gfx/issues/1721
This project needs a big leap in order to continue developing - moving from gfx pre-ll to wgpu-rs, which is modern, extremely portable, and has a similar level of abstraction. See #222. wgpu-rs is naturally going to be targeting the Web, even though today its capabilities are mostly focused on native.
@vitvakatu earlier expressed interest in doing the port, but I'm not aware of any progress, so the task is still open for interested parties.
Yeah, I got distracted by other tasks (and continue to be distracted), so I suppose someone else could try to do so. I can help with code reviews.
@kvark / @vitvakatu - thanks for the info.
Is there any detailed breakdown of what would need to be done to move to wgpu-rs
? #222 doesn't really seem to indicate what the steps involved in this port would be.
What sort of effort do you think the port would involve - days, weeks?
It's a big multi-week effort. Steps can be described as follows:
Here is a similar effort that was done in the past - https://github.com/kvark/vange-rs/pull/73 , to give you a sense of scale.
How about we break it down further and assign chunks to willing owners?
Basically you need to rewrite the whole render
module, and you can't do it step-by-step. You can, however, translate examples one-by-one (by disabling ones that are not working) and slowly implement necessary features.
I don't know how to break down such huge task.
You could also cut out all the pipelines/shaders except for the most basic one to start with. But it still requires a lot of thinking up-front. Just rewriting the infrastructure we have is the biggest challenge, and it will probably need to be done in one go.
@LordBenjamin @jpryne we greatly appreciate your interest in helping with this, and we'll be happy to provide guidance along the way. Just giving a fair warning that this is not an easy task, especially if you also need to learn about gfx pre-ll and wgpu-rs along the way.
The way it could be done, I imagine is:
render
moduleJust giving a fair warning that this is not an easy task, especially if you also need to learn about gfx pre-ll and wgpu-rs along the way.
Fair enough. Possibly in over my head TBH - I have little Rust / gfx experience as I'm coming from a C# / DirectX and TypeScript / three.js background.
I'm sure it would be an interesting ride and I would learn a lot by doing this. Appreciate your offers of guidance and code reviews. I don't want to commit to doing it and then waste your time with trivial questions either though.
I'll have a bit more of a look into wgpu-rs
and let you know if I think I can help!
Is web assembly initially planned?