Documentation

Reference
Manual / 01

Everything you need to build intelligent collective systems. From basic physics configuration to advanced vector field evolution.

Section 01

Installation

Integrate BoidsJS into your project via npm or yarn. Zero dependencies, lightweight at < 5kb.

npm install @individual11/boidsjs
# or
yarn add @individual11/boidsjs
Section 02

Quick Start

The easiest way to get started is with our dedicated React wrapper. Simply drop the component into your workspace.

import { BoidsJS } from '@individual11/boidsjs/react';

const App = () => (
  <div style={{ width: '100vw', height: '100vh' }}>
    <BoidsJS boidCount={200} algorithm="optimized" />
  </div>
);

/ API Reference

Reference 01

Core Configuration

boidCount
numberDef: 50

Total number of boids in the simulation.

color
stringDef: #22d3ee

Color of the boids.

shape
stringDef: triangle

Visual shape: 'triangle', 'circle', or 'line'.

boidSize
numberDef: 5

Size of the boids in pixels.

Reference 02

Physics & Behavior

algorithm
stringDef: reynolds

The flocking logic: 'reynolds', 'optimized', or 'flow-field'.

maxSpeed
numberDef: 4

Maximum velocity magnitude.

minSpeed
numberDef: 2

Minimum velocity magnitude.

maxForce
numberDef: 0.1

Stability and steering strength.

Reference 03

Interactions

mouseInteraction
stringDef: none

Mode: 'none', 'attract', or 'repulse'.

mouseRadius
numberDef: 150

Influence radius for mouse interaction.

predatorCount
numberDef: 0

Number of specialized predators to avoid.

Reference 04

Visual Aids

showFlowField
booleanDef: false

Visualize underlying flow lines.

showNoiseBackground
booleanDef: false

Visualize underlying noise map.

flowFieldColor
stringDef: rgba(255,255,255,0.1)

Color of the flow lines.

Reference 05

Reynolds Options

perceptionRadius
numberDef: 50

Neighbor detection radius.

alignmentWeight
numberDef: 1.0

Strength of velocity matching.

cohesionWeight
numberDef: 1.0

Strength of group centering.

separationWeight
numberDef: 1.0

Strength of collision avoidance.

Reference 06

Flow Field Options

scale
numberDef: 0.003

Density of the noise field.

strength
numberDef: 0.25

Steering impact of the field.

Reference 07

Hooks & Callbacks

onFrame
function

Callback executed on every animation frame.