Camera stuck
#1014
Replies: 1 comment 1 reply
-
It doesn't seem you are moving the camera while inside of an XR session on line 35 in your player component. To access the camera during an XR session, you can use const { gl, camera } = useThree();
const xrCamera = gl.xr.getCamera(camera); You can toggle between cameras in and out of sessions by checking the const { gl, camera } = useThree();
useFrame(() => {
const session = gl.xr.isPresenting;
const xrCamera = gl.xr.getCamera(camera);
(session ? xrCamera : camera).position.copy(ref.current.position);
}); As moderate changes in position can translate to huge jumps in physical space, I would highly advise smoothly lerping between the camera position and the parent object's. const { gl, camera } = useThree();
useFrame((, delta) => {
const session = gl.xr.isPresenting;
const xrCamera = gl.xr.getCamera(camera);
(session ? xrCamera : camera).position.lerp(ref.current.position, delta * speed);
}); |
Beta Was this translation helpful? Give feedback.
1 reply
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions