Skip to content

Commit

Permalink
refactor(origin): use controller locomotion
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa committed Oct 5, 2024
1 parent 74e0fef commit 001845b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/components/xr/origin.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { TeleportTarget, XROrigin } from '@react-three/xr'
import { useState } from 'react'
import { Vector3 } from 'three'
import type { Group } from 'three'

import { useControllerLocomotion, XROrigin } from '@react-three/xr'
import { useRef } from 'react'

export const Origin = () => {
const [position, setPosition] = useState(new Vector3(0, 0, 2))

/** @see {@link https://pmndrs.github.io/xr/docs/tutorials/teleport} */
return (
<>
<XROrigin position={position} />
<TeleportTarget onTeleport={setPosition} />
</>
)
const ref = useRef<Group>(null)

useControllerLocomotion(ref)

/**
* TODO: rapier physics
* @see {@link https://pmndrs.github.io/xr/docs/getting-started/all-hooks#usecontrollerlocomotion}
*/
return (<XROrigin position={[0, 0, 2]} ref={ref} />)
}

0 comments on commit 001845b

Please sign in to comment.