i have a lot of lines, and the effect I want to achieve is to make them thicker and change color when the mouse touches them.
My code:
// ...
// when creating a scene
let line_g = new LineGeometry();
let mat = new LineMaterial({
linewidth: 2.5,
color: 0x00ff00,
});
mat.resolution.set(containerRect.width, containerRect.height);
this.highLightLine = new Line2(line_g, mat);
this.scene.add(this.highLightLine);
//...
// when the mouse gets the position of the line
this.highLightLine.geometry.setPositions(
this.scene.linesList[edgeIndices[0]].vertex_coord
);
I instantiate a line2 when creating a scene, get the point array of the line when the mouse picks up the line, and use the setPositions method to give it to the previously created line2, but this will report the following error
Error:
THREE.LineSegmentsGeometry.computeBoundingSphere():
Computed radius is NaN. The instanced position data is likely to have NaN values
if i write them together like this, it can be displayed normally.
let line_g = new LineGeometry();
line_g.setPositions(
this.scene.linesList[edgeIndices[0]].vertex_coord
);
let mat = new LineMaterial({
linewidth: 2.5,
color: 0x00ff00,
});
mat.resolution.set(containerRect.width, containerRect.height);
this.highLightLine = new Line2(line_g, mat);
this.scene.add(this.highLightLine);

