EdgesGeoemtry thresholdAngle Inverse Result

I use
var egeometry = new THREE.EdgesGeometry(meshResult.geometry);
to get the edges of wall segements. With second parameter thresholdAngle 92 I get the exact opposite what I want. I get then the edges which are on a plane.But I need to remove these edges and show the now removed edges.

I modified the EdgesGeoemtry code for a undefined check.

// generate vertices

for (key in edges) {

  var e = edges[key];

  // an edge is only rendered if the angle (in degrees) between the face normals of the adjoining faces exceeds this value. default = 1 degree.

  if (

    e.face2 === undefined ||

    (faces[e.face1].normal.dot(faces[e.face2].normal) <= thresholdDot)) {//} && faces[e.face1].normal.dot(faces[e.face2].normal) >= thresholdDot2)) {

    if (e.face2 !== undefined) {

      console.log('dot', e); // faces[e.face1].normal.dot(faces[e.face2].normal));

      var vertex = sourceVertices[e.index1];

      vertices.push(vertex.x, vertex.y, vertex.z);

      vertex = sourceVertices[e.index2];

      vertices.push(vertex.x, vertex.y, vertex.z);

    }

  }

}

So this looks interesting, as i have often noticed that angles above 90 don’t give me what I would expect (showing when they shouldn’t)

however I am very hesitant of changing a bit of the code in the core (e.g. not an example) as I use the min file.

Any suggestions on implementing this fix “externally” (e.g. in my own code)

I’ve rewritten the new EdgeGeometry function:

private EdgesGeometry(geometry) {

// BufferGeometry.call(this);

//  this.type = 'EdgesGeometry';

// this.parameters = {

//   thresholdAngle: thresholdAngle

// };

var thresholdAngle = 1; // (thresholdAngle !== undefined) ? thresholdAngle : 1;

// buffer

var vertices = [];

// helper variables

var thresholdDot = Math.cos(MathUtils.DEG2RAD * 1);

var thresholdDot2 = Math.cos(MathUtils.DEG2RAD * 1111);

var edge = [0, 0], edges = {}, edge1, edge2;

var key, keys = ['a', 'b', 'c'];

// prepare source geometry

var geometry2;

if (geometry.isBufferGeometry) {

  geometry2 = new THREE.Geometry();

  geometry2.fromBufferGeometry(geometry);

} else {

  geometry2 = geometry.clone();

}

geometry2.mergeVertices();

geometry2.computeFaceNormals();

var sourceVertices = geometry2.vertices;

var faces = geometry2.faces;

// now create a data structure where each entry represents an edge with its adjoining faces

for (var i = 0, l = faces.length; i < l; i++) {

  var face = faces[i];

  for (var j = 0; j < 3; j++) {

    edge1 = face[keys[j]];

    edge2 = face[keys[(j + 1) % 3]];

    edge[0] = Math.min(edge1, edge2);

    edge[1] = Math.max(edge1, edge2);

    key = edge[0] + ',' + edge[1];

    if (edges[key] === undefined) {

      edges[key] = { index1: edge[0], index2: edge[1], face1: i, face2: undefined };

    } else {

      edges[key].face2 = i;

    }

  }

}

// generate vertices

for (key in edges) {

  var e = edges[key];

  // an edge is only rendered if the angle (in degrees) between the face normals of the adjoining faces exceeds this value. default = 1 degree.

  if (

    e.face2 === undefined ||

    (faces[e.face1].normal.dot(faces[e.face2].normal) <= thresholdDot)) {//} && faces[e.face1].normal.dot(faces[e.face2].normal) >= thresholdDot2)) {

    if (e.face2 !== undefined) {

      console.log('dot', e); // faces[e.face1].normal.dot(faces[e.face2].normal));

      var vertex = sourceVertices[e.index1];

      vertices.push(vertex.x, vertex.y, vertex.z);

      vertex = sourceVertices[e.index2];

      vertices.push(vertex.x, vertex.y, vertex.z);

    }

  }

}

var g = new THREE.BufferGeometry();

g.type = "EdgesGeometry";

// build geometry

var b = new Float32BufferAttribute(vertices, 3);

g.setAttribute('position', b);

return g;

}