Is it possible to draw the render in a canvas element?

Make sure that you’ve rendered the scene before calling toDataURL(). Here is an example I wrote a while ago using toBlob() instead of toDataURL(), but either one should work…

renderer.render( scene, camera );

const imgData = canvas.toBlob( ( blob ) => {

    const imgEl = document.createElement( 'img' );
    imgEl.src = URL.createObjectURL( blob );
    document.body.appendChild( imgEl );

});
1 Like