import { Vector, Contact, Vertex, Bounds } from './geometry'; import { Body, Filter, World } from './body'; /** * The `Matter.Pair` module contains methods for creating and manipulating collision pairs. * * @class Pair */ export declare type Collision = { body: Body; bodyA: Body; bodyB: Body; collided: boolean; supports: Vertex[]; parentA: Body; parentB: Body; depth: number; axisBody: Body; axisNumber: number; reused: boolean; normal: Vector; tangent: Vector; penetration: Vector; }; export declare class Pair { id: string; bodyA: Body; bodyB: Body; activeContacts: Contact[]; separation: number; isActive: boolean; confirmedActive: boolean; isSensor: boolean; timeCreated: number; timeUpdated: number; collision: Collision | undefined; inverseMass: number; friction: number; frictionStatic: number; restitution: number; slop: number; /** * Get the id for the given pair. * @method id * @param {body} bodyA * @param {body} bodyB * @return {string} Unique pairId */ static id(bodyA: Body, bodyB: Body): string; /** * Creates a pair. * @method create * @param {collision} collision * @param {number} timestamp * @return {pair} A new pair */ constructor(collision: Collision, timestamp: number); /** * Updates a pair given a collision. * @method update * @param {pair} this * @param {collision} collision * @param {number} timestamp */ update(collision: Collision, timestamp: number): void; /** * Set a pair as active or inactive. * @method setActive * @param {pair} this * @param {bool} isActive * @param {number} timestamp */ setActive(isActive: boolean, timestamp: number): void; } export declare class Pairs { table: { [key: string]: Pair; }; list: Pair[]; collisionStart: Pair[]; collisionActive: Pair[]; collisionEnd: Pair[]; /** * Creates a new pairs structure. * @method create * @param {object} options * @return {pairs} A new pairs structure */ constructor(options?: any); /** * Updates pairs given a list of collisions. * @method update * @param {object} this * @param {collision[]} collisions * @param {number} timestamp */ update2(collisions: Collision[], timestamp: number): void; /** * Finds and removes pairs that have been inactive for a set amount of time. * @method removeOld * @param {object} pairs * @param {number} timestamp */ removeOld(timestamp: number): void; /** * Clears the given pairs structure. * @method clear * @param {pairs} pairs * @return {pairs} pairs */ clear(): this; } /** * The `Matter.SAT` module contains methods for detecting collisions using the Separating Axis Theorem. * * @class SAT */ export declare type Overlap = { overlap: number; axis: Vector; axisNumber: number; }; export declare type Projection = { min: number; max: number; }; /** * The `Matter.Detector` module contains methods for detecting collisions given a set of pairs. * * @class Detector */ export declare class Detector { /** * Finds all collisions given a list of pairs. * @method collisions * @param {pair[]} broadphasePairs * @param {engine} engine * @return {array} collisions */ static collisions(broadphasePairs: [Body, Body, number][], engine: any): Collision[]; /** * Returns `true` if both supplied collision filters will allow a collision to occur. * See `body.collisionFilter` for more information. * @method canCollide * @param {} filterA * @param {} filterB * @return {bool} `true` if collision can occur */ static canCollide(filterA: Filter, filterB: Filter): boolean; } export declare class Grid { readonly detector: typeof Detector.collisions; buckets: { [key: string]: Body[]; }; pairs: { [key: string]: [Body, Body, number]; }; pairsList: [Body, Body, number][]; bucketWidth: number; bucketHeight: number; /** * Creates a new grid. * @method create * @param {} options * @return {grid} A new grid */ constructor(options?: any); /** * Updates the grid. * @method update * @param {grid} this * @param {body[]} bodies * @param {engine} engine * @param {boolean} forceUpdate */ update(bodies: Body[], world: World, forceUpdate: boolean): void; /** * Clears the grid. * @method clear * @param {grid} this */ clear(): void; /** * Finds the union of two regions. * @method _regionUnion * @private * @param {} regionA * @param {} regionB * @return {} region */ private static regionUnion; /** * Gets the region a given body falls in for a given grid. * @method _getRegion * @private * @param {} grid * @param {} body * @return {} region */ private static getRegion; /** * Creates a region. * @method _createRegion * @private * @param {} startCol * @param {} endCol * @param {} startRow * @param {} endRow * @return {} region */ private static createRegion; /** * Gets the bucket id at the given position. * @method getBucketId * @private * @param {} column * @param {} row * @return {string} bucket id */ private static getBucketId; /** * Creates a bucket. * @method createBucket * @private * @param {} buckets * @param {} bucketId * @return {} bucket */ private static createBucket; /** * Adds a body to a bucket. * @method _bucketAddBody * @private * @param {} grid * @param {} bucket * @param {} body */ private static bucketAddBody; /** * Removes a body from a bucket. * @method _bucketRemoveBody * @private * @param {} grid * @param {} bucket * @param {} body */ private static bucketRemoveBody; /** * Generates a list of the active pairs in the grid. * @method _createActivePairsList * @private * @param {} grid * @return [] pairs */ private static createActivePairsList; } /** * The `Matter.Query` module contains methods for performing collision queries. * * See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). * * @class Query */ export declare class Query { /** * Returns a list of collisions between `body` and `bodies`. * @method collides * @param {body} body * @param {body[]} bodies * @return {object[]} Collisions */ static collides: (body: Body, bodies: Body[]) => Collision[]; /** * Casts a ray segment against a set of bodies and returns all collisions, ray width is optional. Intersection points are not provided. * @method ray * @param {body[]} bodies * @param {vector} startPoint * @param {vector} endPoint * @param {number} [rayWidth] * @return {object[]} Collisions */ static ray(bodies: Body[], startPoint: Vector, endPoint: Vector, rayWidth?: number): Collision[]; /** * Returns all bodies whose bounds are inside (or outside if set) the given set of bounds, from the given set of bodies. * @method region * @param {body[]} bodies * @param {bounds} bounds * @param {bool} [outside=false] * @return {body[]} The bodies matching the query */ static region(bodies: Body[], bounds: Bounds, outside?: boolean): Body[]; /** * Returns all bodies whose vertices contain the given point, from the given set of bodies. * @method point * @param {body[]} bodies * @param {vector} point * @return {body[]} The bodies matching the query */ static point(bodies: Body[], point: Vector): Body[]; } export declare class Resolver { /** * Prepare pairs for position solving. * @method preSolvePosition * @param {pair[]} pairs */ static preSolvePosition(pairs: Pair[]): void; /** * Find a solution for pair positions. * @method solvePosition * @param {pair[]} pairs * @param {body[]} bodies * @param {number} timeScale */ static solvePosition(pairs: Pair[], bodies: Body[], timeScale: number): void; /** * Apply position resolution. * @method postSolvePosition * @param {body[]} bodies */ static postSolvePosition(bodies: Body[]): void; /** * Prepare pairs for velocity solving. * @method preSolveVelocity * @param {pair[]} pairs */ static preSolveVelocity(pairs: Pair[]): void; /** * Find a solution for pair velocities. * @method solveVelocity * @param {pair[]} pairs * @param {number} timeScale */ static solveVelocity(pairs: Pair[], timeScale: number): void; }