Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / index / XrInputState

Type Alias: XrInputState ​

ts
type XrInputState = {
  handedness: XrHandedness;
  kind: XrInputKind;
  connected: boolean;
  rayOrigin: THREE.Vector3;
  rayDirection: THREE.Vector3;
  gripPosition: THREE.Vector3 | null;
  gripQuaternion: THREE.Quaternion | null;
  select: boolean;
  selectStart: boolean;
  selectEnd: boolean;
  squeeze: boolean;
  squeezeStart: boolean;
  squeezeEnd: boolean;
  axes: number[];
  hasAxes: boolean;
  buttons: boolean[];
  joints: XrHandJoints | null;
};

Defined in: xr/types.ts:44

One frame of normalized input for a single source.

Boolean actions follow the same pending→latched contract as the desktop InputSystem: select is the held state, while selectStart / selectEnd are true for exactly one frame. This lets Behaviours poll (if (select)) or edge-detect (if (selectStart)) without subscribing to events.

Properties ​

PropertyTypeDescriptionDefined in
handednessXrHandedness-xr/types.ts:45
kindXrInputKind-xr/types.ts:46
connectedbooleanFalse once the source disconnects (a released pinch on Vision Pro).xr/types.ts:48
rayOriginTHREE.Vector3Pointing ray in WORLD space, from the source's targetRaySpace.xr/types.ts:50
rayDirectionTHREE.Vector3-xr/types.ts:51
gripPositionTHREE.Vector3 | nullPhysical grip pose. Null for gaze and transient-pointer, which have no grip.xr/types.ts:53
gripQuaternionTHREE.Quaternion | null-xr/types.ts:54
selectbooleanPrimary action: controller trigger, hand pinch, or Vision Pro gaze-pinch.xr/types.ts:56
selectStartboolean-xr/types.ts:57
selectEndboolean-xr/types.ts:58
squeezebooleanSecondary action: controller grip squeeze. Never fires for hands/gaze.xr/types.ts:60
squeezeStartboolean-xr/types.ts:61
squeezeEndboolean-xr/types.ts:62
axesnumber[]Thumbstick / trackpad axes in [-1, 1]. Empty when hasAxes is false.xr/types.ts:64
hasAxesbooleanTrue only for sources with a physical stick — gates stick-driven locomotion.xr/types.ts:66
buttonsboolean[]Raw gamepad button pressed-states, when the source exposes a gamepad.xr/types.ts:68
jointsXrHandJoints | nullTracked hand joint positions, world space, or null for controllers. Positions only — pose matching is position-based so it works identically against WebXR, a simulator, or a recorded hand.xr/types.ts:76