带有参数的Dat.gui函数调用? [英] Dat.gui function invocation with parameters?

查看:213
本文介绍了带有参数的Dat.gui函数调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 dat.gui 很陌生。根据此小教程,您可以从以下位置调用对象的函数gui,只需将其传递给gui的 add 函数:

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, 'explode');

是否可以将参数传递给爆炸函数?

Is it possible to pass arguments to the explode function?

谢谢!

推荐答案

将参数传递给按钮的功能。但是,您可以在该函数中访问对象的其他属性:

It is not possible to pass arguments to a button's function. You can however access other properties of your object in that function:

function myViewModel() {
    var self = this;

    this.name = "name1",
    this.score = 9,
    this.check = function() {
        if(self.score >= 5) { // access to the score property
            alert('you pass!');
        } else {
            alert('try again.');
        }
    }
};

这篇关于带有参数的Dat.gui函数调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆