threejs-worldgen
    Preparing search index...

    Class Flock

    A flock (fish school, bird flock, herd) simulated with boids on the CPU. Positions and velocities are float64 in whatever coordinates the environment uses (a world's local frame). Pure, seeded and fixed-step: call Flock.step with the same dt and you get the same flock everywhere.

    O(n²) neighbour search per step.

    Index
    • Creates count members around home, each placed where the environment is usable (else at home), swimming in random horizontal directions. Everything is drawn from seed.

      Parameters

      • seed: number
      • count: number
      • home: [number, number, number]
      • params: BoidParams
      • environment: Environment
      • spread: number = ...

      Returns Flock

    count: number

    Members.

    environment: Environment

    Where the flock may be.

    heading: Float64Array

    Wander heading per member, radians.

    home: [number, number, number]

    Home position the flock is leashed to.

    params: BoidParams

    Steering parameters (may be changed between steps).

    position: Float64Array

    Positions, xyz per member.

    steps: number = 0

    Steps taken so far.

    velocity: Float64Array

    Velocities, xyz per member.

    • Advances the flock by one fixed step of dt seconds. predators are fled from.

      Parameters

      Returns void