具有透明图像的A帧光标具有错误的绘制顺序

时间:2017-02-01 15:45:56

标签: javascript three.js transparency aframe

我有一个透明的图像光标,也就是说,一个图像是相机的孩子。

<a-camera>
    <a-image position="0 0 -1" width="0.2" height="0.2" transparent="true" src="image.png">
</a-camera>

我很难让它出现在其他透明图像(例如恐龙)之上。我看到奇怪的文物:

enter image description here

如果与material="depthTest: false;"一起使用,则会显示在其他透明图片后面:

enter image description here

StackOverflow上有很多关于Three.js透明度的材料,但不属于A-Frame。我确实试过在各种物体上玩renderOrder属性而没有运气。

我该如何解决这个问题?

相关代码:

https://codepen.io/OpherV/pen/oBqgBa?editors=1000

1 个答案:

答案 0 :(得分:3)

事实证明,A {Frame sortObjectsexplicitly changed为假,即使在ThreeJS中它默认为真。我不知道为什么,因为这里没有记录。

需要一段时间才能找到这个,但知道这个解决方案非常简单:

document.querySelector('a-scene').renderer.sortObjects = true;