XR · function

readControllers

Read every input source a session currently reports.

Explained in XR.

function readControllers(session: XrSession, frame: XrFrame, referenceSpace: unknown, out?: ControllerState[]): ControllerState[]
import { readControllers } from '@driftengine/xr';

Parameters

ParameterTypeDescription
sessionXrSession
frameXrFrame
referenceSpaceunknown
out?ControllerState[]

In depth

out is filled and returned, so a frame loop allocates nothing after the first call. Sources come and go as controllers wake and sleep, which is why the list is read from the session every frame rather than cached at inputsourceschange: the event exists for a consumer that wants to react, and this is the polling half.