Dat.gui Function Invocation With Parameters?
I am quite new with dat.gui. According to this little tutorial, you can invoke an object's function from the gui, just passing it to the gui's add function: gui.add(fizzyText, 'exp
Solution 1:
You can pass some arguments to explode() if you create through Function.bind() a copy of this function.
gui.add({explode : fizzyText.explode.bind(this, param_1, param_2)}, "explode");
Further information to Function.prototype.bind()
I also had to do it, to reuse my function and it worked fine for me like that :)
Solution 2:
It is not possible to pass arguments to a button's function. You can however access other properties of your object in that function:
functionmyViewModel() {
var self = this;
this.name = "name1",
this.score = 9,
this.check = function() {
if(self.score >= 5) { // access to the score propertyalert('you pass!');
} else {
alert('try again.');
}
}
};
Post a Comment for "Dat.gui Function Invocation With Parameters?"