Skip to content

@relu-interactives/spatial-ecs


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

Class: XRInteractionSystem ​

Defined in: systems/XRInteractionSystem.ts:104

Implements ​

Constructors ​

Constructor ​

ts
new XRInteractionSystem(inputSystem): XRInteractionSystem;

Defined in: systems/XRInteractionSystem.ts:120

Parameters ​

ParameterType
inputSystemXRInputSystem

Returns ​

XRInteractionSystem

Methods ​

update() ​

ts
update(world, deltaTime): void;

Defined in: systems/XRInteractionSystem.ts:124

Parameters ​

ParameterType
worldWorld
deltaTimenumber

Returns ​

void

Implementation of ​

EcsSystem.update


getHoveredEntityId() ​

ts
getHoveredEntityId(): number | null;

Defined in: systems/XRInteractionSystem.ts:950

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:960

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:970

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

Returns ​

Set<number>


getHeldEntityIds() ​

ts
getHeldEntityIds(): Set<number>;

Defined in: systems/XRInteractionSystem.ts:977

Entities currently held, so hover feedback can skip them.

Returns ​

Set<number>


isGrabbing() ​

ts
isGrabbing(): boolean;

Defined in: systems/XRInteractionSystem.ts:984

True when any source is holding something.

Returns ​

boolean


isSourceBusy() ​

ts
isSourceBusy(world, input): boolean;

Defined in: systems/XRInteractionSystem.ts:1002

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:1033

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:1041

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:1048

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:1063

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:1064
primaryHandednessXrHandedness | null-systems/XRInteractionSystem.ts:1065
secondaryHandednessXrHandedness | null-systems/XRInteractionSystem.ts:1066
handSeparationnumber | nullMetres between the hands, or null unless two hands are on it.systems/XRInteractionSystem.ts:1068
attachPointIds(string | null)[]The attach point ids in use, in holder order.systems/XRInteractionSystem.ts:1070

null