[英]A-Frame cursor with transparent image has a wrong draw order
I have a transparent image cursor, that is, an image that is a child of the camera. 我有一个透明的图像光标,即一个相机的孩子的图像。
<a-camera>
<a-image position="0 0 -1" width="0.2" height="0.2" transparent="true" src="image.png">
</a-camera>
I'm having a tough time getting it to appear above other transparent images (such as the dinosaur). 我很难让它出现在其他透明图像(如恐龙)之上。 I'm seeing odd artifacts:
我看到奇怪的文物:
If used with material="depthTest: false;"
如果与
material="depthTest: false;"
it appears behind other transparent images: 它出现在其他透明图像后面:
There's a lot of material on StackOverflow about transparency with Three.js, but non of it pertains to A-Frame. StackOverflow上有很多关于Three.js透明度的材料,但不属于A-Frame。 I did try playing with the
renderOrder
property on various objects with no luck. 我确实尝试在各种对象上使用
renderOrder
属性而没有运气。
How can I solve this? 我怎么解决这个问题?
Relevant codepen: 相关代码:
https://codepen.io/OpherV/pen/oBqgBa?editors=1000 https://codepen.io/OpherV/pen/oBqgBa?editors=1000
So as it turns out, sortObjects
is explicitly changed to false by A-Frame, even though in ThreeJS it's true by default. 事实证明,
sortObjects
被A-Frame 明确地改为 false,即使在ThreeJS中它默认是真的。 I'm not sure why, as this isn't documented anywhere. 我不知道为什么,因为这没有在任何地方记录。
It took a while to find this out but knowing this the solution is quite simple: 需要一段时间才能找到它,但知道这个解决方案非常简单:
document.querySelector('a-scene').renderer.sortObjects = true;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.