当图像文件本地存储时,图像加载为黑色矩形

时间:2019-11-29 15:16:32

标签: augmented-reality aframe

我刚接触A型框架,并在Glitch中创建了这个项目。

这是我的代码。

<a-assets>
  <img id="image" src="arrow.png" crossorigin="anonymous">
</a-assets>
<a-image src="#image" width="2" height="0.8"></a-image>

arrow.png的路径没有错误,因为在控制台中没有出现404错误。如果我更改“ arrow.png”中的拼写,则会得到404。

图像显示为黑框。 enter image description here

但是,如果我改用在线资源,它会正确显示。

<a-assets>
  <img id="image" src="https://i.imgur.com/wjobVTN.jpg" crossorigin="anonymous">
</a-assets>

enter image description here

我在快递服务器中创建了一个GET端点来返回图像。

// Return arrow
path = `${__dirname}/views/arrow.png`
app.get('/arrow', (request, response) => {
  response.sendFile(path);
});

当我从浏览器转到端点时,整个屏幕为黑色。

编辑 小故障项目链接 https://glitch.com/~quickest-catshark

1 个答案:

答案 0 :(得分:0)

查看您在Glith上的项目结构,您需要将arrow.png移到公用文件夹中。

混合故障https://glitch.com/~scalloped-lemongrass