import { type Vec2 } from "../math/vec2"; /** * A moving agent to apply steering behaviors on */ export interface Agent { position: Vec2; velocity: Vec2; rotation: number; angularVelocity: number; radius: number; mass: number; maxSpeed: number; maxForce: number; turnRate: number; accumulatedForce: Vec2; bounds_force?: Vec2; } export type AgentParams = { radius: number; mass: number; maxSpeed: number; maxForce: number; turnRate: number; }; /** * Creates an agent */ export declare function agent(position: Vec2, params: AgentParams): Agent; export type SteeringForce = Vec2; /** * Interface for Steering Behaviors to implement * @param weight a unitless value of influence weight within all behaviors * @param compute returns a direction vector to steer towards */ export interface SteeringBehavior { weight: number; compute(agent: Agent, dt: number): Vec2; } type TargetProvider = () => Vec2 | undefined; export declare class Seek implements SteeringBehavior { weight: number; speedFactor: number; target: TargetProvider; /** * Create a Seek Behavior that Seeks the provided target * @param weight weight of influence (a unitless value) * @param speedFactor a factor to multiply the Seek speed * @param target a TargetProvider that returns the position of the target */ constructor(weight: number, speedFactor: number, target: TargetProvider); compute(agent: Agent): Vec2; } export declare class Arrive implements SteeringBehavior { weight: number; speedFactor: number; target: TargetProvider; slowRadius: number; /** * Create an Arrive Behavior that Arrives at the provided target. * @param weight weight of influence (a unitless value) * @param speedFactor a factor to multiply the Seek speed * @param target a TargetProvider that returns the position of the target */ constructor(weight: number, speedFactor: number, slowRadius: number, target: TargetProvider); compute(agent: Agent): Vec2; } /** * Call this within update loop every frame to update an Agent * @param body Agent to update * @param behaviors list of behaviors to apply * @param bounds list of Boundaries to apply collision detection * @param delta delta time in seconds */ export declare function update_agent(body: Agent, behaviors: SteeringBehavior[], bounds: Boundary[], delta: number): void; export type Penetration = { signedDistance: number; normal: Vec2; }; export interface Boundary { penetration(p: Vec2): Penetration; } export declare class WanderJitter implements SteeringBehavior { weight: number; interval: number; timer: number; wanderAngle: number; /** * Applies Jitter to movement * @param weight weight of influence * @param interval interval of time in seconds to apply the jitter at (periodic) */ constructor(weight: number, interval?: number); compute(agent: Agent, dt: number): Vec2; } export declare class Wander implements SteeringBehavior { weight: number; circleDistance: number; circleRadius: number; jitter: number; private wanderAngle; /** * Applies a Smooth Wander behavior to movement * @param weight influence of weight * @param circleDistance controls smoothing factor * @param circleRadius controls jitter and smoothing factor * @param jitter controls jitter factor */ constructor(weight: number, circleDistance?: number, circleRadius?: number, jitter?: number); compute(agent: Agent, dt: number): Vec2; reset(directionHint?: Vec2): void; } export declare class FlightAvoidance implements SteeringBehavior { weight: number; obstacles: () => Obstacle[]; radius: number; falloff: number; forwardBias: number; /** * Flights away from obstacles * @param weight weight of influence * @param obstacles array of obstacles to flight away from * @param radius the distance of radius to keep away * @falloff controls smoothing factor (best to keep close to [1-2]) * @forwardBias controls smoothing factor (best to keep between [0, 1]) */ constructor(weight: number, obstacles: () => Obstacle[], radius?: number, falloff?: number, forwardBias?: number); compute(agent: Agent): Vec2; } /** * Represents an Obstacle with a position and a radius */ export type Obstacle = { position: Vec2; radius: number; }; export {}; //# sourceMappingURL=steer.d.ts.map