Skip to content

Commit 8f49bc6

Browse files
committed
examples: fix hit test anchor example reading points out of the list
1 parent 51d88ab commit 8f49bc6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

examples/hit-test-anchor/app.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
useXRRequestHitTest,
1212
useXRAnchor,
1313
useXRInputSourceStateContext,
14-
useXRInputSourceState,
1514
} from '@react-three/xr'
1615
import { useEffect, useRef } from 'react'
1716
import { Matrix4, Mesh, Vector3 } from 'three'
@@ -127,6 +126,9 @@ function Point({ index, left }: { left?: boolean; index: number }) {
127126
useEffect(
128127
() =>
129128
(left ? useLeftPoints : useRightPoints).subscribe((state) => {
129+
if (index >= state.length) {
130+
return
131+
}
130132
ref.current!.position.copy(state[index])
131133
}),
132134
[index, left],

0 commit comments

Comments
 (0)