I am looking for a way to show or hide objects by simply clicking a button. For example, when the button is clicked on the GUI, obj1 should be hidden and obj2 revealed. I tried using
object.traverse(object.visible=false);
but it doesn't seem to be working as expected.
This is how I currently render my objects:
var gal = jsonLoader.load( "model/galmodel.js", addModelToScene ) ;
gal.traverse(gal.visible = false);
Can anyone provide guidance on how to achieve this functionality? What command should I use to hide or reveal the objects upon click?
Thank you in advance.