本文介绍了在另一个顶部显示一个网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 2 个尺寸大致相同(几乎相同)的 3D 模型;两个网格将在几个点相交和重叠.我希望一个网格始终显示在另一个上方,并且下面物体的网格永远不会显示,除非它没有被顶部物体的网格覆盖——就像背心穿在衬衫上一样(背心是上面显示的网格).没有缩放,我怎么能做到这一点?提前致谢!

I have 2 3D models with roughly the same (pretty much the same) dimensions; both meshes will intersect and overlap at several points. I would like one mesh to always be displayed above the other and the mesh of the object underneath is never displayed unless it isn't covered by the mesh of the object on top--much like how a vest is worn over a shirt (vest is the mesh being displayed above). Without scaling, how can I achieve this? Thanks in advance!

推荐答案

您需要将网格的 renderOrder 和材质的 depthTest 属性设置为 .

You need to set the renderOrder of your meshes and the depthTest property of the materials to false.

 material.depthTest = false;

 mesh1.renderOrder = 0;
 mesh2.renderOrder = 1;

也看看这个jsfiddle:http://jsfiddle.net/p2nuga2f/1/

Also have a look at this jsfiddle: http://jsfiddle.net/p2nuga2f/1/

还有这个 Three.js 讨论主题:https://discourse.threejs.org/t/always-render-mesh-on-top-of-another/120

and this three.js discourse thread: https://discourse.threejs.org/t/always-render-mesh-on-top-of-another/120

这篇关于在另一个顶部显示一个网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 02:25