Text type input in gui in three.js

I am using dat.gui for getting input from the user. I need text type input method in that gui. How to create it. I have only a decision box and drop down and button type input methods only in that gui. how to add text type input in that gui. Please help me?. Thanks in advanced.

This is not a question about three.js, but I answer it because dat.gui is so often used, and so convenient, for three.js demos.

dat.gui will infer input type from the existing data type. So to get a text field, the value of the field must be a string at the time you add the control to dat.gui.

const params = {
    textField: "This is a placeholder text"

const gui = new dat.GUI();
gui.add(params, "textField").onFinishChange(function (value) {
    //Do something with the new value

@EliasHasle, Thanks . Is there any possible way for a text field, only allows floating type

Please just read my answer and test the proposed solution. I have now tested it, and can confirm that it works: https://jsfiddle.net/b452w0p8/


Yes @EliasHasle. Thank you :blush:

1 Like

No problem! :raised_hands:

1 Like