webxr: also support velocity of head device;
@@ -273,9 +273,17 @@ var webxr = {
},
webxr_getVelocity: function(device, velocity, angularVelocity) {
- if (state.hands[device]) {
+ var pose;
+
+ if (device === 0 /* DEVICE_HEAD */) {
+ pose = state.viewer;
+ } else if (state.hands[device]) {
var space = state.hands[device].gripSpace || state.hands[device].targetRaySpace;
- var pose = state.frame.getPose(space, state.space);
+ pose = state.frame.getPose(space, state.space);
+ } else {
+ return false;
+ }
+
if (pose && pose.linearVelocity && pose.angularVelocity) {
HEAPF32[(velocity >> 2) + 0] = pose.linearVelocity.x;
HEAPF32[(velocity >> 2) + 1] = pose.linearVelocity.y;
@@ -285,7 +293,6 @@ var webxr = {
HEAPF32[(angularVelocity >> 2) + 2] = pose.angularVelocity.z;
return true;
}
- }
return false;
},
