fenomas / noa

Experimental voxel game engine.
MIT License
616 stars 91 forks source link

Preload all block textures at startup? #26

Closed Nesh108 closed 7 years ago

Nesh108 commented 7 years ago

Hello there!

Would it be possible to preload the textures at startup? I am asking because I have noticed that if a new block texture is used, then the engine will try to fetch it, meaning that it can show an empty hole while retrieving it.

If it could just fetch and cache all the textures, it wouldn't matter much as it is expected to have some loading but at least it would have a better overall feel when playing the game.

How could one go about doing that in noa?

fenomas commented 7 years ago

Hey! Short answer: should be possible, but I have no particular idea how.

I think that it should work the same as preloading assets for any other purpose (like loading a font before you display the text). If you load each asset once before creating your noa/Babylon scene, then when Babylon loads the textures they'll come from cache instantly.

So my guess is that any existing "image preload" library should work for this. But I haven't tried it and don't know one to recommend.

Nesh108 commented 7 years ago

Yeah, that worked out. Just using image-preloader solved the latency issues. Thanks! :D