fenomas / noa

Experimental voxel game engine.
MIT License
611 stars 87 forks source link

Possibly make chunk loading asynchronous or whatnot #126

Closed csf30816 closed 4 years ago

csf30816 commented 4 years ago

I don't know if you already do this or not but sometimes I notice a freeze when loading a chunk. And although I only ever use async when a library forces me to I think async might fix that problem as it seems it enables you to do multiple things at once. I might be wrong. It also could be that my chunk loading script isn't very efficient. Sorry for all the "issues" I've opened lmao.

fenomas commented 4 years ago

Hi, yes, you definitely want to do chunk creation in a worker if possible. That's basically the rationale for why the engine sends you an event and then asks you to call an API later with the data. I don't think this is currently implemented in the test world, but it would probably be good if it was.

Doing worldgen asynchronously (but not in a worker) is also good - I believe the "test" world in the examples repo does this. But just doing things async means that worldgen still happens in the main thread, so if any single chunk takes a long time to create then you'll see FPS drops. So using workers is definitely the ideal approach.

No worries about the issues, open as many as you have questions about please!

csf30816 commented 4 years ago

ah yes. Web Workers is what I meant.