Class WebXRBodyTracking
Hierarchy (View Summary)
- WebXRAbstractFeature
- WebXRBodyTracking
Constructors
constructor
-
new WebXRBodyTracking(
_xrSessionManager: WebXRSessionManager,
options?: IWebXRBodyTrackingOptions,
): WebXRBodyTrackingConstruct a new WebXRBodyTracking feature.
Parameters
- _xrSessionManager: WebXRSessionManager
The XR session manager.
- options: IWebXRBodyTrackingOptions = {}
Configuration options.
Returns WebXRBodyTracking
- _xrSessionManager: WebXRSessionManager
Properties
Optionaldepends On
The dependencies of this feature, if any
disable Auto Attach
Should auto-attach be disabled?
is Disposed
Is this feature disposed?
Readonlyon Body Mesh Set Observable
Observable fired when the body mesh has been set via setBodyMesh or during initial configuration.
Readonlyon Body Tracking Ended Observable
Observable fired when body tracking is lost (i.e. XRFrame.body becomes
null or returns no valid poses after previously tracking).
Readonlyon Body Tracking Frame Update Observable
Observable fired every frame that has valid body tracking data. At the point of notification, all joint transforms are up-to-date.
Readonlyon Body Tracking Started Observable
Observable fired when body tracking starts (i.e. the first frame where
XRFrame.body returns valid data).
on Feature Attach Observable
Observers registered here will be executed when the feature is attached
on Feature Detach Observable
Observers registered here will be executed when the feature is detached
Readonlyoptions
Configuration options for the body tracking feature.
Static ReadonlyName
The module's name, used when enabling the feature on the features manager.
Value: "xr-body-tracking".
Static ReadonlyVersion
The (Babylon) version of this module. This is an integer representing the implementation version. This number does not correspond to the WebXR specs version.
Accessors
attached
-
get attached(): boolean
Is this feature attached
Returns boolean
is Tracking
-
get isTracking(): boolean
Returns
truewhile body tracking data is actively being received.Returns boolean
tracked Body
-
Get the currently tracked body, if any.
Returns Nullable<WebXRTrackedBody>
xr Native Feature Name
-
get xrNativeFeatureName(): string
The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
Returns string
-
set xrNativeFeatureName(name: string): void
The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
Parameters
- name: string
Returns void
StaticAll Body Joints
-
Returns the complete ordered list of body joint names tracked by this feature. Useful for iterating over all joints or building UI.
Returns readonly WebXRBodyJoint[]
Methods
attach
-
Attach the feature. Called by the features manager when the XR session initialises.
Body tracking is a draft WebXR spec. Some UAs (e.g. Meta Quest) provide body data on
XRFrame.bodybut do not list"body-tracking"insession.enabledFeatures. To handle this, we temporarily clear xrNativeFeatureName before calling the baseattach()so the enabled-features check is skipped, then restore it afterwards.Returns boolean
trueif attachment succeeded.
detach
-
Detach the feature. Called by the features manager when the XR session ends.
Returns boolean
trueif detachment succeeded.
dispose
-
Dispose this feature and all resources.
Returns void
is Compatible
-
This function will be executed during before enabling the feature and can be used to not-allow enabling it. Note that at this point the session has NOT started, so this is purely checking if the browser supports it
Returns boolean
whether or not the feature is compatible in this environment
set Body Mesh
-
Attach a rigged body mesh (or replace the current one) at any time.
This is a convenience method that forwards to the underlying WebXRTrackedBody.setBodyMesh. The body does not need to be already tracking for this to work — the mesh will be applied once tracking begins.
Parameters
- bodyMesh: AbstractMesh
The rigged mesh to drive.
OptionalrigMapping: XRBodyMeshRigMappingOptional mapping from WebXRBodyJoint names to bone names.
Returns void
- bodyMesh: AbstractMesh
snapshot Frame To Clipboard Async
-
Capture a single-frame snapshot of all 83 joints and copy it to the clipboard. Call this from a playground button or the console while wearing the headset:
bodyTracking.snapshotFrameToClipboard();The JSON can later be loaded offline to replay the bone-local computation without a headset.
Returns Promise<void>
A promise that resolves when the copy completes, or rejects if no body is currently tracked.
WebXR Body Tracking feature.
This feature tracks the user's full-body pose using the WebXR Body Tracking Module, which exposes 83 articulated joints covering the torso, arms, hands, legs and feet.
Quick Start
How It Works
"body-tracking"native WebXR feature at session start.XRFrame.bodyis available, joint poses are filled into a flat Float32Array via the batchfillPoses()API (with a per-joint fallback).Coordinate System
WebXR data arrives in a right-handed coordinate system. Babylon.js defaults to left-handed. The conversion is handled automatically:
scene.useRightHandedSystem = true, no conversion is applied.See
https://immersive-web.github.io/body-tracking/