Unwanted edge in CSG result

I am trying to apply wireframe on result of CSG subtract operation, library is THREE-CSGMesh by @manthrax (btw, many thanks for this port).

Doing it this way I am getting strange artifact (please see attached image).

    wireframe = new THREE.LineSegments(
      new THREE.EdgesGeometry( mesh.geometry, 1 ), 
      new THREE.LineBasicMaterial( { color: 0x888888, linewidth: 2 } ) );
    scene.add(wireframe);

Examining this mesh in console I found nothing special, so I am completely stacked.
Any suggestions please, how to get rid of it ?
Live version is here.

Try subdividing the BoxGeometry. By default, for performance reasons, it’s segmented with the minimum number of vertices possible, might not be ideal for CSG operations.

Instead of the default 1, you can try increasing it to 32 or 64:

box = new THREE.Mesh(new THREE.BoxGeometry(1, 1, 1, 16, 16, 16), mat);    
2 Likes

Many thanks, this works !
Optimum is 40, with less than this value, small “tail” still present.

1 Like