Drag object along paths

Instead of fixing the code, I suggest you try another approach. Have you considered to work with Line3? It’s a mathematical representation of a line segment in 3D space defined by a start and end point. The class provides a method called Line3.closestPointToPoint() that allows you to compute the closest point on the line for a given point in 3D space. It’s also possible to clamp the result so the closest point is between the start and end point. Both features could be useful if you want to restrict the object movement along the line (and not overshoot).

So try to remove the usage of THREE.Path and give THREE.Line3 a chance.

2 Likes