diff --git a/src/resources/webxr.js b/src/resources/webxr.js index 313a0ffc..f6ea53a8 100644 --- a/src/resources/webxr.js +++ b/src/resources/webxr.js @@ -273,7 +273,21 @@ var webxr = { }, webxr_getVelocity: function(device, velocity, angularVelocity) { - return false; // Unsupported, see immersive-web/webxr#619 + if (state.hands[device]) { + var space = state.hands[device].gripSpace || state.hands[device].targetRaySpace; + var pose = state.frame.getPose(space, state.space); + if (pose && pose.linearVelocity && pose.angularVelocity) { + HEAPF32[(velocity >> 2) + 0] = pose.linearVelocity.x; + HEAPF32[(velocity >> 2) + 1] = pose.linearVelocity.y; + HEAPF32[(velocity >> 2) + 2] = pose.linearVelocity.z; + HEAPF32[(angularVelocity >> 2) + 0] = pose.angularVelocity.x; + HEAPF32[(angularVelocity >> 2) + 1] = pose.angularVelocity.y; + HEAPF32[(angularVelocity >> 2) + 2] = pose.angularVelocity.z; + return true; + } + } + + return false; }, webxr_isDown: function(device, button, down, changed) {