mirror of https://github.com/bjornbytes/lovr.git
webxr: Add support for lovr.headset.getVelocity;
This commit is contained in:
parent
35032bb21c
commit
72403de209
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue