Hello. I created a small demo, inspired by this scene. But I got bad.
When you change the color of the item, mesh disappears completely. See gif file.
Function code caused by a clique Codepen. She called each time you change colors. Yes, it is terrible). Please help advice. How best to implement?