javascript 是否可以使用 dat.gui 创建按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18366229/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 11:39:32  来源:igfitidea点击:

Is it possible to create a button using dat.gui

javascriptdat.gui

提问by Lonelydatum

I would like to create a button using dat.gui library. In a perfect world, this would work like this:

我想使用 dat.gui 库创建一个按钮。在一个完美的世界中,这会像这样工作:

gui.add("button", "click me");

回答by Lonelydatum

This creates a button with text left aligned.

这将创建一个文本左对齐的按钮。

var obj = { add:function(){ console.log("clicked") }};

gui.add(obj,'add');

回答by eriksssss

FWIW, dat.gui assumes the GUI type based on the target's initial value type.

FWIW,dat.gui 根据目标的初始值类型假定 GUI 类型。

  • boolean => checkbox
  • int/float => slider
  • string => text input
  • function => button
  • 布尔值 => 复选框
  • int/float => 滑块
  • 字符串 => 文本输入
  • 功能 => 按钮

Examples can be found here: http://workshop.chromeexperiments.com/examples/gui/#1--Basic-Usage

示例可以在这里找到:http: //workshop.chromeexperiments.com/examples/gui/#1--Basic-Usage