After looking into it a bit more I think I found the underlying issue:
https://github.com/BabylonJS/Babylon.js/commit/800885feadfd88d459c3223a98776e995e12b7ec
The slider has an _updateValueFromPointer function that takes the pointer’s x,y coordinates and computes the value for the slider:
value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
}
var mult = (1 / this._step) | 0;
this.value = this._step ? ((value * mult) | 0) / mult : value;
I have setup a new playground that console logs these intermediate values as you mouse over the toggle switch:
https://playground.babylonjs.com/#VVM792#6
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.
@Deltakosh what do you think?