Remove inner line with EdgesGeometry

I’m creating an BufferGeometry. Now I’m trying to get the outer lines of the geometry with EdgesGeometry. This works fine with following code:
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(‘position’, new THREE.BufferAttribute(vertices, 3));
const edges = new THREE.EdgesGeometry(geometry);
const line = new THREE.LineSegments(edges, new THREE.LineBasicMaterial({ color: 0xc4eaff }));

But it’s possible that there are “holes” in my BufferGeometry. Is there a way to remove those with EdgesGeometry?

What I get:
image

What I want:
image

EdgesGeometry visualizes all edges which are not shared. Hence, it will also visualize the mentioned holes of your geometry.

EdgesGeometry does not support your use case (rendering just the outline) by default. So I’m afraid you have to implement an enhanced version of EdgesGeometry that fulfills your requirements.

I’ve managed to solve the problem by:

  1. Get a vert at the outer line in EdgesGeometry
  2. ‘walk’ from vert to vert on outerline
  3. Stop when first vert is reached again
  4. Create a shape from the verts, extract lines