dataarts / dat.gui

Lightweight controller library for JavaScript.
Apache License 2.0
7.51k stars 1.09k forks source link

How can I find out what parameters a specified function takes? #285

Open daiedy opened 3 years ago

daiedy commented 3 years ago

image Please add parameters and what this function should return to the documentation

backspaces commented 3 years ago

I believe the fcn's arg is just the controllers value.

  gui.add(controller, 'width', 100, 1000, 25).onChange(width => {
        view.setWidth(width)
  })
backspaces commented 3 years ago

Oh, and many times with an onChange, you really don't care about the actual controller.width value, you only want to call a function with that value like above.

A sneaky trick is to just have a one-parameter "controller" that is not used elsewhere:

    gui.add({ width: 700 }, 'width', 100, 1000, 25).onChange(val => {
         view.setWidth(val)
    })