georgealways / lil-gui

Makes a floating panel for controllers on the web. Works as a drop-in replacement for dat.gui in most projects.

Home Page:https://lil-gui.georgealways.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow dot notation in property name

mistic100 opened this issue · comments

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

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 !

Not all—glad you figured it out!