I've seen a few examples of using useHitTest
with versions of @react-three/xr lower than v5, but I'm not quite sure how to convert the syntax using the newer versions.. (and using useRef
with Typescript, which might be a separate issue).
Here is an example of the older syntax:
plane detection with react-three/xr
and
https://codesandbox.io/s/react-xr-usehittest-demo-5iff9?file=/src/App.tsx
But I'm not sure (based on this react-three/xr documentation):
a. How to add sessionInit={{ requiredFeatures: ['hit-test'] }}
to Canvas
or XR
tags, post deprecation of ARCanvas
.
b. Whether hit.decompose
is still needed.
c. Whether mesh.applyMatrix4(hitMatrix)
is needed, or whether something like ref={hitPoint}
is still needed
d. If using ref
with Typescript, how to solve the Type 'MutableRefObject<undefined>' is not assignable
error when adding to a mesh. As per this answer, maybe I need to force mount the component or something..
Any help or examples appreciated. Thanks