engine icon indicating copy to clipboard operation
engine copied to clipboard

WebXR Input Source: linear velocity

Open Maksims opened this issue 4 years ago • 2 comments

Linear Velocity has been added for handheld devices in WebXR specs: https://pr-preview.s3.amazonaws.com/cabanier/webxr/pull/1182.html#dom-xrpose-linearvelocity

This also been implemented in the latest Oculus Browser: https://twitter.com/rcabanier/status/1377459759876505606

This PR implements input source linear velocity and also emulates it with the same logic if it is not available/supported. So if the input source has a grip space - we guarantee to provide linear velocity.

New APIs:

// pc.XrInputSource
inputSource.getLinearVelocity() // Vec3 with world space linear velocity in units per second, or null if input source is not handheld

I confirm I have signed the Contributor License Agreement.

Maksims avatar Apr 01 '21 18:04 Maksims

How about returning a zero vector if it is not available? This would match the behavior we get when trying to read the velocity of a kinematic or static rigidbody in physics.

LeXXik avatar Apr 01 '21 19:04 LeXXik

How about returning a zero vector if it is not available? This would match the behavior we get when trying to read the velocity of a kinematic or static rigidbody in physics.

There are input sources that have no such concept as position, for example: touch in AR session, or voice commands input source, or gaze style input source. So we should not provide linear velocity for such types, just like we don't provide position and rotation data for such input sources. So it stays consistent for XR input source concepts.

Maksims avatar Apr 01 '21 21:04 Maksims

Would love to get a second look at this PR, so it can be merged/resolved.

Maksims avatar Nov 14 '23 08:11 Maksims