最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - three.js wireframe only shape with hidden edges as dashed lines - Stack Overflow

programmeradmin3浏览0评论

I'm trying to create a specific type of 3D object in three.js. I want for example a cube in wireframe mode (so only edges shown). But I want the edges that are behind to be dashed. Illustration:

I don't know if this is feasible with three.js or if I should try directly with webgl. Should I use THREE.Mesh in wireframe or THREE.Line with LineDashedMaterial or maybe both on top of each other?

I'm trying to create a specific type of 3D object in three.js. I want for example a cube in wireframe mode (so only edges shown). But I want the edges that are behind to be dashed. Illustration:

I don't know if this is feasible with three.js or if I should try directly with webgl. Should I use THREE.Mesh in wireframe or THREE.Line with LineDashedMaterial or maybe both on top of each other?

Share Improve this question edited Mar 4, 2013 at 12:52 calude asked Feb 26, 2013 at 8:02 caludecalude 3532 silver badges10 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 10

I managed to do it. You need to create three objects.

1st object: the solid 3d object (I mean the faces not the edges)

2nd object: all edges but dashed

3rd object: all edges but normal (not dashed)

For the 1st object set the material with color: false, side: THREE.DoubleSide, depthTest: true.

Second object material: color: (whatever you like), depthTest: false.

Third object material: color: (whatever you like), depthTest: true.

I also set all materials with polygonOffset: true, polygonOffsetFactor: 1, polygonOffsetUnits: 1 to get rid of z-fighting.

This is a really cool idea. I have implemented your answer as described above at:

http://stemkoski.github./Three.js/Dashed-3D.html

in case anybody wants to see it in action.

发布评论

评论列表(0)

  1. 暂无评论