playcanvas
Version:
PlayCanvas WebGL game engine
60 lines (58 loc) • 1.43 kB
JavaScript
/**
* @import { XrHand } from './xr-hand.js'
* @import { XrJoint } from './xr-joint.js'
*/ /**
* Represents a finger of a tracked {@link XrHand} with related joints and index.
*
* @category XR
*/ class XrFinger {
/**
* Gets the index of the finger. Enumeration is: thumb, index, middle, ring, little.
*
* @type {number}
*/ get index() {
return this._index;
}
/**
* Gets the hand that the finger belongs to.
*
* @type {XrHand}
*/ get hand() {
return this._hand;
}
/**
* Array of joints that belong to this finger, starting from joint closest to wrist all the way
* to the tip of a finger.
*
* @type {XrJoint[]}
*/ get joints() {
return this._joints;
}
/**
* Tip joint of the finger, or null if not available.
*
* @type {XrJoint|null}
*/ get tip() {
return this._tip;
}
/**
* Create a new XrFinger instance.
*
* @param {number} index - Index of the finger.
* @param {XrHand} hand - Hand that the finger belongs to.
* @ignore
*/ constructor(index, hand){
/**
* @type {XrJoint[]}
* @private
*/ this._joints = [];
/**
* @type {XrJoint|null}
* @private
*/ this._tip = null;
this._index = index;
this._hand = hand;
this._hand._fingers.push(this);
}
}
export { XrFinger };