I'm trying to take a screenshot of a .glb file displayed by model-viewer. But I can't arrive to a solution. I've read somewhere that the key is to convert the modelviewer to a blob object and then download an image.
<div class="button">
<a id="download" href="#">Download button</a>
</div>
<script>
function download() {
const modelViewer = document.querySelector("#modelviewertest");
const screenshot = URL.createObjectURL(
modelViewer.toBlob("image/jpeg")
);
const donwloadLink = document.querySelector("#download");
donwloadLink.download = screenshot;
donwloadLink.href = data;
}
I have tried to take a screenshot with html2canvas but not working. I would like to save into my server a screenshot of the glb model loaded on model-viewer.