I have a scene with multiple models and I am using dat.gui to toggle through them.
Previously, I attempted to achieve this by toggling the visibility on/off with the following code:
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');
However, I encountered errors such as "Uncaught TypeError: undefined is not a function".
Furthermore, I am looking for a solution where I can switch between more than 2 models at the click of a button, displaying one model while hiding all others.
Is there a better or simpler way to achieve this? Any assistance would be greatly appreciated as I am relatively new to working with three.js.