Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve pinching accuracy (fixes #4689) #4691

Merged
merged 4 commits into from
Oct 5, 2020

Conversation

cesmoak
Copy link
Contributor

@cesmoak cesmoak commented Sep 30, 2020

Description: As discussed in #4689, this PR improves pinching accuracy by 1) adjusting the distance between thumb and index finger needed to start the gesture, and by 2) moving the position pinch events report to the halfway point between the thumb and index finger.

Changes proposed:

  • The min distance between thumb and index fingertips to start a pinch gesture is changed to be 0.015.
  • Two new properties are exposed on hand-tracking-controls: startPinchDistance, which defaults to 0.015 and endPinchDistance, which defaults to 0.03.
  • The position property for pinchstarted, pinchmoved, and pinchended events is moved to the halfway point between thumb and index fingertips.
  • Checks are added to tests to sanity-check the pinch event position.

@@ -25,7 +25,8 @@ Use `hand-tracking-controls` to integrate [hand tracked input][webxrhandinput] i
| hand | The hand that will be tracked (i.e., right, left). | left |
| modelColor | Color of hand material. | white |
| modelStyle | Mesh representing the hand or dots matching the joints | mesh

| startPinchDistance | Maximum distance between tip of thumb and index finger before a pinch gesture is started. | 0.015 |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make it configurable? Is not a value that clearly works better for most cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the best value I've found from my personal tests--happy to hardcode for that. The even better approach would use the radius property of the joint poses, but maybe best to wait until we have more than one example piece of hardware to determine the best number using that. If you confirm, I'll remove both configurable properties.

Copy link
Member

@dmarcos dmarcos Oct 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove the properties, use 0.015 and adjust later if needed. Just keep the API simpler. Still a lot to learn about hand tracking 😃

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest commit removes the properties.

@@ -8,6 +8,8 @@ suite('tracked-controls-webxr', function () {
var standingMatrix = new THREE.Matrix4();
var index = {transform: {position: {x: 0, y: 0, z: 0}}};
var thumb = {transform: {position: {x: 0, y: 0, z: 0}}};
var indexPosition = new THREE.Vector3();
var thumbPosition = new THREE.Vector3();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of the tests 🏅

@@ -217,22 +217,22 @@ module.exports.Component = registerComponent('hand-tracking-controls', {

var distance = indexTipPosition.distanceTo(thumbTipPosition);

if (distance < 0.01 && this.isPinched === false) {
if (distance < 0.015 && this.isPinched === false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can maybe move this to a variable at the top var PINCH_DISTANCE = 0.015 . We use similar pattern in other components

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in the latest commit

this.isPinched = true;
this.pinchEventDetail.position.copy(indexTipPose.transform.position);
this.pinchEventDetail.position.copy(indexTipPosition).lerp(thumbTipPosition, 0.5);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the 0.5 value for? Maybe define another variable on top?

@dmarcos dmarcos merged commit da23899 into aframevr:master Oct 5, 2020
@dmarcos
Copy link
Member

dmarcos commented Oct 5, 2020

Thanks! Congrats on your first PR 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants