-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
separate the Engine from the Render #517
Comments
The renderer is separate from the engine already, can you be more specific? If you mean running the engine in a web worker, it should be possible but you will need to serialise the world to pass it between threads. Have a look at the serializer in matter-tools which should help you start. |
I just want to make the matter-js keep running when switching the tab. My idea is running the engine in a web worker, but it show errors when I created an engine in a web worker because a worker isn't allowed to access html dom.
Does it mean serialising the world in a worker and passing it to the main js? I don't know how to make an engine in a web worker. /(ㄒoㄒ)/~~ |
Looks like a pretty wild hack, but if it works then why not!
Would you mind posting those errors?
Yeah exactly, I think that's how you need to do it if you wanted to render on the main thread. |
Had this same issue and adding hacker time worked, thanks so much. |
can we find an example of this working ? Ans does it have a performance improvement? |
@koraysels do you mean running in a worker? There's no official example of this yet (it's on my list!) but it should be possible to do as discussed here and in other threads. The main benefit of threads in this context is usually to allow rendering and physics to run at different rates rather than performance. You'd only see a boost if you can make use more than one thread, which is not straightforward for the physics side of things (on my list too, but it's a complex research topic of its own). Usually this starts with rendering on one thread and running physics on another thread, which might give a small boost depending on how complex your rendering is more than anything else. It might also be a slight detriment depending on how you implement the data sharing between threads (sending minimal data through shared memory is probably the way to go). |
I want to run the Engine in H5 Worker and run the Render in the main JS. What should I do?
The text was updated successfully, but these errors were encountered: