-
Notifications
You must be signed in to change notification settings - Fork 48
Input Support (Vive Controllers, Mouse, etc)
Because GUIVR lives entirely in WebGL, access to events and button presses are entirely custom-built.
const input = gui.addInputObject( viveController );
scene.add( input );
ViveController in this case is an instance of THREE.ViveController.
If a THREE.ViveController is given to gui.addInputObject(), then GUIVR will automatically bind the relevant interactivity (trigger, grip, haptic feedback).
gui.addInputObject() can take anything of type THREE.Object3D. This means you can add cameras, lights, arbitrary 3D meshes as input objects to GUIVR.
gui.addInputObject() returns an Input object which represents a laser pointer that gets internally updated. The laser is only shown when it crosses any of GUIVR's panels.
The Input object also has the following methods:
pressed( flag )gripped( flag )
These allow you to bind anything to GUIVR's inputs. For example you can make a mouse click on the browser trigger an input 'press' by doing:
document.addEventListener( 'mousedown', function(){ laser.pressed( true ); } );
This is useful for adding things like Google Cardboard which won't have native button presses but rely on touching the browser surface to emulate a press event.
By default GUIVR binds the mouse from the browser as an input type. You don't have to do anything, simply not enable VR and you can click and drag any slider or push any button on GUIVR.