Skip to content

Commit

Permalink
Use simple pinch end threshold avoiding repeated pinch starts
Browse files Browse the repository at this point in the history
  • Loading branch information
mrxz committed Nov 14, 2024
1 parent 9cdc304 commit 1463a92
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/components/hand-tracking-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var THUMB_TIP_INDEX = 4;
var INDEX_TIP_INDEX = 9;

var PINCH_START_DISTANCE = 0.015;
var PINCH_END_PERCENTAGE = 0.1;
var PINCH_END_DISTANCE = 0.02;

/**
* Controls for hand tracking
Expand Down Expand Up @@ -282,12 +282,11 @@ module.exports.Component = registerComponent('hand-tracking-controls', {

if (distance < PINCH_START_DISTANCE && this.isPinched === false) {
this.isPinched = true;
this.pinchDistance = distance;
pinchEventDetail.position.copy(indexTipPosition).add(thumbTipPosition).multiplyScalar(0.5);
this.el.emit('pinchstarted', pinchEventDetail);
}

if (distance > (this.pinchDistance + this.pinchDistance * PINCH_END_PERCENTAGE) && this.isPinched === true) {
if (distance > PINCH_END_DISTANCE && this.isPinched === true) {
this.isPinched = false;
pinchEventDetail.position.copy(indexTipPosition).add(thumbTipPosition).multiplyScalar(0.5);
this.el.emit('pinchended', pinchEventDetail);
Expand Down

0 comments on commit 1463a92

Please sign in to comment.