UNPKG

@threlte/xr

Version:

Tools to more easily create VR and AR experiences with Threlte

15 lines (14 loc) 526 B
import { Vector3 } from 'three'; import { useController } from '../../hooks/useController'; const controllers = { left: useController('left'), right: useController('right') }; const forward = new Vector3(); export const defaultComputeFunction = (context, handContext) => { const targetRay = controllers[handContext.hand].current?.targetRay; if (targetRay === undefined) return; forward.set(0, 0, -1).applyQuaternion(targetRay.quaternion); context.raycaster.set(targetRay.position, forward); };