diff --git a/packages/react/xr/src/input.tsx b/packages/react/xr/src/input.tsx index 432ca26..f0add3d 100644 --- a/packages/react/xr/src/input.tsx +++ b/packages/react/xr/src/input.tsx @@ -36,8 +36,13 @@ export function useXRInputSourceStateContext(({ space, children }, ref) => { const internalRef = useRef(null) // eslint-disable-next-line react-hooks/rules-of-hooks - const resolvedSpace = useXRSpace(space as any) + const resolvedSpace = typeof space === 'string' ? useXRSpace(space) : space useImperativeHandle(ref, () => internalRef.current!, []) useApplyXRSpaceMatrix(internalRef, resolvedSpace) const setRef = useCallback((group: Group | null) => { @@ -57,10 +57,12 @@ export type XRHandJointSpaceType = XRHandJoint */ export function useXRSpace(): XRSpace -export function useXRSpace(type: XRInputSourceSpaceType | XRHandJointSpaceType): XRSpace | undefined - export function useXRSpace(type: XRReferenceSpaceType): XRReferenceSpace | undefined +export function useXRSpace( + type: XRInputSourceSpaceType | XRHandJointSpaceType | XRReferenceSpaceType, +): XRSpace | undefined + export function useXRSpace(type?: XRSpaceType): XRSpace | XRReferenceSpace | undefined { switch (type) { case 'grip-space':