Can I avoid the XRButton ? #220
Unanswered
quertenmont
asked this question in
Q&A
Replies: 1 comment 1 reply
-
WebXR requires interaction to start a session, so you could place a button beforehand (you'll often see immersive sites have a button gate to get the same permission for audio), and eagerly create a session once granted. Maybe react-xr can export a method to do this. This would be the relevant code: function XRSessionInit() {
const set = useXR(state => state.set)
useLayoutEffect(() => {
let session
try {
navigator.xr
.requestSession('immersive-vr', {
optionalFeatures: ['local-floor', 'bounded-floor', 'hand-tracking', 'layers'],
})
.then((session) => {
// Check if unmounted
if (session === null) return
// Otherwise, init react-xr
set(() => ({ session }))
})
} catch(e) {
// Session unsupported
console.error(e)
}
return () => {
session?.end()
session = null
set(() => ({ session }))
}
}, [set])
}
{hasInteraction && (
<Canvas>
<XR>
<XRSessionInit />
</XR>
</Canvas>
)} |
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
-
Hello,
I am looking to develop an XR app for the meta store through a PWA+WEB XR.
But I'd like to skip the step where the user has to push the XR Button to get into the immersive view.
Is this possible or is it a limitation of web xr ?
Thanks for helping,
Loic
Beta Was this translation helpful? Give feedback.
All reactions