I am trying to develop a web-ar experience that allows the user to switch between front and back cameras throughout the experience, while utilizing SLAM/6dof while using the back camera. Ideally I'd like to use PlayCanvas, but was unable to get the front camera to work. I have had some mild success implementing this in a-frame, but many things are breaking.
I couldn't find any PlayCanvas specific documentation on enabling the front camera, and using XR.stop(), followed by XR.run({canvas: document.getElementById('camerafeed'), cameraConfig: {direction: XR.XrConfig.camera().FRONT}}) didn't have any effect.
Within a-frame I am doing a similar sequence of events, but I am seeing some results. The front camera gets activated, but there are errors in the log, 3D objects don't render(they render when we start in front camera mode), and trying to switch cameras again displays the "Oops, something went wrong!" screen.
As for toggling the SLAM/6dof I keep getting an error that I can not change disableWorldTracking after XR.run has been executed. Even if I have run the XR.stop function and listened for the stopxr event.
A-frame functionality that is supposed to switch to the front camera(just the important bits):
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 proper way to change the disableWorldTracking parameter while the scene is running? What is the proper way to alternate between front and back camera while the scene is running?