i'm using dat.gui, i have a global variable called variab (outside of the setupGui function showed here) that changes dinamically during the runtime, and i want to get showed the current value in a box rendered by dat.gui . At the purpose, i wrote this code:
function setupGui() {
var FizzyText = function() {
this.sum = variab;
};
var text = new FizzyText();
var gui = new dat.GUI();
gui.add(text, 'sum').onChange( function(){
FizzyText.variab = variab;
console.log("Value changed to: ", variab);
});
var update = function() {
FizzyText.variab = Math.random();
requestAnimationFrame(update);
};
update();
}
But it doesn't work, i already tried all the suggestions present in Three.js: Cannot change value in dat.GUI , like using listen() and updateDisplay() methods . Note that setupGui() runs continually, not only one time.
How can i fix my problem? Thanks in advance