From 5dcf696410ed9c80a38d1e905b370bffe09b0152 Mon Sep 17 00:00:00 2001 From: Noeri Huisman <8823461+mrxz@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:52:23 +0100 Subject: [PATCH] Use simple pinch end threshold avoiding repeated pinch starts --- src/components/hand-tracking-controls.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/hand-tracking-controls.js b/src/components/hand-tracking-controls.js index d6658949915..1755b68899f 100644 --- a/src/components/hand-tracking-controls.js +++ b/src/components/hand-tracking-controls.js @@ -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 @@ -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);