How to keep unused materials when exporting gltf files from Blender?

I want to switch different material balls for the same object by clicking it, but after setting up two material balls in blender, the unused material ball will be lost when exporting the gltf file. Could you please tell me how I should do it?

Hello and welcome :slight_smile:

I think that the Blender exporter gets rid of unassigned materials anyway…

What you could do is exporting one (very light, a plane…) object and assign a material per face :

and then on BJS side you would hide this mesh, but retreive all the materials, and bind your click to switch materials on another mesh (sphere) : Playground

++
Tricotou

2 Likes