UNPKG

bird-oid

Version:

A 3D boid system with accompanying emergent behaviors. Implementation mostly based on Craig Reynolds paper Steering Behaviors For Autonomous Characters.

39 lines (38 loc) 1.62 kB
export default Boid; /** * A data structure for a single Boid. * * @property {import("gl-matrix").vec3} position * @property {import("gl-matrix").vec3} velocity * @property {import("gl-matrix").vec3} acceleration * @property {import("gl-matrix").vec3[]} target * @property {import("../types.js").BehaviorObject[]} behavious */ declare class Boid { /** * @param {import("../types.js").BehaviorObject[]} behaviors An array of behaviors to apply to the boid. */ constructor(behaviors: import("../types.js").BehaviorObject[]); position: vec3; velocity: vec3; acceleration: vec3; target: vec3; behaviors: import("../types.js").BehaviorObject[]; /** * Add a force to the boid's acceleration vector. If you need mass, you can either use behaviors.scale or override. * @param {import("gl-matrix").vec3} force */ applyForce(force: import("gl-matrix").vec3): void; /** * Compute all the behaviors specified in `boid.behaviors` and apply them via applyForce. Arguments usually come from the system and can be overridden via `behavior.options`. * @param {import("../types.js").ApplyBehaviorObject} applyOptions */ applyBehaviors({ boids, maxSpeed, maxForce, center, bounds }: import("../types.js").ApplyBehaviorObject): void; /** * Update a boid's position according to its current acceleration/velocity and reset acceleration. Usually called consecutively to `boid.applyBehaviors`. * @param {number} dt * @param {number} maxSpeed */ update(dt: number, maxSpeed: number): void; } import { vec3 } from "gl-matrix";