Nikita Fedorov
Nikita Fedorov

Reputation: 870

AFrame: a-image throws error when using image from assets

I'm trying to add an image to my scene with src pointing to one of the items inside assets tag:

<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>
...

And I'm getting the following error in console:

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)

I've tried to load it this way also, but it didn't work:

<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>

But if I remove a-asset-item, it works:

<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>

Could you please advice what I'm doing wrong? Is it a bug?

Upvotes: 0

Views: 602

Answers (2)

Nikita Fedorov
Nikita Fedorov

Reputation: 870

My bad. I should have used img instead of a-asset-item tag

Upvotes: 1

Sumit Kumar
Sumit Kumar

Reputation: 760

Yeah, Similar issue I have found two days ago, Actually a-assets works only when you are running it through server. I have solve this by using django.

Upvotes: 0

Related Questions