Skip to content

Commit 4db0372

Browse files
chore: Removed grabbing and handle logic
1 parent cbbf2a5 commit 4db0372

File tree

2 files changed

+2
-40
lines changed

2 files changed

+2
-40
lines changed

‎examples/hit-testing/src/duck.tsx‎

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
*/
99
import { useGLTF } from '@react-three/drei'
1010
import { useFrame } from '@react-three/fiber'
11-
import { Handle, HandleStore } from '@react-three/handle'
12-
import { useXRRequestHitTest } from '@react-three/xr'
13-
import { useRef, useState } from 'react'
1411
import { Group } from 'three'
15-
import { onResults } from './app.js'
16-
import { Reticle } from './reticle.js'
1712

1813
// const MODEL = 'https://vazxmixjsiawhamofees.supabase.co/storage/v1/object/public/models/duck/model.gltf'
1914
const MODEL = 'duck.gltf'
@@ -22,38 +17,9 @@ useGLTF.preload(MODEL)
2217

2318
export const Duck = (props: any) => {
2419
const { nodes, materials } = useGLTF(MODEL) as any
25-
const [isBeingGrabbed, setisBeingGrabbed] = useState(false)
26-
const hitTestRefPoint = useRef<Group>(null)
27-
const duckGroup = useRef<Group>(null)
28-
const hitTestRequest = useXRRequestHitTest()
29-
const handleRef = useRef<HandleStore<unknown>>(null)
30-
31-
useFrame(async (_, __, frame: XRFrame | undefined) => {
32-
if (frame && isBeingGrabbed && hitTestRefPoint.current) {
33-
const requestedHitTest = await hitTestRequest(hitTestRefPoint)
34-
if (requestedHitTest?.results && requestedHitTest.results.length > 0 && requestedHitTest?.getWorldMatrix) {
35-
onResults('duck', requestedHitTest?.results ?? [], requestedHitTest?.getWorldMatrix)
36-
}
37-
}
38-
})
3920

4021
return (
41-
<>
42-
<group ref={duckGroup} {...props} dispose={null}>
43-
<Handle
44-
ref={handleRef}
45-
handleRef={duckGroup}
46-
apply={(state) => {
47-
if (state.last) {
48-
setisBeingGrabbed(false)
49-
} else {
50-
setisBeingGrabbed(true)
51-
}
52-
53-
duckGroup.current?.position.copy(state.current.position)
54-
duckGroup.current?.quaternion.copy(state.current.quaternion)
55-
}}
56-
>
22+
<group {...props} dispose={null}>
5723
<mesh
5824
geometry={nodes.character_duck.geometry}
5925
material={nodes.character_duck.material}
@@ -76,10 +42,6 @@ export const Duck = (props: any) => {
7642
<mesh geometry={nodes.Cube1338_2.geometry} material={materials['Black.027']} />
7743
</group>
7844
</mesh>
79-
<group ref={hitTestRefPoint} />
80-
</Handle>
8145
</group>
82-
{isBeingGrabbed && <Reticle handedness="duck" />}
83-
</>
8446
)
8547
}

‎packages/react/xr/plugins/pretty-md.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export const load = (app) => {
140140

141141
// Update the nav number in the frontmatter
142142
const content = fs.readFileSync(targetFile, 'utf-8')
143-
const updatedContent = content.replace(/nav:\s*\d+/, `nav: ${index + 25}`)
143+
const updatedContent = content.replace(/nav:\s*\d+/, `nav: ${index + 26}`)
144144
fs.writeFileSync(targetFile, updatedContent)
145145
})
146146
}

0 commit comments

Comments
 (0)