Details about the classes, methods, and properties provided by dat.GUI. For more hands-on examples, see the dat.GUI tutorial.
A lightweight controller library for JavaScript. It allows you to easily manipulate variables and fire functions on the fly.
An "abstract" class that represents a given property of an object.
dat.controllers.ControllerRepresents a given property of an object that is a number.
A lightweight controller library for JavaScript. It allows you to easily manipulate variables and fire functions on the fly.
Kind: global class
DOMElementdat.gui.GUIBooleanBooleanStringNumberStringBooleanObjectBooleanControllerControllerdat.gui.GUIdat.gui.GUIObject| Param | Type | Default | Description |
|---|---|---|---|
| [params] | Object |
||
| [params.name] | String |
The name of this GUI. | |
| [params.load] | Object |
JSON object representing the saved state of this GUI. | |
| [params.parent] | dat.gui.GUI |
The GUI I’m nested in. | |
| [params.autoPlace] | Boolean |
true |
|
| [params.hideable] | Boolean |
true |
If true, GUI is shown/hidden by h keypress. |
| [params.closed] | Boolean |
false |
If true, starts closed |
| [params.closeOnTop] | Boolean |
false |
If true, close/open button shows on top of the GUI |
Example
// Creating a GUI with options.
var gui = new dat.GUI({name: 'My GUI'});
Example
// Creating a GUI and a subfolder.
var gui = new dat.GUI();
var folder1 = gui.addFolder('Flow Field');
DOMElementOutermost DOM Element
Kind: instance property of GUI
dat.gui.GUIThe parent GUI
Kind: instance property of GUI
BooleanHandles GUI’s element placement for you
Kind: instance property of GUI
BooleanHandles GUI’s position of open/close button
Kind: instance property of GUI
StringThe identifier for a set of saved values
Kind: instance property of GUI
NumberThe width of GUI element
Kind: instance property of GUI
StringThe name of GUI. Used for folders. i.e
a folder’s name
Kind: instance property of GUI
BooleanWhether the GUI is collapsed or not
Kind: instance property of GUI
ObjectContains all presets
Kind: instance property of GUI
BooleanDetermines whether or not to use localStorage as the means for
remembering
Kind: instance property of GUI
ControllerAdds a new Controller to the GUI. The type of controller created
is inferred from the initial value of object[property]. For
color properties, see addColor.
Kind: instance method of GUI
Returns: Controller - The controller that was added to the GUI.
| Param | Type | Description |
|---|---|---|
| object | Object |
The object to be manipulated |
| property | String |
The name of the property to be manipulated |
| [min] | Number |
Minimum allowed value |
| [max] | Number |
Maximum allowed value |
| [step] | Number |
Increment by which to change value |
Example
// Add a string controller.
var person = {name: 'Sam'};
gui.add(person, 'name');
Example
// Add a number controller slider.
var person = {age: 45};
gui.add(person, 'age', 0, 100);
ControllerAdds a new color controller to the GUI.
Kind: instance method of GUI
Returns: Controller - The controller that was added to the GUI.
| Param |
|---|
| object |
| property |
Example
var palette = {
color1: '#FF0000', // CSS string
color2: [ 0, 128, 255 ], // RGB array
color3: [ 0, 128, 255, 0.3 ], // RGB with alpha
color4: { h: 350, s: 0.9, v: 0.3 } // Hue, saturation, value
};
gui.addColor(palette, 'color1');
gui.addColor(palette, 'color2');
gui.addColor(palette, 'color3');
gui.addColor(palette, 'color4');
Removes the given controller from the GUI.
Kind: instance method of GUI
| Param | Type |
|---|---|
| controller | Controller |
Removes the root GUI from the document and unbinds all event listeners.
For subfolders, use gui.removeFolder(folder) instead.
Kind: instance method of GUI
dat.gui.GUICreates a new subfolder GUI instance.
Kind: instance method of GUI
Returns: dat.gui.GUI - The new folder.
Throws:
Error if this GUI already has a folder by the specified
name| Param |
|---|
| name |
Removes a subfolder GUI instance.
Kind: instance method of GUI
| Param | Type | Description |
|---|---|---|
| folder | dat.gui.GUI |
The folder to remove. |
Opens the GUI.
Kind: instance method of GUI
Closes the GUI.
Kind: instance method of GUI
Hides the GUI.
Kind: instance method of GUI
Shows the GUI.
Kind: instance method of GUI
dat.gui.GUIKind: instance method of GUI
Returns: dat.gui.GUI - the topmost parent GUI of a nested GUI.
ObjectKind: instance method of GUI
Returns: Object - a JSON object representing the current state of
this GUI as well as its remembered properties.
An “abstract” class that represents a given property of an object.
Kind: global class
DOMElementObjectStringControllerControllerControllerControllerControllerControllerObjectControllerBoolean| Param | Type | Description |
|---|---|---|
| object | Object |
The object to be manipulated |
| property | string |
The name of the property to be manipulated |
DOMElementThose who extend this class will put their DOM elements in here.
Kind: instance property of Controller
ObjectThe object to manipulate
Kind: instance property of Controller
StringThe name of the property to manipulate
Kind: instance property of Controller
ControllerKind: instance method of Controller
| Param | Type |
|---|---|
| options | Array | Object |
ControllerSets the name of the controller.
Kind: instance method of Controller
| Param | Type |
|---|---|
| name | string |
ControllerSets controller to listen for changes on its underlying object.
Kind: instance method of Controller
ControllerRemoves the controller from its parent GUI.
Kind: instance method of Controller
ControllerSpecify that a function fire every time someone changes the value with this Controller.
Kind: instance method of Controller
Returns: Controller - this
| Param | Type | Description |
|---|---|---|
| fnc | function |
This function will be called whenever the value is modified via this Controller. |
ControllerSpecify that a function fire every time someone “finishes” changing the value wih this Controller. Useful for values that change incrementally like numbers or strings.
Kind: instance method of Controller
Returns: Controller - this
| Param | Type | Description |
|---|---|---|
| fnc | function |
This function will be called whenever someone “finishes” changing the value via this Controller. |
Change the value of object[property]
Kind: instance method of Controller
| Param | Type | Description |
|---|---|---|
| newValue | Object |
The new value of object[property] |
ObjectGets the value of object[property]
Kind: instance method of Controller
Returns: Object - The current value of object[property]
ControllerRefreshes the visual display of a Controller in order to keep sync with the object’s current value.
Kind: instance method of Controller
Returns: Controller - this
BooleanKind: instance method of Controller
Returns: Boolean - true if the value has deviated from initialValue
dat.controllers.ControllerRepresents a given property of an object that is a number.
Kind: global class
Extends: dat.controllers.Controller
dat.controllers.Controller
dat.controllers.NumberControllerdat.controllers.NumberControllerdat.controllers.NumberController| Param | Type | Description |
|---|---|---|
| object | Object |
The object to be manipulated |
| property | string |
The name of the property to be manipulated |
| [params] | Object |
Optional parameters |
| [params.min] | Number |
Minimum allowed value |
| [params.max] | Number |
Maximum allowed value |
| [params.step] | Number |
Increment by which to change value |
dat.controllers.NumberControllerSpecify a minimum value for object[property].
Kind: instance method of NumberController
Returns: dat.controllers.NumberController - this
| Param | Type | Description |
|---|---|---|
| minValue | Number |
The minimum value for object[property] |
dat.controllers.NumberControllerSpecify a maximum value for object[property].
Kind: instance method of NumberController
Returns: dat.controllers.NumberController - this
| Param | Type | Description |
|---|---|---|
| maxValue | Number |
The maximum value for object[property] |
dat.controllers.NumberControllerSpecify a step value that dat.controllers.NumberController increments by.
Kind: instance method of NumberController
Default: if minimum and maximum specified increment is 1% of the
difference otherwise stepValue is 1
Returns: dat.controllers.NumberController - this
| Param | Type | Description |
|---|---|---|
| stepValue | Number |
The step value for dat.controllers.NumberController |