src/boid.js
function inSight(b) {
        if (position.distanceSq(b.position) > maxDistanceSq) {
            return false;
        }
        const heading = velocity.clone().normalize();
        const difference = b.position.clone().subtract(position);
        const dotProd = difference.dotProduct(heading);

        heading.dispose();
        difference.dispose();

        return dotProd >= 0;
    }
function inSight(b) {
        if (position.distanceSq(b.position) > maxDistanceSq) {
            return false;
        }
        const heading = velocity.clone().normalize();
        const difference = b.position.clone().subtract(position);
        const dotProd = difference.dotProduct(heading);

        heading.dispose();
        difference.dispose();

        return dotProd >= 0;
    }
function inSight ( b ) { if ( position . distanceSq ( b . position ) > maxDistanceSq ) { return false ; } const heading = velocity . clone ( ) . normalize ( ) ; const difference = b . position . clone ( ) . subtract ( position ) ; const dotProd = difference . dotProduct ( heading ) ; heading . dispose ( ) ; difference . dispose ( ) ; return dotProd >= 0 ; }
is boid close enough to be in sight and facing
is boid close enough to be in sight and facing