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

Input Support (Vive Controllers, Mouse, etc)

Michael Chang edited this page Sep 15, 2016 · 4 revisions

Because GUIVR lives entirely in WebGL, access to events and button presses are entirely custom-built.

Vive Controllers

  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).

Any Object3D

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.

Mouse

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.

Clone this wiki locally