In addition to your solution,
I can suggest at least three ways to avoid structures (untested too):
- Use Components Map and materials array

Pack material indices into string:
Return materials:
- You can use the mesh asset materials:
- Also you can use json as a dynamic structure:

Hope this helps.




