Replies: 1 comment 5 replies
-
import * as React from 'react'
import * as THREE from 'three'
import { Canvas } from '@react-three/fiber'
import { useHitTest, ARButton, XR } from '@react-three/xr'
function HitTest() {
const mesh = React.useRef()
useHitTest((hitMatrix: THREE.Matrix4, hit: XRHitTestResult) => {
hitMatrix.decompose(mesh.current.position, mesh.current.quaternion, mesh.current.scale)
})
return (
<mesh ref={mesh}>
<boxGeometry />
<meshBasicMaterial color="blue" />
</mesh>
)
}
function App() {
return (
<>
<ARButton />
<Canvas>
<XR>
<HitTest />
</XR>
</Canvas>
</>
)
} |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The older version of the library seems to use this syntax:
Along with
useHitTest
as exampled here: https://stackoverflow.com/questions/70496077/plane-detection-with-react-three-xrI'm really struggling to figure out what the new syntax is with the
XR
component, I've tried:But
useHitTest
doesn't seem to be firing at all..Any suggestions would be really appreciated here.
Beta Was this translation helpful? Give feedback.
All reactions