Conversation
|
I don't get it. Is this some sort of working solution or just some bits of a failed experiment? |
This is a working solution for running Raylib.js in worker |
|
But does this allow to use original unmodified examples without the GameFrame() trick? |
No, this pull request only about support for worker context. But i think it is possible to do this in worker context. I can continue to work specifically on this if needed. |
|
I implemented my idea in a separate branch and here's what I realized:
Here is a demo https://x0k.github.io/raylib.js/ (I don't recommend checking implementations other than |
I initially experimented with OffscreenCanvas to allow compiling examples without modifying the game loop.
But now i realized that the execution of WASM code is treated like a normal function call (not a macro or micro tasks), so the worker thread will never handle user input, which is useless for many apps.
Also currently it is impossible to simply generate frames in a worker with
OffscreenCanvasandbitmaprenderercontext, as they don't work with2dcontext.So my experiment was failed, but there is a code to run lib in worker or main thread.