src/boid.js
function followPath(path, loop) {
        loop = !!loop;

        const wayPoint = path[pathIndex];
        if (!wayPoint) {
            pathIndex = 0;
            return boid;
        }
        if (position.distanceSq(wayPoint) < pathThresholdSq) {
            if (pathIndex >= path.length - 1) {
                if (loop) {
                    pathIndex = 0;
                }
            } else {
                pathIndex++;
            }
        }
        if (pathIndex >= path.length - 1 && !loop) {
            arrive(wayPoint);
        } else {
            seek(wayPoint);
        }
        return boid;
    }
function followPath(path, loop) {
        loop = !!loop;

        const wayPoint = path[pathIndex];
        if (!wayPoint) {
            pathIndex = 0;
            return boid;
        }
        if (position.distanceSq(wayPoint) < pathThresholdSq) {
            if (pathIndex >= path.length - 1) {
                if (loop) {
                    pathIndex = 0;
                }
            } else {
                pathIndex++;
            }
        }
        if (pathIndex >= path.length - 1 && !loop) {
            arrive(wayPoint);
        } else {
            seek(wayPoint);
        }
        return boid;
    }
function followPath ( path , loop ) { loop = ! ! loop ; const wayPoint = path [ pathIndex ] ; if ( ! wayPoint ) { pathIndex = 0 ; return boid ; } if ( position . distanceSq ( wayPoint ) < pathThresholdSq ) { if ( pathIndex >= path . length - 1 ) { if ( loop ) { pathIndex = 0 ; } } else { pathIndex ++ ; } } if ( pathIndex >= path . length - 1 && ! loop ) { arrive ( wayPoint ) ; } else { seek ( wayPoint ) ; } return boid ; }
follow a path made up of an array or vectors
follow a path made up of an array or vectors