【问题标题】:AFrame: a-image throws error when using image from assetsAFrame:使用资产中的图像时,a-image 会引发错误
【发布时间】:2020-10-12 13:52:29
【问题描述】:

我正在尝试将图像添加到我的场景中,其中 src 指向资产标签内的项目之一:

<a-assets>
    <a-asset-item id="shoot" src="/assets/icons/shoot.png"></a-asset-item>
</a-assets>

...
<a-image src="#shoot" 
    position="0 0 -0.2" 
    scale="0.05 0.05 0.05" 
    material="alphaTest: 0.5"></a-image>
...

我在控制台中收到以下错误:

THREE.WebGLState: TypeError: Failed to execute 'texImage2D' on 'WebGLRenderingContext': Overload resolution failed.
    at Object.texImage2D (aframe-master.js:27470)
    at uploadTexture (aframe-master.js:28387)
    at setTexture2D (aframe-master.js:27939)
    at WebGLTextures.safeSetTexture2D (aframe-master.js:28819)
    at SingleUniform.setValueT1 [as setValue] (aframe-master.js:23479)
    at Function.WebGLUniforms.upload (aframe-master.js:23938)
    at setProgram (aframe-master.js:32143)
    at WebGLRenderer.renderBufferDirect (aframe-master.js:30878)
    at renderObject (aframe-master.js:31625)
    at renderObjects (aframe-master.js:31595)
    at WebGLRenderer.render (aframe-master.js:31376)
    at HTMLElement.render (aframe-master.js:79612)
    at bound (aframe-master.js:83391)
    at onAnimationFrame (aframe-master.js:31231)
    at onAnimationFrame (aframe-master.js:21566)

我也尝试过以这种方式加载它,但它不起作用:

<a-assets>
    <a-asset-item id="shoot" src="/assets/icons/shoot.png"></a-asset-item>
</a-assets>
<a-image src="/assets/icons/shoot.png" 
    position="0 0 -0.2" 
    scale="0.05 0.05 0.05" 
    material="alphaTest: 0.5"></a-image>

但如果我删除一个资产项,它会起作用:

<a-image src="/assets/icons/shoot.png" 
    position="0 0 -0.2" 
    scale="0.05 0.05 0.05" 
    material="alphaTest: 0.5"></a-image>

你能告诉我我做错了什么吗?是bug吗?

【问题讨论】:

  • 没有运行和调试的代码将很难提供帮助。与glitch.com/~aframe分享简单的可运行代码,帮助人们帮助你

标签: aframe


【解决方案1】:

是的,我两天前发现了类似的问题,实际上 a-assets 仅在您通过服务器运行时才有效。我已经通过使用 django 解决了这个问题。

【讨论】:

  • 其实我用的是服务器
【解决方案2】:

我的错。我应该使用img 而不是a-asset-item 标签

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多