Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haptics #29

Open
lojjic opened this issue Apr 13, 2020 · 9 comments
Open

Haptics #29

lojjic opened this issue Apr 13, 2020 · 9 comments
Milestone

Comments

@lojjic
Copy link

lojjic commented Apr 13, 2020

This is a feature request for a formalized API for haptic feedback on WebXR gamepad inputs, when available. Even very simple haptics can greatly increase immersion and usability in XR applications.

The Gamepad Extensions draft defines a simple interface for pulsing haptic actuators, and that did already have some decent browser support in WebVR. That spec contains other extensions (hand and pose) that seem obsolete, however, so it may be good to respec it in a webxr module.

Or, that may not be ideal in WebXR's more robust model -- e.g looking forward to more complex haptic hardware, haptics on gamepad-less input sources, etc. -- in which case it would need a new API.

Refs:
https://twitter.com/Tojiro/status/1249787874708303873
immersive-web/webvr#23
https://w3c.github.io/gamepad/extensions.html#gamepadhapticactuator-interface

@Artyom17
Copy link

Artyom17 commented Apr 15, 2020

Just FYI, Oculus Browser 8.5 (ETA end of this week) will have experimental support for haptics via adding hapticActuators / pulse into the gamepad object. The sample can be seen here: https://github.com/Artyom17/webxr-samples/blob/gh-pages/controller-state.html

@toji
Copy link
Member

toji commented Apr 16, 2020

That's great to hear, @Artyom17! I've very curious to see how that works out and what bumps (if any) you hit along the way. It'll be very informative for the rest of the group.

@Manishearth Manishearth added this to the Future milestone Apr 17, 2020
@Artyom17
Copy link

@toji It was pretty straight forward port of whatever I had for WebVR. In JS code it looks like this:

        if ("hapticActuators" in gamepad && gamepad.hapticActuators.length > 0) {
          for (let j = 0; j < gamepad.buttons.length; ++j) {
            if (gamepad.buttons[j].pressed) {
              // Vibrate the gamepad using to the value of the button as
              // the vibration intensity, normalized to 0.0..1.0 range.
              gamepad.hapticActuators[0].pulse((j + 1.0) / (gamepad.buttons.length + 1), 1000);
              break;
            }
          }

@ngokevin
Copy link

ngokevin commented Apr 30, 2020

@Artyom17 Is the experimental API still around?

@RaananW
Copy link

RaananW commented Apr 30, 2020

Working wonderfully on the quest. Integrated in Babylon.js already - https://github.com/BabylonJS/Babylon.js/blob/master/src/XR/motionController/webXRAbstractMotionController.ts#L410

@De-Panther
Copy link

Also works at https://github.com/De-Panther/unity-webxr-export
It was the simplest WebXR related feature to add so far.

@julianfrank
Copy link

Working wonderfully on the quest. Integrated in Babylon.js already - https://github.com/BabylonJS/Babylon.js/blob/master/src/XR/motionController/webXRAbstractMotionController.ts#L410

Is there a sample code for this?

@RaananW
Copy link

RaananW commented May 9, 2022

Working wonderfully on the quest. Integrated in Babylon.js already - https://github.com/BabylonJS/Babylon.js/blob/master/src/XR/motionController/webXRAbstractMotionController.ts#L410

Is there a sample code for this?

Sure - https://playground.babylonjs.com/#9K3MRA#854

@julianfrank
Copy link

Working wonderfully on the quest. Integrated in Babylon.js already - https://github.com/BabylonJS/Babylon.js/blob/master/src/XR/motionController/webXRAbstractMotionController.ts#L410

I can second that now... works like a charm now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants