Skip to content

Commit 5dcf696

Browse files
committed
Use simple pinch end threshold avoiding repeated pinch starts
1 parent c3b5363 commit 5dcf696

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/components/hand-tracking-controls.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var THUMB_TIP_INDEX = 4;
4343
var INDEX_TIP_INDEX = 9;
4444

4545
var PINCH_START_DISTANCE = 0.015;
46-
var PINCH_END_PERCENTAGE = 0.1;
46+
var PINCH_END_DISTANCE = 0.02;
4747

4848
/**
4949
* Controls for hand tracking
@@ -282,12 +282,11 @@ module.exports.Component = registerComponent('hand-tracking-controls', {
282282

283283
if (distance < PINCH_START_DISTANCE && this.isPinched === false) {
284284
this.isPinched = true;
285-
this.pinchDistance = distance;
286285
pinchEventDetail.position.copy(indexTipPosition).add(thumbTipPosition).multiplyScalar(0.5);
287286
this.el.emit('pinchstarted', pinchEventDetail);
288287
}
289288

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

0 commit comments

Comments
 (0)