dataarts / dat.gui

Lightweight controller library for JavaScript.
Apache License 2.0
7.46k stars 1.08k forks source link

Step should be based on the minimum and or maximum values #291

Open Robyt3 opened 3 years ago

Robyt3 commented 3 years ago

My use case is this:

folder.add(settings, 'numColors').min(1).max(101).step(2).name('Number of colors');

where I want the number of colors to be an odd number.

Once I change the slider in the GUI thou, the number will be changed to an even number.

This appears to be the relevant code segment:

https://github.com/dataarts/dat.gui/blob/51d1a37b00326c232f34d9b80dc6dea2bec8595b/src/dat/controllers/NumberController.js#L71-L73

The _v % this.__step !== 0 checks the parity of the value, which should take into account if the minimum/maximum value has a different parity.