Three.js - 在另一个之上的几何 [英] Three.js - Geometry on top of another
本文介绍了Three.js - 在另一个之上的几何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Three.js 中是否可以始终在场景顶部渲染网格,即使它的位置在所有对象后面?我正在使用网格实现套索选择,我需要在场景其余部分的顶部渲染选择框.
Is it posible in Three.js to have a mesh always rendered on top of the scene, even if it's position is behind all objects? I'm implementing a lasso selection with a mesh and I need to render the selecting box on top of the rest of the scene.
推荐答案
是.
首先这样做:
renderer.autoClear = false;
然后创建第二个场景,其中仅包含您想要位于顶部的对象.然后,在您的渲染循环中:
Then create a second scene that contains just the objects you want to be on top. Then, in your render loop:
renderer.clear(); // clear buffers
renderer.render( scene, camera ); // render scene 1
renderer.clearDepth(); // clear depth buffer
renderer.render( scene2, camera ); // render scene 2
另一种解决方案是只有一个场景,但使用此模式:
Another solution is to have just one scene, but use this pattern:
mesh.renderOrder = 999;
mesh.onBeforeRender = function( renderer ) { renderer.clearDepth(); };
如果网格具有单一材质,它将渲染在顶部".
If the mesh has a single material, it will render "on top".
这篇关于Three.js - 在另一个之上的几何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文