首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >chrome的<model-viewer>在拒绝承诺时暂停

chrome的<model-viewer>在拒绝承诺时暂停
EN

Stack Overflow用户
提问于 2021-04-28 11:39:13
回答 1查看 72关注 0票数 0

我尝试将画布中的纹理(fabric.js)分配给模型查看器的baseColorTexture。但没那么走运。并且错误在promise rejection时暂停。我需要指导。谢谢

代码语言:javascript
复制
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);
EN

回答 1

Stack Overflow用户

发布于 2021-04-28 12:53:39

我已经找到解决方案了

代码语言:javascript
复制
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'))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67293440

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档