1

I am learning how to get the most out of my buffer geometries. I slowly start to understand how they are working and what the different possibilities are.

But now I want a mesh with an outline:

enter image description here

     3------------------------------------------------2
     /                                                 \
    /                                                   \
   /                                                     \
  /                                                       \
 0---------------------------------------------------------1

To get the mesh I need to define two faces ( 0, 1, 2 ) and ( 0, 2, 3 ). So to draw this mesh my indices array will looks like this:

var indices = [ 0, 1, 2, 0, 2, 3 ];

But to draw the outline I need to connect the points in the order (0, 1, 2, 3, 0) so my line indices array looks like this:

var indices = [0, 1, 2, 3, 0];

But I can only define once a indices array to my THREE.BufferGeometry instance. So to draw both I need to clone the geometry and add it once connected to a Mesh and once as a Line. This means all positions are stored twice.

Can I not use the same buffer geometry to draw both the line and the mesh. Somehow by passing two indices arrays or by for example combining them to one and using an offset as was mentioned here in this question.

This works fine as you can see my fiddle

Community
  • 1
  • 1
Wilt
  • 41,477
  • 12
  • 152
  • 203
  • Consider using `WireframeHelper `or `EdgesHelper`, which were created because of this issue. – WestLangley Feb 03 '16 at 15:55
  • @WestLangley Can I not use 2 draw calls with multi material (mesh material and line material) to solve it with one geometry? – Wilt Apr 07 '16 at 08:02
  • You can render the mesh with a custom `ShaderMaterial`. See http://threejs.org/examples/webgl_materials_wireframe.html. – WestLangley Apr 07 '16 at 16:02

0 Answers0