I have never done anything with
material.lightmapTexture, which includes the exporting of it. I think that way you are baking it yourself, and load / assigning at run time is the best approach.
The exporter I work with does bake when there is no direct translation possible. Am pretty sure the GLB exporter does the same, though I do direct, single Blender => BJS translation, while theirs is a double translation of Blender => GLB, GLB => BJS.
While baking during export is convenient for let’s say evaluating something you got off of Blendswap to decide if it is worth using, there are several limitations:
- Blender can only bake the whole mesh, not different materials in a mult-imaterial mesh.
- That combined with metal & roughness & other stuff cannot be baked in Cycles, means with one material per mesh there has to be a common setting for these at the sub-material level.
- Multiple uses of the same material need to be baked multiple times, since there is no guarantee the meshes have identical geometry resulting in identical UV, nor are both necessarily the only material of those meshes.
- Blender has a hard time when one of the materials of a multi-material mesh of a mesh contains alpha, like a character with an eye brow texture. Order of baking is not something that is controllable in Blender, unless you do it in steps yourself.
For things like Base Color / Normals, once you bake it yourself, you could just then hook it up in Blender and let the exporter to the work. Not sure the double translation of light maps exists for GLB though.