Skip to content

Commit 5ae8be8

Browse files
committed
deprecate useControllerLocomotion in favor of useXRControllerLocomotion
1 parent 8fed149 commit 5ae8be8

File tree

6 files changed

+27
-27
lines changed

6 files changed

+27
-27
lines changed

docs/getting-started/all-hooks.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Hook for getting the geometry from the detected plane.
141141

142142
Hook for getting all detected planes with the provided semantic label.
143143

144-
### `useControllerLocomotion`
144+
### `useXRControllerLocomotion`
145145

146146
Hook for abstracting boilerplate needed to use controller based locomotion in XR.
147147

@@ -159,7 +159,7 @@ Hook for abstracting boilerplate needed to use controller based locomotion in XR
159159
// Example showing basic usage
160160
export const userMovement = () => {
161161
const originRef = useRef<THREE.Group>(null);
162-
useControllerLocomotion(originRef);
162+
useXRControllerLocomotion(originRef);
163163
return <XROrigin ref={originRef} />
164164
}
165165

@@ -176,7 +176,7 @@ export const userMovementWithPhysics = () => {
176176
}
177177
}
178178

179-
useControllerLocomotion(userMove)
179+
useXRControllerLocomotion(userMove)
180180

181181
return <>
182182
<RigidBody

examples/minecraft/src/VRPlayerControl.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useFrame } from '@react-three/fiber'
22
import { Vector3Object } from '@react-three/rapier'
3-
import { useControllerLocomotion, useXRInputSourceState, XROrigin } from '@react-three/xr'
3+
import { useXRControllerLocomotion, useXRInputSourceState, XROrigin } from '@react-three/xr'
44
import * as THREE from 'three'
55

66
export function VRPlayerControl({
@@ -32,7 +32,7 @@ export function VRPlayerControl({
3232
})
3333
}
3434

35-
useControllerLocomotion(physicsMove, { speed: 5 })
35+
useXRControllerLocomotion(physicsMove, { speed: 5 })
3636

3737
useFrame(() => {
3838
if (controllerRight?.gamepad?.['a-button']?.state === 'pressed') {

examples/rag-doll/src/App.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Physics, usePlane } from '@react-three/cannon'
44
import { Cursor } from './helpers/Drag.js'
55
import { Guy } from './components/Guy.jsx'
66
import { Mug, Chair, Table, Lamp } from './components/Furniture.jsx'
7-
import { createXRStore, noEvents, useControllerLocomotion, XR, XROrigin, PointerEvents } from '@react-three/xr'
7+
import { createXRStore, noEvents, useXRControllerLocomotion, XR, XROrigin, PointerEvents } from '@react-three/xr'
88
import { useRef, Suspense } from 'react'
99

1010
const store = createXRStore({
@@ -72,7 +72,7 @@ export function App() {
7272

7373
function ControlledXROrigin() {
7474
const ref = useRef(null)
75-
useControllerLocomotion(ref, { speed: 10 })
75+
useXRControllerLocomotion(ref, { speed: 10 })
7676
return <XROrigin ref={ref} scale={10} />
7777
}
7878

packages/react/xr/src/controller-locomotion.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { RootState, useFrame } from '@react-three/fiber'
22
import { RefObject, useMemo } from 'react'
33
import { Vector3, Object3D } from 'three'
44
import {
5-
type ControllerLocomotionRotationOptions,
6-
type ControllerLocomotionTranslationOptions,
7-
createControllerLocomotionUpdate,
5+
type XRControllerLocomotionRotationOptions,
6+
type XRControllerLocomotionTranslationOptions,
7+
createXRControllerLocomotionUpdate,
88
} from '@pmndrs/xr/internals'
99
import { useXRStore } from './xr.js'
1010

@@ -20,16 +20,16 @@ import { useXRStore } from './xr.js'
2020
* @param rotationOptions.speed If `type` is 'smooth', this specifies the speed at which the user's view rotates.
2121
* @param translationControllerHand Specifies which hand will control the movement. Can be either 'left' or 'right'.
2222
*/
23-
export function useControllerLocomotion(
23+
export function useXRControllerLocomotion(
2424
target:
2525
| RefObject<Object3D>
2626
| ((velocity: Vector3, rotationVelocityY: number, deltaTime: number, state: RootState, frame?: XRFrame) => void),
27-
translationOptions: ControllerLocomotionTranslationOptions = {},
28-
rotationOptions: ControllerLocomotionRotationOptions = {},
27+
translationOptions: XRControllerLocomotionTranslationOptions = {},
28+
rotationOptions: XRControllerLocomotionRotationOptions = {},
2929
translationControllerHand: Exclude<XRHandedness, 'none'> = 'left',
3030
) {
3131
const store = useXRStore()
32-
const update = useMemo(() => createControllerLocomotionUpdate(), [])
32+
const update = useMemo(() => createXRControllerLocomotionUpdate(), [])
3333
useFrame((state, delta, frame: XRFrame | undefined) =>
3434
update(
3535
typeof target === 'function' ? target : target.current,

packages/xr/src/controller-locomotion.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { Vector3, Quaternion, Euler, MathUtils, Object3D, Camera } from 'three'
22
import { XRControllerState, XRInputSourceState, XRStore } from './internals.js'
33

4-
export type ControllerLocomotionTranslationOptions =
4+
export type XRControllerLocomotionTranslationOptions =
55
| {
66
speed?: number
77
}
88
| boolean
9-
export type ControllerLocomotionRotationOptions =
9+
export type XRControllerLocomotionRotationOptions =
1010
| ({
1111
deadZone?: number
1212
} & ({ type?: 'snap'; degrees?: number } | { type: 'smooth'; speed?: number }))
1313
| boolean
1414

15-
// useControllerLocomotion defaults and constants
15+
// useXRControllerLocomotion defaults and constants
1616
const defaultSpeed = 2
1717
const defaultSmoothTurningSpeed = 2
1818
const defaultSnapDegrees = 45
@@ -37,15 +37,15 @@ const scaleHelper = new Vector3()
3737
* @param rotationOptions.speed If `type` is 'smooth', this specifies the speed at which the user's view rotates.
3838
* @param translationControllerHand Specifies which hand will control the translation. Can be either 'left' or 'right'.
3939
*/
40-
export function createControllerLocomotionUpdate() {
40+
export function createXRControllerLocomotionUpdate() {
4141
let canRotate = true
4242
return <T extends Array<any>>(
4343
target: Object3D | undefined | null | ((velocity: Vector3, rotationVelocityY: number, ...params: T) => void),
4444
store: XRStore<any>,
4545
camera: Camera,
4646
delta: number,
47-
translationOptions: ControllerLocomotionTranslationOptions = {},
48-
rotationOptions: ControllerLocomotionRotationOptions = {},
47+
translationOptions: XRControllerLocomotionTranslationOptions = {},
48+
rotationOptions: XRControllerLocomotionRotationOptions = {},
4949
translationControllerHand: Exclude<XRHandedness, 'none'> = 'left',
5050
...params: T
5151
) => {

pnpm-lock.yaml

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)