Talos docs

XrHand

Since next

One hand this tick: its controller and, where the headset tracks hands, its joints.

Plain text

Plain data.

Signature

export interface XrHand {
  /** A controller is bound to this hand and tracked. */
  readonly active: boolean
  /** The controller's OpenXR interaction profile, or null. */
  readonly profile: string | null
  /** Where the hand holds the controller, in the world; null while untracked. */
  readonly grip: XrPose | null
  /** The controller's pointing ray, in the world. */
  readonly aim: XrPose | null
  /** `grip` in the XR origin's frame: what a cockpit aligns against. */
  readonly gripLocal: XrPose | null
  /** `aim` in the XR origin's frame. */
  readonly aimLocal: XrPose | null
  /** The trigger, 0 to 1. */
  readonly trigger: number
  /** 0 to 1 (a click grip is 0 or 1). */
  readonly squeeze: number
  /** -1 to 1 each. */
  readonly thumbstick: [number, number]
  /** Held this tick (the analog ones from 0.6 until below 0.4). */
  readonly buttons: Record<XrButton, boolean>
  /** Pressed this tick. */
  readonly pressed: Record<XrButton, boolean>
  /** Released this tick. */
  readonly released: Record<XrButton, boolean>
  /** The hand itself is tracked (hand tracking): `joints` and `palm` are set. */
  readonly tracked: boolean
  /** The palm of a tracked hand, in the world; null unless `tracked`. */
  readonly palm: XrPose | null
  /** The palm in the XR origin's frame. */
  readonly palmLocal: XrPose | null
  /** The 26 joints of OpenXR hand tracking (wrist, palm, then thumb to little finger), or null. */
  readonly joints: XrJoint[] | null
}

Import: import type { XrHand } from "@argus/api"

Members

MemberSignatureDescription
activereadonly active: booleanA controller is bound to this hand and tracked.
profilereadonly profile: string | nullThe controller's OpenXR interaction profile, or null.
gripreadonly grip: XrPose | nullWhere the hand holds the controller, in the world; null while untracked.
aimreadonly aim: XrPose | nullThe controller's pointing ray, in the world.
gripLocalreadonly gripLocal: XrPose | nullgrip in the XR origin's frame: what a cockpit aligns against.
aimLocalreadonly aimLocal: XrPose | nullaim in the XR origin's frame.
triggerreadonly trigger: numberThe trigger, 0 to 1.
squeezereadonly squeeze: number0 to 1 (a click grip is 0 or 1).
thumbstickreadonly thumbstick: [number, number]-1 to 1 each.
buttonsreadonly buttons: Record<XrButton, boolean>Held this tick (the analog ones from 0.6 until below 0.4).
pressedreadonly pressed: Record<XrButton, boolean>Pressed this tick.
releasedreadonly released: Record<XrButton, boolean>Released this tick.
trackedreadonly tracked: booleanThe hand itself is tracked (hand tracking): joints and palm are set.
palmreadonly palm: XrPose | nullThe palm of a tracked hand, in the world; null unless tracked.
palmLocalreadonly palmLocal: XrPose | nullThe palm in the XR origin's frame.
jointsreadonly joints: XrJoint[] | nullThe 26 joints of OpenXR hand tracking (wrist, palm, then thumb to little finger), or null.

Example

The tested fixture fixtures/recipes/jump-pad-and-elevator/scenes/behaviors/camera-zone.ts.

import type { Behavior } from "@argus/api"

/**
 * A trigger volume that retunes the camera while the player is inside it.
 *
 * The engine has no camera-zone concept and needs none: a volume, a `trigger` component and this.
 * Here the player's behaviour owns the camera (it re-sends its params when the view is turned), so
 * the zone tells it what to change rather than calling `ctx.camera.set` itself. In a scene where
 * nothing else writes the camera, the zone can call `ctx.camera.set(kind, params)` directly.
 */
interface Props {
  /** `ctx.camera.set` params to merge in on the way in, and on the way out. */
  inside?: Record<string, unknown>
  outside?: Record<string, unknown>
}

export default {
  onTrigger(ctx, trigger) {
    const params = trigger.entering ? ctx.props.inside : ctx.props.outside
    if (params) ctx.events.emit("camera-zone", { target: trigger.other.id, params })
  },
} satisfies Behavior<Record<string, never>, Props>