I'm making a small billiards game in THREE.js, and have opted to use Dat.Gui as a GUI library. I have a few small questions regarding the latter:
- First Question: Can I make a class that returns the GUI?
Currently I have a mygui.js file where I put the code of the gui (the example code[1], let's say), and I include that in mygame.html before the main.js. However, all other objects (table, balls, lights, etc) are classes and I'd like to do that too with the GUI. When I place everything inside a
class MyGUI {
constructor() {
//javascript part of the example here
return gui;
}
}
and then call in main.js
var mygui = new MyGUI();
the GUI isn't showing up, but when I don't include the class and the line in main.js, it works. I have downloaded dat.gui.min.js and included it in the html.
Second Question: I want to change variables now and then based on when I call the gui's change function, but how would I go about that without classes (should that not work)?
Third Question: I want to use the GUI, only to display values. Users are not supposed to change it. Can I make the GUI read-only? (to be clear: changing the values in the GUI will not change gameplay, they're just textual representations of the state of the game)
Fourth Question: I want to remove the top part of the GUI (where you can load/save presets or something). How do I do that?