Three.js 行为异常的被遮挡对象

编程入门 行业动态 更新时间:2024-10-26 03:34:24
本文介绍了Three.js 行为异常的被遮挡对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送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:关键词]

本文发布于:2023-04-30 15:12:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1395698.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:遮挡   异常   对象   js

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!