From 910bcd40e190716f6e45348c943c7eea880bc54b Mon Sep 17 00:00:00 2001 From: Aaron Welles Date: Wed, 19 Jun 2019 01:45:23 -0400 Subject: [PATCH 1/2] .add( controller ) --- src/dat/gui/GUI.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/dat/gui/GUI.js b/src/dat/gui/GUI.js index 972c3073..49ec9760 100644 --- a/src/dat/gui/GUI.js +++ b/src/dat/gui/GUI.js @@ -168,7 +168,7 @@ const GUI = function(pars) { if (params.autoPlace && common.isUndefined(params.scrollable)) { params.scrollable = true; } -// params.scrollable = common.isUndefined(params.parent) && params.scrollable === true; + // params.scrollable = common.isUndefined(params.parent) && params.scrollable === true; // Not part of params because I don't want people passing this in via // constructor. Should be a 'remembered' value. @@ -1131,17 +1131,23 @@ function recallSavedValue(gui, controller) { } function add(gui, object, property, params) { - if (object[property] === undefined) { - throw new Error(`Object "${object}" has no property "${property}"`); - } - let controller; - if (params.color) { - controller = new ColorController(object, property); + if (object instanceof Controller) { + controller = object; } else { - const factoryArgs = [object, property].concat(params.factoryArgs); - controller = ControllerFactory.apply(gui, factoryArgs); + + if (object[property] === undefined) { + throw new Error(`Object "${object}" has no property "${property}"`); + } + + if (params.color) { + controller = new ColorController(object, property); + } else { + const factoryArgs = [object, property].concat(params.factoryArgs); + controller = ControllerFactory.apply(gui, factoryArgs); + } + } if (params.before instanceof Controller) { From 5730da37c4076f1232c6f613becf291e1a5bf913 Mon Sep 17 00:00:00 2001 From: AARON WELLES Date: Wed, 19 Jun 2019 02:21:21 -0400 Subject: [PATCH 2/2] .add( controller ) --- src/dat/gui/GUI.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dat/gui/GUI.js b/src/dat/gui/GUI.js index 49ec9760..aea13a60 100644 --- a/src/dat/gui/GUI.js +++ b/src/dat/gui/GUI.js @@ -168,7 +168,7 @@ const GUI = function(pars) { if (params.autoPlace && common.isUndefined(params.scrollable)) { params.scrollable = true; } - // params.scrollable = common.isUndefined(params.parent) && params.scrollable === true; +// params.scrollable = common.isUndefined(params.parent) && params.scrollable === true; // Not part of params because I don't want people passing this in via // constructor. Should be a 'remembered' value.