chrome's <model-viewer> Paused on promise rejection

273 views Asked by At

I'm trying to assign the texture from a canvas(fabric.js) to model-viewer's baseColorTexture. But no luck. And the error is Paused on promise rejection. I need guidance. Thanks

var img = new Image();
img.src = document.getElementById('canvas').toDataURL('image/jpeg', 1.0);
const modelViewerTexture = document.querySelector('model-viewer');
modelViewerTexture.model.materials[0].pbrMetallicRoughness['baseColorTexture'].texture.source.setURI(img);
1

There are 1 answers

0
Alex Yim On

I found the solution already

var can = document.getElementById('canvas').toDataURL('image/jpeg', 1.0)
const modelViewerTexture = document.querySelector('model-viewer')

localStorage.setItem('imgData', can)
modelViewerTexture.model.materials[0].pbrMetallicRoughness['baseColorTexture'].texture.source.setURI(localStorage.getItem('imgData'))