Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebXRManager: Fix caching of baseReferenceFrame and teleport example. #24058

Merged
merged 1 commit into from
May 20, 2022

Conversation

richardanaya
Copy link
Contributor

@richardanaya richardanaya commented May 14, 2022

Fixed #24033

Description

The teleporter example was broken in a few ways.

  • the example wasn't creating a transform from the original baseReferenceFrame acquired from the WebXR manager, leading to really strange offsets after the initial teleport. The first teleport would look correct, but then you'd be modifying a modified space.
  • the baseReferenceFrame wasn't nulled out on sub-sequent entering of vr sessions, only allowing you to enter into the example with VR once
  • the example needs to watch for changes in the session to re-grab baseReferenceFrame again

Video of it working:

a93b746eb1f14bf512196d6628573812.mp4

@richardanaya richardanaya changed the title fixes for WebXRManagers caching of baseReferenceFrame and teleport ex… fixes for WebXRManagers caching of baseReferenceFrame and teleport example May 14, 2022
@richardanaya richardanaya changed the title fixes for WebXRManagers caching of baseReferenceFrame and teleport example Fix for WebXRManagers caching of baseReferenceFrame and teleport example May 14, 2022
@richardanaya richardanaya force-pushed the dev branch 2 times, most recently from 53d1ec2 to 1880b9e Compare May 14, 2022 06:19
@richardanaya richardanaya force-pushed the dev branch 2 times, most recently from 94600fe to acb81b7 Compare May 15, 2022 20:19
@richardanaya
Copy link
Contributor Author

@arodic thanks for the review :) made that change on removing event handlers as you suggested, I left a comment on why I need to cache the session.

@arodic
Copy link
Contributor

arodic commented May 16, 2022

Excellent! I can confirm that this fix works as intended (tested in Oculus Quest 2). I can also confirm that without this fix, the example is broken if multiple sessions are attempted.

@LeviPesin
Copy link
Contributor

@richardanaya Can you please update the PR with a sessionstart listener instead of that check?

@mrdoob mrdoob added this to the r141 milestone May 17, 2022
@mrdoob
Copy link
Owner

mrdoob commented May 17, 2022

@LeviPesin Where would that listener go?

@LeviPesin
Copy link
Contributor

LeviPesin commented May 17, 2022

I think https://github.com/mrdoob/three.js/pull/24058/files#diff-28e2f2792c9f311cb52ce985452165df772dcfde81e80f00cd699426ede935c6R107-R116 should be reverted and to the init() function line renderer.xr.addEventListener( 'sessionstart', () => { baseReferenceSpace = renderer.xr.getReferenceSpace(); } ) should be added.

@richardanaya
Copy link
Contributor Author

richardanaya commented May 18, 2022

@LeviPesin fixed and re-tested according to your suggestion, it's much cleaner :) thank you

@mrdoob mrdoob merged commit dc839ff into mrdoob:dev May 20, 2022
@mrdoob
Copy link
Owner

mrdoob commented May 20, 2022

Thanks!

@Mugen87 Mugen87 changed the title Fix for WebXRManagers caching of baseReferenceFrame and teleport example WebXRManager: Fix caching of baseReferenceFrame and teleport example. May 20, 2022
abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Teleport example is broken on Meta Quest 2
4 participants