Hi everyone,
I’m trying to convert an uploaded stl file into an image with png extension. I have written a code that only captures the scence, but the image is not showing. I don’t know why the image is not displayed.
Here is a piece of the codes:
var canvas = document.getElementsByTagName('canvas')[0];
var dataURL = canvas.toDataURL('image/png');
var imgSrc = dataURL.replace(/^data:image\/[^;]/, 'data:application/octet-stream');
console.log({dataURL});
var image = imgSrc;
The code above only captures the scene without showing the image.
If I use imgSrc.png, it gives me error.
To remove the background for rendering the image, change the scene.background color to an rgba value 0,0,0,0 before renderer.render(scene camera);
Make sure you set canvas to transparent to start with though: