Question

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");
Était-ce utile?

La solution

This creates a button with text left aligned.

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

gui.add(obj,'add');

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top