Is there any way to solve this issue with EdgesGeometry. I want to get rid of the un-closed edges. I modified EdgesGeometry source to discard the Geometry.mergeVertices() to save some iterations. But it also gave me another problem. I get some lines that are never gone no matter what the threshold angle is. This too could be fixed if I somehow remove the unclosed edges. But none of my ideas on tackling this seemed to work perfectly. Any ideas on how I will do it?
initGeometry: function(thresholdAngle, normalSize) {
normalSize = normalSize === undefined ? 1 : normalSize;
this.edges = {};
var edge1, edge2;
var keys = ['a', 'b', 'c'];
var key, v1 = new THREE.Vector3(),
v2 = new THREE.Vector3();
var face, a, b;
var vertices = this.object.geometry.vertices;
var faces = this.object.geometry.faces;
var normal = new THREE.Vector3();
var normals = [];
for (var i = 0; i < faces.length; i++) {
face = faces[i];
for (var j = 0; j < 3; j++) {
a = face[keys[j]];
v1.copy(vertices[a]);
normal.copy(face.vertexNormals[j]);
v2.copy(v1).add(normal.setLength(normalSize));
normals.push(v1.x, v1.y, v1.z);
normals.push(v2.x, v2.y, v2.z);
//
b = face[keys[(j + 1) % 3]];
v2.copy(vertices[b]);
key = createEdgeKey(v1, v2);
if (this.edges[key]) {
this.edges[key].face2 = i;
} else {
this.edges[key] = {
vertex1: a,
vertex2: b,
face1: i,
face2: undefined
};
}
}
}
var points = [];
for (var i = 0; i < vertices.length; i++) {
v1.copy(vertices[i]);
points.push(v1.x, v1.y, v1.z);
}
var geometry = new THREE.BufferGeometry();
geometry.setAttribute('position', new THREE.Float32BufferAttribute(normals, 3));
this.normalLines.geometry = geometry;
geometry = new THREE.BufferGeometry();
geometry.setAttribute('position', new THREE.Float32BufferAttribute(points, 3));
this.points.geometry = geometry;
this.updateEdgeLines();
},
updateEdgeLines: function(thresholdAngle) {
thresholdAngle = thresholdAngle === undefined ? 1 : thresholdAngle;
var thresholdDot = Math.cos(thresholdAngle * Math.PI / 180);
var array = [];
var vertices = this.object.geometry.vertices;
var faces = this.object.geometry.faces;
var processedFaces = [];
for (key in this.edges) {
var e = this.edges[key];
if (e.face2 !== undefined && faces[e.face2].normal.dot(faces[e.face1].normal) <= thresholdDot) {
processedFaces.push(e.face1, e.face2);
}
}
for (key in this.edges) {
var e = this.edges[key];
if (e.face2 === undefined || faces[e.face2].normal.dot(faces[e.face1].normal) <= thresholdDot) {
array.push(vertices[e.vertex1].x, vertices[e.vertex1].y, vertices[e.vertex1].z);
array.push(vertices[e.vertex2].x, vertices[e.vertex2].y, vertices[e.vertex2].z);
}
}
var geometry = new THREE.BufferGeometry();
geometry.setAttribute('position', new THREE.Float32BufferAttribute(array, 3));
this.edgeLines.geometry = geometry;
},