GUI color change

Hi,

I’m playing around with this example: three.js examples. I’m trying to have a color picker GUI and when I pick one color I want to change the new box that is added but not the previous boxes in the list. So far when I change the “cubeMaterialcolor” all objects are changing.

I manage to make it work by pressing keys and setting up different colors.( r = red, g = green , etc.)
but I can’t make it work with GUI.

I was wondering how you guys will approach this?

Thanks in advance,
N

The problem is that all cubes share the same material. For your use case, it’s better to assign a material for each cube. In this way, changing the color of a single cube won’t affect the others.