function mapPointToPathDistance (path, point) {
    let d, minDistance
    let segmentLengthTotal = 0
    let pathDistance = 0

    for (let i = 1; i < path.pointCount; i++) {
        pointToSegmentDistance(tmpSegDistance, point, path.points[i-1], path.points[i])
        d = tmpSegDistance.distance
        const segmentLength = path.lengths[i]

        if ((minDistance === undefined) || d < minDistance) {
            minDistance = d
            pathDistance = segmentLengthTotal + tmpSegDistance.segmentProjection
        }
        segmentLengthTotal += segmentLength
    }

    // return distance along path of onPath point
    return pathDistance
}
// given an arbitrary point, convert it to a distance along the path
given an arbitrary point, convert it to a distance along the path
given an arbitrary point convert it to a distance along the path
function mapPointToPathDistance (path, point) {
    let d, minDistance
    let segmentLengthTotal = 0
    let pathDistance = 0
    for (let i = 1; i < path.pointCount; i++) {
        pointToSegmentDistance(tmpSegDistance, point, path.points[i-1], path.points[i])
        d = tmpSegDistance.distance
        const segmentLength = path.lengths[i]
        if ((minDistance === undefined) || d < minDistance) {
            minDistance = d
            pathDistance = segmentLengthTotal + tmpSegDistance.segmentProjection
        }
        segmentLengthTotal += segmentLength
    }
    return pathDistance
}
function mapPointToPathDistance ( path , point ) { let d , minDistance let segmentLengthTotal = 0 let pathDistance = 0 for ( let i = 1 ; i < path . pointCount ; i ++ ) { pointToSegmentDistance ( tmpSegDistance , point , path . points [ i - 1 ] , path . points [ i ] ) d = tmpSegDistance . distance const segmentLength = path . lengths [ i ] if ( ( minDistance === undefined ) || d < minDistance ) { minDistance = d pathDistance = segmentLengthTotal + tmpSegDistance . segmentProjection } segmentLengthTotal += segmentLength } return pathDistance }
given an arbitrary point, convert it to a distance along the path
given an arbitrary point convert it to a distance along the path
// return distance along path of onPath point