Search code examples
three.jsmotionleap-motionoculus

LEAP MOTION + OCULUS + THREE.JS: can't get "optimizeHMD = true" working (head mounted)


I attached the Leap Motion sensor to the Oculus Rift SDK2 device, in order to get my hands recognized from the 'head mounted' mode in a Three.js scene.

controller.use('handHold').use('transform', {
    optimizeHMD: true
  }).use('handEntry').use('screenPosition').use('riggedHand', {
    parent: scene,
    renderer: renderer,
    scale: getParam('scale'),
    positionScale: getParam('positionScale'),
    helper: false,
    offset: new THREE.Vector3(0, 0, 0),
    renderFn: function() {
      renderer.render(scene, camera);
      return controls.update();
    },
    materialOptions: {
      wireframe: true
    },
    dotsMode: getParam('dots'),
    stats: stats,
    camera: camera,
    boneLabels: function(boneMesh, leapHand) {
      if (boneMesh.name.indexOf('Finger_03') === 0) {
        return leapHand.pinchStrength;
      }
    },
    boneColors: function(boneMesh, leapHand) {
      if ((boneMesh.name.indexOf('Finger_0') === 0) || (boneMesh.name.indexOf('Finger_1') === 0)) {
        return {
          hue: 0.6,
          saturation: leapHand.pinchStrength
        };
      }
    },
    checkWebGL: true
  }).connect();

But I think the 'optimizeHMD = true' line is being ignored, the leap sensor still recognizes my hands like in Desktop Mode.

I'll appreciate some help!


Solution

  • I'm not very familiar with the Leap SDK, but I don't see any indication that optimizeHMD should be passed as an option to plugins, but rather is a state on the controller object that you need to set. Per this page and this example, during controller construction you can pass optimizeHMD as a parameter to the controller, or you can later call controller.setOptimizeHMD(true|false) to turn it on and off. However I don't see anything that says this is a valid option to pass to one of the controller plugins.

    I suspect that the translation between HMD and non-HMD modes probably happens at the controller level based on this flag, and the flag is simply being ignored by the transform plugin.