Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Creating Controllers

Michael Chang edited this page Oct 21, 2016 · 5 revisions

To add controllers, first you must have a GUI to add it to.

Create a new GUI

const gui = dat.GUIVR.create( 'settings' );
scene.add( gui );

Sliders

gui.add( object, 'numericProperty', min, max );

Sliders have a step function which forces the value to be within the specified increment.

gui.add( object, 'property', min, max ).step( 0.1 );

Checkboxes

gui.add( state, 'boolProperty' );

If state.boolProperty = true or false then the controller will become a checkbox.

Dropdowns

folder.add( state, 'anyProperty', arrayOrObject );

If the third argument is an array or object, the controller will become a dropdown with those options.

Buttons

gui.add( state, 'functionProperty' );

If state.functionProperty is a function then the controller will become a button and the function will run whenever you press it.