How can I get the pairs of vertices that form the edges in EdgeGeometry?
I need to get the start point and end point coordinates of each edges. I am currently using EdgeGeometry. However, I can't figure out the order in which the vertices is stored in the attribute.
I want to store the vertices in an array, as pairs which form the edges.
addBoxEdgestoCache = () => {
const boxEdges = new THREE.EdgesGeometry(this.box.geometry);
const lineMaterial = new THREE.LineBasicMaterial( { color: 'black', linewidth: 0.005} );
const line = new THREE.LineSegments(boxEdges, lineMaterial);
this.scene.add(line);
const arrLength = boxEdges.attributes.position.array.length;
for (let i = 0; i < arrLength; i++){
// get start point
const startPt = new THREE.Vector3(boxEdges.attributes.position.array[i],
boxEdges.attributes.position.array[i+1], boxEdges.attributes.position.array[i+2]);
// get end point
const endPt = new THREE.Vector3(boxEdges.attributes.position.array[arrLength/2],
boxEdges.attributes.position.array[arrLength/2 + 1],
boxEdges.attributes.position.array[arrLength/2+2]);
// store the edge as pair of vertices
this.cache.edges.push([startPt, endPt]);
}
}
The get start point and get end point portion is currently incorrect.