Three.js 行为异常的被遮挡对象 [英] Occluded object with three.js behaving strangely

查看:48
本文介绍了Three.js 行为异常的被遮挡对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用three.js 库,我设法将3D 对象的被遮挡边缘显示为虚线.

而且我希望被其他物体遮挡的边也表现得一样.

解决方案

带有虚线和材质 depthTest: false 的对象必须在前面,以防它被普通"对象.所以我只是手动设置 dashed_object.renderDepth = 9007199254740992; 这是 JavaScript 中可能的最大整数,现在它可以正常工作了.

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/

解决方案

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.

这篇关于Three.js 行为异常的被遮挡对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆