1
0
Files
VR-Web-Player/src/vr180player/xr/input-mode.ts
Aiden fbfdc1c575
All checks were successful
Publish Pages / publish (push) Successful in 22s
Test / test (push) Successful in 11s
removed hand specific tracking
2026-06-11 16:51:42 +10:00

40 lines
929 B
TypeScript

export type PointerInputMode = 'controller';
export type PointerInputModeCarrier = {
controller?: {
userData?: any;
};
pointerInputMode?: PointerInputMode;
};
export function rememberPointerInputMode(
inputSource: PointerInputModeCarrier,
event: any,
fallbackMode: PointerInputMode
): void {
const eventInputSource = event?.data?.inputSource || event?.inputSource || event?.data;
const nextMode = getPointerInputMode(eventInputSource) || fallbackMode;
inputSource.pointerInputMode = nextMode;
if (!inputSource.controller) {
return;
}
inputSource.controller.userData = {
...inputSource.controller.userData,
vrwpInputSource: inputSource
};
}
export function getPointerInputMode(eventInputSource: any): PointerInputMode | null {
if (!eventInputSource) {
return null;
}
if (eventInputSource.gamepad || eventInputSource.targetRayMode === 'tracked-pointer') {
return 'controller';
}
return null;
}