-
Notifications
You must be signed in to change notification settings - Fork 16
/
gui.js
48 lines (41 loc) · 974 Bytes
/
gui.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import * as dat from 'dat.gui'
export default class GuiManager {
constructor () {
// Create the gui
this.gui = new dat.GUI()
this.guiFunctions = {}
}
add (object, param, rangeMin, rangeMax) {
if (rangeMin) {
this.gui.add(object, param, rangeMin, rangeMax)
} else {
this.gui.add(object, param)
}
}
addVector3 (vector, folder) {
if (folder) {
this.folder = this.gui.addFolder(folder)
}
for (let child in vector) {
if (child === 'x' || child === 'y' || child === 'z') {
if (folder) {
this.folder.add(vector, child)
} else {
this.gui.add(vector, child)
}
}
}
}
addObject (object) {
for (let child in object) {
this.gui.add(object, child)
}
}
addFunction (name, callback) {
let buttonName = name.toString()
this.guiFunctions = {
[buttonName]: callback
}
this.gui.add(this.guiFunctions, buttonName)
}
}