georgealways/lil-gui

BooleanController.setValue does not coerce non-boolean values

thomb6n opened this issue · 4 comments

When I add a checkbox for a property that can be either true or false, like the wireframe, everything works when using setValue(true) or setValue(false). When I use setValue(1) however, the debug panel shows the checkbox checked, but it doesn't apply the right value to the property. In the case of the wireframe, it still shows all the faces.

Got it—so you're expecting setValue to convert that parameter to a true/false value before actually assigning the property? Curious which 3D library you're using. And after you do this, the value of whatever.wireframe === 1? Thanks

I'm using Three.js. I think converting would be the best solution, an alternative might be to throw an error when not providing true of false instead of having the checkbox checked in the GUI. In my case, "cube.wireframe" was checked as being enabled in the GUI, but it was not actually enabled.

Thanks—let me think on this a little. None of the other controllers do any validating/converting. Right now I like how setValue is "what you set is what you get", but it might be worth making an exception for booleans.

No worries, it's not a big deal to me, just felt like a small "bug" worth letting you know about. Thanks for considering!