如何解决AFrame:使用资产图片时,a图片会引发错误
我正在尝试使用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>
请问我在做什么错?是虫子吗?
解决方法
是的,两天前我发现了类似的问题,实际上a-资产仅在通过服务器运行时才有效。我已经使用django解决了这个问题。
,我的坏。我应该使用img
而不是a-asset-item
标记
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。