I'm looking to turn objects in my scene on/off through the click of a button on a gui. I have the function:
g3white.traverse(function(child){child.visible = true;});
g3black.traverse(function(child){child.visible = false;});
This function successfully hides/shows each object manually.
However, I want to set this to an onChange function to show the black one and hide the white one (and vice versa) with the click of a button.
Any help is appreciated. Thank you.
You can use DAT.Gui
var gui = new dat.GUI();
var controls = {
toggleObjects: function(){
g3white.traverse(function(child){child.visible = true;});
g3black.traverse(function(child){child.visible = false;});
}
};
gui.add(controls, 'toggleObjects');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.