Allow dot notation in property name
mistic100 opened this issue · comments
Damien Sorel commented
Hi
I think it woud be a good addition to allow the dot notation in the property name to allow using nested objects in controllers.
Example:
const config = {
center: { x: 807, y: 607 },
};
const gui = new GUI();
gui.add(config, 'center.x', 0, 1200);
gui.add(config, 'center.y', 0, 800);
Risks:
If someone has property names using a dot, it will break.
const config = {
'center.x': 807,
}
But who does that...
Alternatives:
In my case I can add getters and setters, but it is not always possible if the controller is a existing object from and external library or whatever.
const config = {
center: { x: 807, y: 607 },
get x() {
return this.center.x;
},
set x(x) {
this.center.x = x;
},
};
Thank you
Damien Sorel commented
I am dumb :-)
gui.add(config.center, 'x', 0, 1200).name('center.x');
gui.add(config.center, 'y', 0, 800).name('center.y');
Thanks for the lib !
georgealways commented
Not all—glad you figured it out!