AFframe: a-image เกิดข้อผิดพลาดเมื่อใช้รูปภาพจากเนื้อหา

ฉันกำลังพยายามเพิ่มรูปภาพในฉากของฉันโดย 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-asset-item มันก็ใช้งานได้:

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

คุณช่วยแนะนำสิ่งที่ฉันทำผิดได้ไหม? มันเป็นข้อผิดพลาดหรือไม่?


person Nikita Fedorov    schedule 12.10.2020    source แหล่งที่มา
comment
หากไม่มีโค้ดให้รันและดีบัก จะช่วยได้ยาก แชร์โค้ดที่รันได้แบบง่ายๆ ด้วย glitch.com/~aframe ช่วยให้ผู้อื่นช่วยคุณได้   -  person Diego Marcos    schedule 12.10.2020


คำตอบ (2)


ใช่ ปัญหาที่คล้ายกันที่ฉันพบเมื่อสองวันก่อน จริงๆ แล้ว a-assets ใช้งานได้เฉพาะเมื่อคุณใช้งานผ่านเซิร์ฟเวอร์เท่านั้น ฉันแก้ไขปัญหานี้โดยใช้ django

person Sumit Kumar    schedule 13.10.2020
comment
ที่จริงแล้วฉันใช้เซิร์ฟเวอร์ - person Nikita Fedorov; 13.10.2020

ความผิดฉันเอง. ฉันควรใช้ img แทนแท็ก a-asset-item

person Nikita Fedorov    schedule 13.10.2020