Skip to content

Commit 1d299eb

Browse files
Adds all registered colors on the colors controller
1 parent 4e165c2 commit 1d299eb

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

examples/assets/color_camera_gui.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ function initGUIControllers(tracker) {
44
var gui = new dat.GUI();
55

66
var trackedColors = {
7-
cyan: true,
8-
magenta: true,
9-
yellow: true,
107
custom: false
118
};
129

10+
Object.keys(tracking.ColorTracker.knownColors_).forEach(function(color) {
11+
trackedColors[color] = true;
12+
});
13+
1314
tracker.customColor = '#000000';
1415

1516
function createCustomColor(value) {
@@ -67,9 +68,12 @@ function initGUIControllers(tracker) {
6768

6869
var colorsFolder = gui.addFolder('Colors');
6970

70-
colorsFolder.add(trackedColors, 'cyan').onFinishChange(updateColors);
71-
colorsFolder.add(trackedColors, 'magenta').onFinishChange(updateColors);
72-
colorsFolder.add(trackedColors, 'yellow').onFinishChange(updateColors);
71+
Object.keys(trackedColors).forEach(function(color) {
72+
if (color !== 'custom') {
73+
colorsFolder.add(trackedColors, color).onFinishChange(updateColors);
74+
}
75+
});
76+
7377
colorsFolder.add(trackedColors, 'custom').onFinishChange(function(value) {
7478
if (value) {
7579
this.customColorElement = colorsFolder.addColor(tracker, 'customColor').onChange(createCustomColor);

0 commit comments

Comments
 (0)