Preserve Drawing Buffers to save an image from an XR session

Hi everyone,

I’m looking for a little bit of guidance when using preserve drawing buffers within an XR scene, i’ve used something similar before to save an image from a conventional scene but trying the same in an xr scene i get a blank image output and this…
it’s as if the renderer.domElement.toDataURL starts to be written and then turns to a string of AAA.

i’m pretty much using this simple code…

renderer.preserveDrawingBuffer = true;           
imgData = renderer.domElement.toDataURL('image/jpeg', 1.0);

var ab = document.createElement('a');
ab.href = imgData; = "yourCouch.jpg";;

renderer.preserveDrawingBuffer = false;

would anyone happen to know why this wouldn’t be working or if there is a different method or approach to save an image from a webXR session?

many kind thanks in advance!!


Does anyone have any ideas on this subject?

I can’t really help you but have you tried rendering on a different render target, as a workaround ? Maybe spawn a separate renderer without xr.enabled and render the scene again… Not clean, but, if it works… is it for AR or VR ?

@felixmariotto oh I see, that sounds like a way, would this capture the devices camera feed also though? Or just the three scene? It’s AR, I used this example as a reference start point three.js examples

No I don’t think it would…