Skip to main content

Class: Hands

Defined in: src/input/Hands.ts:25

Represents and provides access to WebXR hand tracking data. Uses the 'handedness' property of input hands for identification.

Constructors

Constructor

new Hands(hands): Hands

Defined in: src/input/Hands.ts:31

Parameters

hands

XRHandSpace[]

An array containing XRHandSpace objects from Three.js.

Returns

Hands

Properties

dominant

dominant: Handedness = Handedness.RIGHT

Defined in: src/input/Hands.ts:26


hands

hands: XRHandSpace[]

Defined in: src/input/Hands.ts:31

An array containing XRHandSpace objects from Three.js.

Methods

getIndexTip()

getIndexTip(handedness): undefined | XRJointSpace

Defined in: src/input/Hands.ts:70

Gets the index finger tip joint.

Parameters

handedness

Handedness = Handedness.NONE

Optional handedness ('left'/'right'), defaults to NONE (uses dominant hand).

Returns

undefined | XRJointSpace

The joint object or null.


getJoint()

getJoint(jointName, targetHandednessEnum): undefined | XRJointSpace

Defined in: src/input/Hands.ts:44

Retrieves a specific joint object for a given hand.

Parameters

jointName

The name of the joint to retrieve (e.g., 'index-finger-tip').

"wrist" | "thumb-metacarpal" | "thumb-phalanx-proximal" | "thumb-phalanx-distal" | "thumb-tip" | "index-finger-metacarpal" | "index-finger-phalanx-proximal" | "index-finger-phalanx-intermediate" | "index-finger-phalanx-distal" | "index-finger-tip" | "middle-finger-metacarpal" | "middle-finger-phalanx-proximal" | "middle-finger-phalanx-intermediate" | "middle-finger-phalanx-distal" | "middle-finger-tip" | "ring-finger-metacarpal" | "ring-finger-phalanx-proximal" | "ring-finger-phalanx-intermediate" | "ring-finger-phalanx-distal" | "ring-finger-tip" | "pinky-finger-metacarpal" | "pinky-finger-phalanx-proximal" | "pinky-finger-phalanx-intermediate" | "pinky-finger-phalanx-distal" | "pinky-finger-tip"

targetHandednessEnum

Handedness

The hand enum value (Handedness.LEFT or Handedness.RIGHT) to retrieve the joint from. If Handedness.NONE, uses the dominant hand.

Returns

undefined | XRJointSpace

The requested joint object, or null if not found or invalid input.


getMiddleTip()

getMiddleTip(handedness): undefined | XRJointSpace

Defined in: src/input/Hands.ts:92

Gets the middle finger tip joint.

Parameters

handedness

Handedness = Handedness.NONE

Optional handedness ('left'/'right'), defaults to NONE (uses dominant hand).

Returns

undefined | XRJointSpace

The joint object or null.


getPinkyTip()

getPinkyTip(handedness): undefined | XRJointSpace

Defined in: src/input/Hands.ts:114

Gets the pinky finger tip joint.

Parameters

handedness

Handedness = Handedness.NONE

Optional handedness ('left'/'right'), defaults to NONE (uses dominant hand).

Returns

undefined | XRJointSpace

The joint object or null.


getRingTip()

getRingTip(handedness): undefined | XRJointSpace

Defined in: src/input/Hands.ts:103

Gets the ring finger tip joint.

Parameters

handedness

Handedness = Handedness.NONE

Optional handedness ('left'/'right'), defaults to NONE (uses dominant hand).

Returns

undefined | XRJointSpace

The joint object or null.


getThumbTip()

getThumbTip(handedness): undefined | XRJointSpace

Defined in: src/input/Hands.ts:81

Gets the thumb tip joint.

Parameters

handedness

Handedness = Handedness.NONE

Optional handedness ('left'/'right'), defaults to NONE (uses dominant hand).

Returns

undefined | XRJointSpace

The joint object or null.


getWrist()

getWrist(handedness): undefined | XRJointSpace

Defined in: src/input/Hands.ts:125

Gets the wrist joint.

Parameters

handedness

Handedness = Handedness.NONE

Optional handedness enum value (LEFT/RIGHT/NONE), defaults to NONE (uses dominant hand).

Returns

undefined | XRJointSpace

The joint object or null.


isValid()

isValid(handIndex?): boolean

Defined in: src/input/Hands.ts:233

Checks for the availability of hand data. If an integer (0 for LEFT, 1 for RIGHT) is provided, it checks for that specific hand. If no integer is provided, it checks that data for both hands is available.

Parameters

handIndex?

number

Optional. The index of the hand to validate (0 or 1).

Returns

boolean

true if the specified hand(s) have data, false otherwise.


toPositionQuaternionArray()

toPositionQuaternionArray(): number[]

Defined in: src/input/Hands.ts:175

Converts the pose data (position and quaternion) of all joints for both hands into a single flat array. Each joint is represented by 7 numbers (3 for position, 4 for quaternion). Missing joints or hands are represented by zeros. Ensures a consistent output order: all left hand joints first, then all right hand joints.

Returns

number[]

A flat array containing position (x, y, z) and quaternion (x, y, z, w) data for all joints, ordered [left..., right...]. Size is always 2 * HAND_JOINT_NAMES.length * 7.


toString()

toString(): string

Defined in: src/input/Hands.ts:135

Generates a string representation of the hand joint data for both hands. Always lists LEFT hand data first, then RIGHT hand data, if available.

Returns

string

A string containing position data for all available joints.