src/boid.js
function arrive(targetVec) {
        const desiredVelocity = targetVec.clone().subtract(position);
        desiredVelocity.normalize();

        const distanceSq = position.distanceSq(targetVec);
        if (distanceSq > arriveThresholdSq) {
            desiredVelocity.scaleBy(maxSpeed);
        } else {
            const scalar = maxSpeed * distanceSq / arriveThresholdSq;
            desiredVelocity.scaleBy(scalar);
        }
        const force = desiredVelocity.subtract(velocity);
        steeringForce.add(force);
        force.dispose();

        return boid;
    }
function arrive(targetVec) {
        const desiredVelocity = targetVec.clone().subtract(position);
        desiredVelocity.normalize();

        const distanceSq = position.distanceSq(targetVec);
        if (distanceSq > arriveThresholdSq) {
            desiredVelocity.scaleBy(maxSpeed);
        } else {
            const scalar = maxSpeed * distanceSq / arriveThresholdSq;
            desiredVelocity.scaleBy(scalar);
        }
        const force = desiredVelocity.subtract(velocity);
        steeringForce.add(force);
        force.dispose();

        return boid;
    }
function arrive ( targetVec ) { const desiredVelocity = targetVec . clone ( ) . subtract ( position ) ; desiredVelocity . normalize ( ) ; const distanceSq = position . distanceSq ( targetVec ) ; if ( distanceSq > arriveThresholdSq ) { desiredVelocity . scaleBy ( maxSpeed ) ; } else { const scalar = maxSpeed * distanceSq / arriveThresholdSq ; desiredVelocity . scaleBy ( scalar ) ; } const force = desiredVelocity . subtract ( velocity ) ; steeringForce . add ( force ) ; force . dispose ( ) ; return boid ; }
seek until within arriveThreshold
seek until within arriveThreshold