I am working with a Geometry that has vertices forming a polyline. However, the offset I have created is not accurate. Currently, I am calculating the center of the geometry and then offsetting a value relative to this center. This method is resulting in an incorrect offset.
This is my current code:
var size = 10;
var geo = this.mesh.geometry,
center = new THREE.Vector3();
geo.computeBoundingBox();
geo.boundingBox.getCenter(center);
geo.vertices.forEach(function(vertice){
var C = new THREE.Vector3()
C.subVectors( vertice, center ).multiplyScalar( 1 + ( size / C.length() ) ).add( center );
vertice.copy(C);
});
geo.verticesNeedUpdate = true;
After analyzing this issue, I am considering a different approach which involves using the previous and next vertices to calculate a more precise base point for the offset. The diagram below illustrates what I aim to achieve. While I know the vertices a, b, and c, I am uncertain about how to determine the vertex at the intersection of the two lines at a 90-degree angle.
By adopting this new method, I hope to calculate a more accurate offset per vertex with improved distance options. Can anyone provide insights on how to calculate the purple dot between points a and b?