The material indices from the caps were only copied if the base mesh had a material index attribute. Fix that by copying them manually if the cap has the attribute.
The material indices from the caps were only copied if the base mesh had a material index attribute. Fix that by copying them manually if the cap has the attribute.