Here is a playground https://playground.babylonjs.com/#VVM792 in which I attempt to build a toggle on/off switch out of a slider GUI control by setting the minimum to 0, maximum to 1 and a step of 1.
If I click slightly to the left of the circle, the circle “thumb” snaps to into the “off” position as expected. However if I click to the right of the circle, nothing happens. I expected that clicking to the right of the thumb should toggle the switch into the “on” position. Instead I have to drag the thumb to the right to get the thumb to toggle into the “on” position.
This playground demonstrates that, due to the bitwise OR operation with zero, which is essentially a Math.floor operation on the value, the slider value can never reach the maximum because it is always being round down. And the mouse coordinates that would be required to produce a value of the maximum lie just to the right of the toggle and aren’t reachable.
This isn’t just a problem between toggling between 0 and 1. In my new playground I set the maximum of 3, and if you click around you will see that the same issue happens. The maximum is unreachable by clicking and you the most you can get is 2.
I think perhaps this can be fixed by checking if step is 1 and then using regular Math.round on the value.
The toggle now correctly snaps to the maximum. Also works with other values of maximum and other values of step. Please try it out.
In the playground I monkey patched the prototype._updateValueFromPointer to keep everything in the original except the last line where I use Math.round.