The project loads on headset – but we don’t like the floating window for the HTML buttons. I.e., the non-XR non-Aframe non-ThreeJS elements on the page.
How can we hide/show nodes based on the client platform, i.e., mobile or headset?
Or are you saying that this is all being handled directly by A-Frame?
I was wondering if you cloned one of our sample projects—I’d like to take a look at the structure and frameworks for reference
Yes, AFrame would handle that. If you haven’t already, I recommend checking out their docs and sample projects—they have examples that run across multiple devices with variations for each one.
I’d do a custom component to manage everything like this.
AFRAME.registerComponent('check-xr-mode', {
init: function () {
const renderer = this.el.sceneEl.renderer;
// Wait for the renderer to be initialized
if (renderer && renderer.xr) {
const session = renderer.xr.getSession();
if (session) {
// Check the mode of the XR session
const mode = session.mode;
if (mode === 'immersive-ar') {
// User is in AR mode
console.log('User is in AR mode');
// Disable xrextras-pinch-scale
this.el.removeAttribute('xrextras-pinch-scale');
} else if (mode === 'immersive-vr') {
// User is in VR mode
console.log('User is in VR mode');
// Enable xrextras-pinch-scale if needed
this.el.setAttribute('xrextras-pinch-scale', '');
} else {
// User is not in an XR session
console.log('User is not in XR mode');
// Adjust behaviors for non-XR mode if necessary
}
} else {
// No XR session is active
console.log('No XR session is active');
}
}
}
});