CurvePath: Inconsistency with closed path

I’ve recently worked with three.js curve entities and discovered something that confused me.

Let’s say you create an instance of CurvePath and add some curve objects to it. If you want to sample evenly distributed points from that CurvePath, you call .getSpacedPoints(). The problem is that .getSpacedPoints() returns different results if the CurvePath object is closed via .closePath() or .autoClose.

This example shows the effect of .closePath(). IMO the result is correct because points are distributed over the entire path.

The next example uses .autoClose and seems to be incorrect because there is no sampling of points in the last line curve.

The problem is that CurvePath handles .autoClose and .closePath() differently. .closePath() creates an additional line curve in order to connect the last and the first point of the path. .autoClose instead doesn’t create a curve but just adds the first point twice to the points array in .getSpacedPoints() and .getPoints(). This variation looks confusing to me and i would prefer an uniform behavior.

Maybe one solution: Enhance the .add() method of CurvePath. The implementation could evaluate .autoClose and adjust the curves array property if necessary via .closePath().

/ping @zz85

Author: Fantashit

1 thought on “CurvePath: Inconsistency with closed path

Comments are closed.