Trying to create a web-ar experience that allows users to switch between front and back cameras while utilizing SLAM/6dof with the back camera has been a challenging endeavor. While attempting this in PlayCanvas, I faced difficulties getting the front camera to function properly. Similarly, my efforts in A-Frame have resulted in some success, but various issues persist.
The lack of specific PlayCanvas documentation on enabling the front camera led me to experiment with XR.stop() followed by XR.run({canvas: document.getElementById('camerafeed'), cameraConfig: {direction: XR.XrConfig.camera().FRONT}}), unfortunately without any noticeable effect.
Meanwhile, within A-Frame, I managed to activate the front camera, albeit encountering log errors, rendering issues with 3D objects, and complications when attempting to switch cameras multiple times.
In addition, attempts to toggle SLAM/6dof parameters have been met with an error message indicating that disableWorldTracking cannot be altered after XR.run has been executed, even following the use of XR.stop() and stopxr event listening.
Snippet of A-Frame functionality for switching to the front camera:
init: function() {
this.el.sceneEl.addEventListener('stopxr', event => {
console.log("AR has been stopped.");
const videoCanvas = document.querySelector('canvas.a-canvas');
XR.XrController.configure({disableWorldTracking: true});
XR.run({canvas: videoCanvas, cameraConfig: {direction: XR.XrConfig.camera().FRONT}});
});
},
switchToFace: function() {
this.el.sceneEl.emit('stopxr');
//XR.stop();
},
What is the correct procedure for adjusting the disableWorldTracking parameter while the scene is active? And how can the seamless transition between front and back cameras be achieved during runtime?