File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -36,8 +36,13 @@ export function useXRInputSourceStateContext<T extends keyof XRInputSourceStateM
3636 type ?: T ,
3737) : XRInputSourceStateMap [ T ] {
3838 const state = useContext ( xrInputSourceStateContext )
39- if ( state == null || ( type != null && state . type != type ) ) {
40- throw new Error ( `useXRInputSourceStateContext() can only be used inside a the xr store config` )
39+ if ( state == null ) {
40+ throw new Error ( `useXRInputSourceStateContext() can only be used inside the xr store config` )
41+ }
42+ if ( type != null && state . type != type ) {
43+ throw new Error (
44+ `useXRInputSourceStateContext(${ type } ) can not be used inside a component for input type "${ state . type } "` ,
45+ )
4146 }
4247 return state as XRInputSourceStateMap [ T ]
4348}
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ export const XRSpace = forwardRef<
2929> ( ( { space, children } , ref ) => {
3030 const internalRef = useRef < Group | null > ( null )
3131 // eslint-disable-next-line react-hooks/rules-of-hooks
32- const resolvedSpace = useXRSpace ( space as any )
32+ const resolvedSpace = typeof space === 'string' ? useXRSpace ( space ) : space
3333 useImperativeHandle ( ref , ( ) => internalRef . current ! , [ ] )
3434 useApplyXRSpaceMatrix ( internalRef , resolvedSpace )
3535 const setRef = useCallback ( ( group : Group | null ) => {
@@ -57,10 +57,12 @@ export type XRHandJointSpaceType = XRHandJoint
5757 */
5858export function useXRSpace ( ) : XRSpace
5959
60- export function useXRSpace ( type : XRInputSourceSpaceType | XRHandJointSpaceType ) : XRSpace | undefined
61-
6260export function useXRSpace ( type : XRReferenceSpaceType ) : XRReferenceSpace | undefined
6361
62+ export function useXRSpace (
63+ type : XRInputSourceSpaceType | XRHandJointSpaceType | XRReferenceSpaceType ,
64+ ) : XRSpace | undefined
65+
6466export function useXRSpace ( type ?: XRSpaceType ) : XRSpace | XRReferenceSpace | undefined {
6567 switch ( type ) {
6668 case 'grip-space' :
You can’t perform that action at this time.
0 commit comments