28

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

gui.add("button", "click me");
David Smith
  • 35,646
  • 10
  • 43
  • 61
Lonelydatum
  • 948
  • 1
  • 12
  • 24

2 Answers2

54

This creates a button with text left aligned.

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

gui.add(obj,'add');
kerl
  • 270
  • 1
  • 3
  • 17
Lonelydatum
  • 948
  • 1
  • 12
  • 24
27

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

  • boolean => checkbox
  • int/float => slider
  • string => text input
  • function => button

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

eriksssss
  • 380
  • 5
  • 6