Question

I want to hide/reveal objects with the click of a button. i.e. click button on a GUI and obj1 is hidden and obj2 is revealed. I was told to do this using

 object.traverse(object.visible=false);

but it does not seem to work.

Here is how I'm rendering my objects

var gal = jsonLoader.load( "model/galmodel.js", addModelToScene ) ;
gal.traverse(gal.visible = false);

Can anyone point me into the right direction on how to make this work? And the command that will hide/reveal the objects on click?

Thank you very much.

Was it helpful?

Solution

Last time i checked, the traverse function was a callback. So you would need to do something like this:

gal.traverse(function(child){
   child.visible = false;
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top