WebVR with offscreen canvas

I’m trying to use WebVR in offscreen canvas.
This is the normal way of adding the VR button:
document.body.appendChild(VRButton.createButton(renderer));

Since the offscreen canvas does not have document, I’m trying the following:

  1. Importing the VR Button in my main thread and adding this line: document.body.appendChild(VRButton.createButton());. This adds the VR button.

  2. Since the renderer is in my offscreen canvas, I checked the VRButton.js code (https://github.com/mrdoob/three.js/blob/6d94b81ef73ffd555818018eee6ed6842f9383ed/examples/jsm/webxr/VRButton.js) and this is the only line that references the renderer: renderer.xr.setSession(session);. So, I tried passing the session data to the offscreen canvas and setting the renderer there. However, I’m getting an error that the session data cannot be cloned

I tried a couple other methods of sending the session data to offscreen, by assigning it to some global variable or by passing the renderer to the main thread, but nothing works.

There are no examples in three.js on how this can be done. I’ll be grateful for any suggestions on how to proceed.

Thank you.