Occluded object with three.js behaving strangely

☆樱花仙子☆ 提交于 2019-12-11 13:02:41

问题


Using the three.js library I managed to show occluded edges of a 3D object as dashed lines.

And I want edges occluded by other objects to behave the same way.

With the solution explained here it's working fine except in some strange cases.

Here's an illustration of such a case (I use an orthographic camera so we don't see how far away objects are from each other, hence the text in the picture):

Has anyone ever encountered something similar?

Any idea why in this case it's not working?

Maybe the part polygonOffset: true, polygonOffsetFactor: 1, polygonOffsetUnits: 1 in my code is misused.

Or maybe side: THREE.DoubleSide in my material is the source of this problem. Because I've seen it has some weird behaviour with transparency.

Here's my code : http://jsfiddle.net/car3v/4/


回答1:


The object with the dashed lines with the material's depthTest: false has to be in front in case it's occluded by a mesh of a "plain" object. So I just set manually dashed_object.renderDepth = 9007199254740992; which is the biggest integer possible in JavaScript and now it's working properly.



来源:https://stackoverflow.com/questions/16110716/occluded-object-with-three-js-behaving-strangely

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!