Skip to content

@relu-interactives/spatial-ecs


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

Class: XRInteractionSystem ​

Defined in: systems/XRInteractionSystem.ts:107

Implements ​

Constructors ​

Constructor ​

ts
new XRInteractionSystem(inputSystem): XRInteractionSystem;

Defined in: systems/XRInteractionSystem.ts:125

Parameters ​

ParameterType
inputSystemXRInputSystem

Returns ​

XRInteractionSystem

Properties ​

PropertyModifierTypeDefault valueDescriptionDefined in
runsWhilePausedreadonlytruetrueHover only while paused: see updatePaused.systems/XRInteractionSystem.ts:109

Methods ​

update() ​

ts
update(world, deltaTime): void;

Defined in: systems/XRInteractionSystem.ts:129

Parameters ​

ParameterType
worldWorld
deltaTimenumber

Returns ​

void

Implementation of ​

EcsSystem.update


releaseEntity() ​

ts
releaseEntity(world, entityId): void;

Defined in: systems/XRInteractionSystem.ts:898

Let go of an entity in every hand, without a throw: for when the hand can't keep it, such as another player already holding it.

Parameters ​

ParameterType
worldWorld
entityIdnumber

Returns ​

void


getHoveredEntityId() ​

ts
getHoveredEntityId(): number | null;

Defined in: systems/XRInteractionSystem.ts:1031

Entity currently under a pointer this frame, or null.

Returns ​

number | null


getHoverFor() ​

ts
getHoverFor(handedness): 
  | {
  entityId: number;
  distance: number;
}
  | null;

Defined in: systems/XRInteractionSystem.ts:1041

What this hand is pointing at, with the distance to it.

The distance is what lets the pointer ray stop at the surface instead of passing through the object.

Parameters ​

ParameterType
handednessXrHandedness

Returns ​

| { entityId: number; distance: number; } | null


getHoveredEntityIds() ​

ts
getHoveredEntityIds(): Set<number>;

Defined in: systems/XRInteractionSystem.ts:1051

Every entity under a pointer this frame — drives hover feedback.

Returns ​

Set<number>


getHeldEntityIds() ​

ts
getHeldEntityIds(): Set<number>;

Defined in: systems/XRInteractionSystem.ts:1058

Entities currently held, so hover feedback can skip them.

Returns ​

Set<number>


isGrabbing() ​

ts
isGrabbing(): boolean;

Defined in: systems/XRInteractionSystem.ts:1065

True when any source is holding something.

Returns ​

boolean


isSourceBusy() ​

ts
isSourceBusy(world, input): boolean;

Defined in: systems/XRInteractionSystem.ts:1083

Whether this input's primary action is committed to interaction.

True while the source holds something, and also while it merely HOVERS a grabbable — because the pinch that is about to grab must not be read as a teleport by the locomotion system. Without the hover half, the first pinch of a grab teleports the player, and so does the pinch that takes an object from the other hand.

Keyed on the INPUT SOURCE rather than handedness. Vision Pro reports handedness: "none" for every gaze-pinch (it is hard-coded in WebKit), so a handedness-keyed check silently never matched there and each pinch both grabbed and teleported.

Parameters ​

ParameterType
worldWorld
inputXrInputState

Returns ​

boolean


registerBusyContributor() ​

ts
registerBusyContributor(contributor): void;

Defined in: systems/XRInteractionSystem.ts:1114

OR-ed into isSourceBusy; see the comment there.

Parameters ​

ParameterType
contributor(world, input) => boolean

Returns ​

void


getHoverForInput() ​

ts
getHoverForInput(input): 
  | {
  entityId: number;
  distance: number;
}
  | null;

Defined in: systems/XRInteractionSystem.ts:1122

Hover for a specific input source (handedness-free — Vision Pro's transient pointers all report handedness "none").

Parameters ​

ParameterType
inputXrInputState

Returns ​

| { entityId: number; distance: number; } | null


isGrabbingWith() ​

ts
isGrabbingWith(handedness): boolean;

Defined in: systems/XRInteractionSystem.ts:1129

True when THIS hand is holding something.

Parameters ​

ParameterType
handednessXrHandedness

Returns ​

boolean


getGrabInfo() ​

ts
getGrabInfo(entityId): 
  | {
  hands: number;
  primaryHandedness: XrHandedness | null;
  secondaryHandedness: XrHandedness | null;
  handSeparation: number | null;
  attachPointIds: (string | null)[];
}
  | null;

Defined in: systems/XRInteractionSystem.ts:1144

How an entity is currently held.

Exposed for scripts: a Behaviour can poll this in onUpdate to drive two-hand-specific behaviour — showing a bipod when both hands are on a weapon, reading the live hand separation to gate a gesture, or reacting to the scale a pull-apart produced. Returns null when nothing holds it.

Parameters ​

ParameterType
entityIdnumber

Returns ​

Type Literal ​
ts
{
  hands: number;
  primaryHandedness: XrHandedness | null;
  secondaryHandedness: XrHandedness | null;
  handSeparation: number | null;
  attachPointIds: (string | null)[];
}
NameTypeDescriptionDefined in
handsnumber-systems/XRInteractionSystem.ts:1145
primaryHandednessXrHandedness | null-systems/XRInteractionSystem.ts:1146
secondaryHandednessXrHandedness | null-systems/XRInteractionSystem.ts:1147
handSeparationnumber | nullMetres between the hands, or null unless two hands are on it.systems/XRInteractionSystem.ts:1149
attachPointIds(string | null)[]The attach point ids in use, in holder order.systems/XRInteractionSystem.ts:1151

null