function _getNeighborAhead (boid, neighbors) {
    const qa = vec2.normalize(Pool.malloc(), boid.rigidBody.velocity)
    vec2.scale(qa, qa, boid.steering.maxQueueAhead)

    const ahead = vec2.add(Pool.malloc(), boid.aabb.position, qa)

    const result = neighbors.find((neighbor) => {
        const d = vec2.distance(ahead, neighbor.aabb.position)
        if ((neighbour !== boid) && (d <= boid.steering.maxQueueRadius))
            return neighbor
    })

    Pool.free(ahead)
    Pool.free(qa)
    return result
}
// get the first neighbor that is ahead of this entity
get the first neighbor that is ahead of this entity
get the first neighbor that is ahead of this entity
function _getNeighborAhead (boid, neighbors) {
    const qa = vec2.normalize(Pool.malloc(), boid.rigidBody.velocity)
    vec2.scale(qa, qa, boid.steering.maxQueueAhead)
    const ahead = vec2.add(Pool.malloc(), boid.aabb.position, qa)
    const result = neighbors.find((neighbor) => {
        const d = vec2.distance(ahead, neighbor.aabb.position)
        if ((neighbour !== boid) && (d <= boid.steering.maxQueueRadius))
            return neighbor
    })
    Pool.free(ahead)
    Pool.free(qa)
    return result
}
function _getNeighborAhead ( boid , neighbors ) { const qa = vec2 . normalize ( Pool . malloc ( ) , boid . rigidBody . velocity ) vec2 . scale ( qa , qa , boid . steering . maxQueueAhead ) const ahead = vec2 . add ( Pool . malloc ( ) , boid . aabb . position , qa ) const result = neighbors . find ( ( neighbor ) => { const d = vec2 . distance ( ahead , neighbor . aabb . position ) if ( ( neighbour !== boid ) && ( d <= boid . steering . maxQueueRadius ) ) return neighbor } ) Pool . free ( ahead ) Pool . free ( qa ) return result }
get the first neighbor that is ahead of this entity
get the first neighbor that is ahead of this entity