leva
leva copied to clipboard
Bug in the Button get function causing getting undefined, when Folder is used.
In this.get
in the Button codes, which is calling this.getInput
, which in turn relying on this.getData()[path]
.
When Folder is used for that useControls group, the actual "path" in this.getData() reads: "FolderName.VariableName" instead of only VariableName. Which will result in getting undefined if the FolderName string (include spaces) is not included in the "Button ... get( here )".
So my suggestion is either improve the definition of "path" or improve the documentation to require including FolderName (include space) when use Button, get, with Folder feature.
You can update the documentation.
We could upgrade get
in the case of a button to be relative to the folder, meaning if you wanted to retrieve values outside the folder you would have to do:
useControls({
myFolder1: folder({ value1: 0 }),
myFolder2: folder({ button2: button((get) => get('../myFolder1/value1')) })
})
...but that would require a bit of rewrite.
Maybe it was my misunderstanding about how the get should work. The problem with the current path is that if the folder name contains spaces then the getter would be used something like get( "folder name.VariableName" )
. But as said that maybe intended.
I have not followed the project along the way, none the less its a beautiful project, as a successor in React to dat.gui. Could you point where would u recommend to update in the docs, as in where should the mechanism of the "Path" in the getter be explained?