Skip to main content

@realitycollective/webxr-input

Interfaces

InterfaceDescription
HeadPoseA viewer (head) pose sample - camera on desktop, HMD in XR.
HeadPoseSourceSupplies the viewer pose each frame.
InputCapabilities-
InputHitHintA pre-resolved interaction hint from providers whose engine performs its own targeting (e.g. Meta IWSDK delivers hover/press as ECS tag transitions rather than exposing a raycast query). When a provider supplies hints for a frame, a consumer's binder accepts them IN PLACE of its own hit-testing for the named target - provider power wins when the provider has extended capabilities.
InputProviderThe one interface an engine adapter must implement to feed input into the Reality Collective extension families.
InputProviderContractCaseOne check an InputProvider implementation must pass. run returns silently on success and throws an Error describing the failure otherwise, so any test runner can host it.
InputProviderContractDriverOptional hooks a contract case can drive. An adapter's test harness supplies whatever it can fake; cases that need a missing hook pass without running, so a partial driver is always safe.
InputSourceSnapshotOne live input source, engine-normalised and sampled once per update. Fields the provider cannot supply are simply absent - consumers gate on InputCapabilities, not on per-frame presence checks.
PointerInputSourceDelivers press-move-release for one interaction source.
PointerSampleOne pointer/ray interaction stream, engine-normalised.
PoseTupleA world-space pose.
RayTupleA ray in world space; direction is expected normalised.

Type Aliases

Type AliasDescription
GrabCapabilityHow grabbing is fulfilled: - "none" - no grab input at all. - "poseOnly" - the provider reports grab start/end + poses; the consumer (or the interactions core) moves the object. - "native" - the engine owns carry/throw (e.g. IWSDK grabbables + physics); the provider reports the transitions and observed poses only.
Handedness-
InputCapabilityRequirementThe input requirements a consumer (an interaction behaviour) can declare. Checked against InputCapabilities by capability negotiation.
InputSourceKindWhat kind of physical thing produced this source.
PresenceModalityWhich visuals a provider should present for the user's own body: - "hands" - hand meshes only. - "controllers" - controller models only. - "auto" - let the runtime decide from the live session.
QuatTupleOrientation quaternion as [x, y, z, w].
UnsubscribeReturned by every subscription; call to detach the listener.
Vec3TuplePosition as [x, y, z] in meters, world space unless stated otherwise.

Variables

VariableDescription
INPUT_CAPABILITY_REQUIREMENTSEvery requirement a consumer (an interaction behaviour) can declare, as runtime data so a test can check it against the keys of NO_CAPABILITIES. Every capability appears here, and "grabs" is the one capability with two requirements.
NO_CAPABILITIESA provider with nothing to give - the safe default before a session.
SELECT_PRESS_THRESHOLDSelect threshold used by consumers that need a boolean from select.
SELECT_RELEASE_THRESHOLDRelease threshold (hysteresis below the press threshold).

Functions

FunctionDescription
inputProviderContractCasesThe shared provider conformance suite, runner-free on purpose: every adapter repository has its own runner, so this ships the checks as data and the adapter iterates them. A typical suite is three lines:
satisfiesTrue when capabilities satisfies a single requirement.
unmetRequirementsThe subset of requirements that capabilities does NOT satisfy.
velocityBetweenGrip velocity derived from two consecutive poses - the throw/flick input every physics-flavoured grab needs, for the many providers that report poses but no velocity. Pure and dependency-free: the caller keeps the previous pose, this turns the pair into a velocity.