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:
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