Open lojjic opened 4 years ago
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
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.
@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;
}
}
@Artyom17 Is the experimental API still around?
Working wonderfully on the quest. Integrated in Babylon.js already - https://github.com/BabylonJS/Babylon.js/blob/master/src/XR/motionController/webXRAbstractMotionController.ts#L410
Also works at https://github.com/De-Panther/unity-webxr-export It was the simplest WebXR related feature to add so far.
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?
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?
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
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
andpose
) 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.