Here’s something i continually re-use, especially for testing features.
It’s a simple toggle setup using a boolean variable to change back and forth between two states.
In the example’s case, cube as Red or Yellow.
(cube_clicked = true / false is just it’s state, not representative of whether it’s actually been clicked.)
I have a more complex one that can be used for all objects i might share if i can simplify it a bit.
Zip file of project attached. just unzip to your verge3d/applications folder.