modules/datguivr/index.js
/*
    Public function users run to give DAT GUI an input device.
    Automatically detects for ViveController and binds buttons + haptic feedback.

    Returns a laser pointer so it can be directly added to scene.

    The laser will then have two methods:
    laser.pressed(), laser.gripped()

    These can then be bound to any button the user wants. Useful for binding to
    cardboard or alternate input devices.

    For example...
      document.addEventListener( 'mousedown', function(){ laser.pressed( true ); } );
  */
Public function users run to give DAT GUI an input device.
Automatically detects for ViveController and binds buttons + haptic feedback.

Returns a laser pointer so it can be directly added to scene.



These can then be bound to any button the user wants. Useful for binding to
cardboard or alternate input devices.

For example
document.addEventListener( 'mousedown', function(){ laser.pressed( true ); } ).
Public function users run to give DAT GUI an input device . Automatically detects for ViveController and binds buttons + haptic feedback . Returns a laser pointer so it can be directly added to scene . These can then be bound to any button the user wants . Useful for binding to cardboard or alternate input devices . For example document . addEventListener ( ' mousedown ' function () { laser . pressed ( true ) ; } ) .
function addInputObject( object ){
    const input = createInput( object );
    input.laser.pressed = function( flag ){
      const hits = input.intersections;
      if (flag && hits && (hits.length > 0)) {
        input.pressed = true;
        input.clicked = true;
      } else {
        input.pressed = false;
      }
    };
    input.laser.gripped = function( flag ){
      input.gripped = flag;
    };
    input.laser.cursor = input.cursor;
    if( THREE.ViveController && object instanceof THREE.ViveController ){
      bindViveController( input, object, input.laser.pressed, input.laser.gripped );
    }
    inputObjects.push( input );
    return input.laser;
  }
function addInputObject ( object ) { const input = createInput ( object ) ; input . laser . pressed = function ( flag ) { const hits = input . intersections ; if ( flag && hits && ( hits . length > 0 ) ) { input . pressed = true ; input . clicked = true ; } else { input . pressed = false ; } } ; input . laser . gripped = function ( flag ) { input . gripped = flag ; } ; input . laser . cursor = input . cursor ; if ( THREE . ViveController && object instanceof THREE . ViveController ) { bindViveController ( input , object , input . laser . pressed , input . laser . gripped ) ; } inputObjects . push ( input ) ; return input . laser ; }
Public function users run to give DAT GUI an input device.
Public function users run to give DAT GUI an input device .
// only pay attention to presses over the GUI