Fixes bug in GetAllMaterials helper function which broke materials
in some models for GetMaterials.

Fixes #2681.