Client side Texture Atlas creator for Three.js

It’s quite a useful tool. I wrote something similar for meep a while ago. I needed to be able to change the contents of the atlas at runtime though, so I ended up writing an implementation that does that. It’s a lot more complicated as a result, for the cases where you know in advance which textures you need - this is much better.

I remember having a lot of trouble optimizing performance for texture edits, making sure that only updated regions are re-packed and having to put in a lot of logic to prevent unnecessary resizing of the atlas and full re-pack.

My use-case for it was mainly for particle engine. I wanted to be able to reduce number of texture switches in the particle rendering. I pack both sprites and various curves for individual emitters into atlases.

The editing thing is due to not knowing in advance which emitters will be spawned and what sprite textures they will use, so the atlas serves to store sprites of active emitters and also to cache currently unused sprites in case they will be required at a later point. That space is reclaimed as necessary.

1 Like