Canvas.toDataUrl() does not work and only shows the background that was loaded at the start. When i trigger the download the content drawn on the canvas element were not saved somehow. How can i fix it?
https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL did not work.
Code:
`
const canvas = document.querySelector(“#item > div > canvas”);
const gl = canvas.getContext(‘webgl’, { preserveDrawingBuffer: true });
const dataURL = canvas.toDataURL('image/png');
const a = document.createElement('a');
a.href = dataURL;
a.download = 'canvas-image.png';
a.click();
`