Add ability to auto-start VR - #840
Merged
Merged
Conversation
Contributor
|
To increment version on merge, please add one of |
Requests a VR session on the prop's rising edge, so a consuming app can drive entry from its own control instead of the VR button SplatControls draws in the canvas. Edge-triggered rather than enforced, so ending a session doesn't pull the user back into one. Browsers only grant an immersive session inside a user gesture, which the viewer cannot manufacture, so the AutoStartVr story raises the request from a button of its own rather than setting the prop on mount. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
useXr seeded its availability state to false and only filled it in from the XR manager inside an effect. A state update made in one effect can't reach the closure of another effect already scheduled in the same commit, so a caller acting on mount was always told VR was unsupported, whatever the headset reported. That left autoStartVr unable to start a session on mount, which is the one moment it exists to cover. Also adds an onXrError prop, since the console isn't reachable from inside a headset, which is where these failures happen. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The auto-start story exists to exercise entering VR on mount, so returning from a session to a viewer running on the desktop left it in a state it never set out to show. It now returns to the button that starts one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The story detected this for itself with a component mounted alongside the viewer, since the XR manager is only reachable from inside the PlayCanvas application. Reporting it from the viewer drops that component, and gives a consuming app the counterpart to autoStartVr: something has to tell a caller that drives entry when the user left, and useXr isn't publicly exported. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Storybook generates an action spy for every on[A-Z] prop and passes it in through args, which the story spread over its own props, so the callback it passed was replaced by one that logs to the Actions panel. Spreading args first leaves the story's own wiring intact. Folds onXrError into onXrExit, which now carries an optional error. A caller's answer to a session ending and to one failing to start is usually the same, and telling the story about a failure the same way it hears about an exit means a failed start no longer strands a mounted viewer outside XR. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 43df69f11c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
joshbuchea
approved these changes
Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some use cases might make more sense to have an app auto transition from whatever the app is doing into an immersive VR session, rather than having the user click the VR button once the model is visible.
Add this as a prop that can be modified by the parent to turn VR on/off, or set to true by the parent to mount it in VR already.
Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
Stack created with GitHub Stacks CLI • Give Feedback 💬