This document describes a design giving developers access to body-tracking XR systems, building on top of the WebXR device API
This API primarily exposes the joints of a person's body. It can be used to render an avatar in VR scenarios. It does not provide access to a full hbodynd mesh.
This API will only be accessible if a body-tracking"
XR feature is requested.
This API presents itself as an additional field on XRFrame
, body
. The body
attribute will be non-null if the XR device supports hand tracking and the feature has been requested.
navigator.xr.requestSession({optionalFeatures: ["body-tracking"]}).then(...);
function renderFrame(session, frame) {
// ...
if (frame.body.hand) {
// render a body
}
}
}
Each body is made up many bones, connected by joints. We name them with their connected bone, for example index-finger-phalanx-distal
is the joint closer to the wrist connected to the distal phalanx bone of the index finger. The *-tip
"joints" locate the tips of the fingers. The wrist
joint is located at the composite joint between the wrist and forearm.
The joint spaces can be accessed via XRBody.get()
, for example to access the leftmiddle knuckle joint one would use:
let joint = inputSource.hand.get("left-middle-finger-phalanx-distal");
All devices which support hand tracking will support or emulate all joints, so this method will always return a valid object as long as it is supplied with a valid joint name. If a joint is supported but not currently being tracked, the getter will still produce the XRBodySpace
, but it will return null
when run through getPose
(etc).
Each joint space is an XRSpace
, with its -Y
direction pointing perpendicular to the skin, outwards from the palm, and -Z
direction pointing along their associated bone, away from the wrist. This space will return null poses when the joint loses tracking.
For *-tip
joints where there is no associated bone, the -Z
direction is the same as that for the associated distal
joint, i.e. the direction is along that of the previous bone.