问题描述
限时送ChatGPT账号..使用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/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屋!
更多推荐
[db:关键词]
发布评论