Made a Blender script for batch baking lightmaps to optimize models for Threejs

Just wanted to share a little side script I put together while working on my galaxy portfolio. It saved me a lot of time with lightmap baking, when optimizing it.

I got tired of manually baking lightmaps for each object in my Three.js project (super tedious) and didn’t find any FOSS alternatives, so I wrote this Blender script that:

  • Bakes multiple objects in one go
  • Automatically creates UV maps if needed
  • Lets you flip between baked/real-time modes with one click (for editing/export)

Helped my performance quite a bit - got crazy bigger fps on mobile and trimmed down my file size, not to mention that threejs doesn’t support some of the light types available in Blender.

It’s just a script, not an addon - wanted to keep it simple. Just copy-paste and run it.

Thought someone might find it useful.

9 Likes