Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove configurable pinch distance properties
  • Loading branch information
cesmoak committed Oct 3, 2020
commit d48d92b0157332f2f86b2aed6d553df42509d733
2 changes: 0 additions & 2 deletions docs/components/hand-tracking-controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ 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 |
| endPinchDistance | Minimum distance between tip of thumb and index finger before a pinch gesture is ended. | 0.03 |

## Events

Expand Down
8 changes: 3 additions & 5 deletions src/components/hand-tracking-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ module.exports.Component = registerComponent('hand-tracking-controls', {
schema: {
hand: {default: 'right', oneOf: ['left', 'right']},
modelStyle: {default: 'mesh', oneOf: ['dots', 'mesh']},
modelColor: {default: 'white'},
startPinchDistance: {default: 0.015},
endPinchDistance: {default: 0.03}
modelColor: {default: 'white'}
},

bindMethods: function () {
Expand Down Expand Up @@ -219,14 +217,14 @@ module.exports.Component = registerComponent('hand-tracking-controls', {

var distance = indexTipPosition.distanceTo(thumbTipPosition);

if (distance < this.data.startPinchDistance && 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(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?

this.pinchEventDetail.position.y += 1.5;
this.el.emit('pinchstarted', this.pinchEventDetail);
}

if (distance > this.data.endPinchDistance && this.isPinched === true) {
if (distance > 0.03 && this.isPinched === true) {
this.isPinched = false;
this.pinchEventDetail.position.copy(indexTipPosition).lerp(thumbTipPosition, 0.5);
this.pinchEventDetail.position.y += 1.5;
Expand Down