How to remove dat.GUI element?

I found this function to remove the gui element, but I think it is deprecated. So far, I have not been able to find anyone else who knows how to remove any part of gui, be it the entire dat.GUI () or just the added element in dat.GUI (). The first one will probably be sufficient for what I need (just delete dat.GUI () all together), but any of them will be very useful!

supposed to remove dat.GUI ()

gui = new dat.GUI(); 

...

 removeGui(gui); function removeGui(gui, parent) { if(!parent) { parent = dat.GUI.autoPlaceContainer; } parent.removeChild(gui.domElement); } 

But it returns an error: you cannot call the removeChild method from undefined, so I assume that autoPlaceContainer is wrong.

The original author of this function left these notes:

where the gui parameters represent the DAT.GUI you want to remove, and the parent is the parent container, unless you specified domElement when creating the DAT.GUI, you do not need to pass the parent element.

+8
user-interface
source share
3 answers
 var gui = new dat.GUI(); item = gui.add(text, 'message'); 

For removing:

 gui.remove(item); 

If your item is inside a folder, you should do:

 folder.remove(item); 
+6
source share

If you want to delete the entire dat.GUI element along with all your listeners, you can use gui.destroy()

+4
source share

Change the remove function in the dat.gui.js file: "slice" wants to be a "splice".

The answer can be found here: https://github.com/ulyssesp/dat.gui/commit/86f43c0be5db08c9a6d7339aa8287620306fb0b5

0
source share

All Articles