import { Vector, Vertex, Bounds } from './geometry'; export declare class Impulse extends Vector { angle: number; constructor(); } /** * The `Matter.Body` module contains methods for creating and manipulating body models. * A `Matter.Body` is a rigid body that can be simulated by a `Matter.Engine`. * Factories for commonly used body configurations (such as rectangles, circles and other polygons) can be found in the module `Matter.Bodies`. * * See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). * @class Body */ export declare type Filter = { category: number; mask: number; group: number; }; export declare const DefaultCollisionFilter: Filter; export declare class Body { id: number; type: string; label: string; shape: string; parts: Body[]; position: Vector; angle: number; vertices: Vertex[]; force: Vector; torque: number; positionImpulse: Vector; previousPositionImpulse: Vector; constraintImpulse: Impulse; totalContacts: number; speed: number; angularSpeed: number; velocity: Vector; angularVelocity: number; isSensor: boolean; isStatic: boolean; isSleeping: boolean; motion: number; sleepThreshold: number; density: number; restitution: number; friction: number; frictionStatic: number; frictionAir: number; collisionFilter: Filter; slop: number; timeScale: number; visible: boolean; opacity: number; texture: string | undefined; xScale: number; yScale: number; xOffset: number; yOffset: number; fillStyle: string; strokeStyle: string; lineWidth: number; events: never[]; bounds: Bounds; chamfer: null; circleRadius: number | undefined; positionPrev: Vector; anglePrev: number; parent: Body | undefined; axes: Vector[]; area: number; mass: number; inertia: number; inverseInertia: number; inverseMass: number; constructor(options?: any); /** * Sets the body as static, including isStatic flag and setting mass and inertia to Infinity. * @method setStatic * @param {body} body * @param {bool} isStatic */ setStatic(isStatic: boolean): void; /** * Sets the mass of the body. Inverse mass, density and inertia are automatically updated to reflect the change. * @method setMass * @param {body} body * @param {number} mass */ setMass(mass: number): void; /** * Sets the density of the body. Mass and inertia are automatically updated to reflect the change. * @method setDensity * @param {body} this * @param {number} density */ setDensity(density: number): void; /** * Sets the moment of inertia (i.e. second moment of area) of the body. * Inverse inertia is automatically updated to reflect the change. Mass is not changed. * @method setInertia * @param {body} this * @param {number} inertia */ setInertia(inertia: number): void; /** * Sets the body's vertices and updates body properties accordingly, including inertia, area and mass (with respect to `body.density`). * Vertices will be automatically transformed to be orientated around their centre of mass as the origin. * They are then automatically translated to world space based on `body.position`. * * The `vertices` argument should be passed as an array of `Matter.Vector` points (or a `Matter.Vertices` array). * Vertices must form a convex hull, concave hulls are not supported. * * @method setVertices * @param {body} this * @param {vector[]} vertices */ setVertices(vertices: Vertex[]): void; /** * Sets the parts of the `body` and updates mass, inertia and centroid. * Each part will have its parent set to `body`. * By default the convex hull will be automatically computed and set on `body`, unless `autoHull` is set to `false.` * Note that this method will ensure that the first part in `body.parts` will always be the `body`. * @method setParts * @param {body} this * @param [this] parts * @param {bool} [autoHull=true] */ setParts(parts: Body[], autoHull?: boolean): void; /** * Set the centre of mass of the body. * The `centre` is a vector in world-space unless `relative` is set, in which case it is a translation. * The centre of mass is the point the body rotates about and can be used to simulate non-uniform density. * This is equal to moving `body.position` but not the `body.vertices`. * Invalid if the `centre` falls outside the body's convex hull. * @method setCentre * @param {body} this * @param {vector} centre * @param {bool} relative */ setCentre(centre: Vector, relative?: boolean): void; /** * Sets the position of the body instantly. Velocity, angle, force etc. are unchanged. * @method setPosition * @param {body} this * @param {vector} position */ setPosition(position: Vector): void; setPosition2(x: number, y: number): void; /** * Sets the angle of the body instantly. Angular velocity, position, force etc. are unchanged. * @method setAngle * @param {body} body * @param {number} angle */ setAngle(angle: number): void; /** * Sets the linear velocity of the body instantly. Position, angle, force etc. are unchanged. See also `Body.applyForce`. * @method setVelocity * @param {body} this * @param {vector} velocity */ setVelocity(velocity: Vector): void; /** * Sets the angular velocity of the body instantly. Position, angle, force etc. are unchanged. See also `Body.applyForce`. * @method setAngularVelocity * @param {body} this * @param {number} velocity */ setAngularVelocity(velocity: number): void; /** * Moves a body by a given vector relative to its current position, without imparting any velocity. * @method translate * @param {body} this * @param {vector} translation */ translate(translation: Vector): void; translate2(x: number, y: number): void; /** * Rotates a body by a given angle relative to its current angle, without imparting any angular velocity. * @method rotate * @param {body} this * @param {number} rotation * @param {vector} [point] */ rotate(rotation: number, point?: Vector): void; /** * Scales the body, including updating physical properties (mass, area, axes, inertia), from a world-space point (default is body centre). * @method scale * @param {body} body * @param {number} scaleX * @param {number} scaleY * @param {vector} [point] */ scale(scaleX: number, scaleY: number, point?: Vector): void; /** * Performs a simulation step for the given `body`, including updating position and angle using Verlet integration. * @method update * @param {body} body * @param {number} deltaTime * @param {number} timeScale * @param {number} correction */ update(deltaTime: number, timeScale: number, correction: number): void; /** * Applies a force to a body from a given world-space position, including resulting torque. * @method applyForce * @param {body} body * @param {vector} position * @param {vector} force */ applyForce(position: Vector, force: Vector): void; /** * Returns the sums of the properties of all compound parts of the parent body. * @method _totalProperties * @private * @param {body} body * @return {} */ private totalProperties; } export declare class Constraint { id: number; label: string; type: string; bodyA: Body | null; bodyB: Body | null; pointA: Vector | null; pointB: Vector | null; length: number; stiffness: number; damping: number; angularStiffness: number; angleA: number; angleB: number; visible: boolean; lineWidth: number; strokeStyle: string; renderType: string; anchors: boolean; /** * Creates a new constraint. * All properties have default values, and many are pre-calculated automatically based on other properties. * To simulate a revolute constraint (or pin joint) set `length: 0` and a high `stiffness` value (e.g. `0.7` or above). * If the constraint is unstable, try lowering the `stiffness` value and / or increasing `engine.constraintIterations`. * For compound bodies, constraints must be applied to the parent body (not one of its parts). * See the properties section below for detailed information on what you can pass via the `options` object. * @method create * @param {} options * @return {constraint} constraint */ constructor(options?: any); /** * Prepares for solving by constraint warming. * @private * @method preSolveAll * @param {body[]} bodies */ static preSolveAll(bodies: Body[]): void; /** * Solves all constraints in a list of collisions. * @private * @method solveAll * @param {constraint[]} constraints * @param {number} timeScale */ static solveAll(constraints: Constraint[], timeScale: number): void; /** * Solves a distance constraint with Gauss-Siedel method. * @private * @method solve * @param {constraint} constraint * @param {number} timeScale */ static solve(constraint: Constraint, timeScale: number): void; /** * Performs body updates required after solving constraints. * @private * @method postSolveAll * @param {body[]} bodies */ static postSolveAll(bodies: Body[]): void; /** * Returns the world-space position of `constraint.pointA`, accounting for `constraint.bodyA`. * @method pointAWorld * @param {constraint} this * @returns {vector} the world-space position */ pointAWorld(): Vector; /** * Returns the world-space position of `constraint.pointB`, accounting for `constraint.bodyB`. * @method pointBWorld * @param {constraint} this * @returns {vector} the world-space position */ pointBWorld(): Vector; } /** * The `Matter.Composite` module contains methods for creating and manipulating composite bodies. * A composite body is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`, therefore composites form a tree structure. * It is important to use the functions in this module to modify composites, rather than directly modifying their properties. * Note that the `Matter.World` object is also a type of `Matter.Composite` and as such all composite methods here can also operate on a `Matter.World`. * * See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). * * @class Composite */ export declare class Composite { id: number; type: string; parent: Composite | undefined; isModified: boolean; bodies: Body[]; constraints: Constraint[]; composites: Composite[]; label: string; /** * Creates a new composite. The options parameter is an object that specifies any properties you wish to override the defaults. * See the properites section below for detailed information on what you can pass via the `options` object. * @method create * @param {} [options] * @return {composite} A new composite */ constructor(options?: any); /** * Sets the composite's `isModified` flag. * If `updateParents` is true, all parents will be set (default: false). * If `updateChildren` is true, all children will be set (default: false). * @method setModified * @param {composite} this * @param {boolean} isModified * @param {boolean} [updateParents=false] * @param {boolean} [updateChildren=false] */ setModified(isModified: boolean, updateParents?: boolean, updateChildren?: boolean): void; /** * Generic add function. Adds one or many body(s), constraint(s) or a composite(s) to the given composite. * Triggers `beforeAdd` and `afterAdd` events on the `composite`. * @method add * @param {composite} this * @param {} object * @return {composite} The original composite with the objects added */ add(objects: any[]): this; /** * Generic remove function. Removes one or many body(s), constraint(s) or a composite(s) to the given composite. * Optionally searching its children recursively. * Triggers `beforeRemove` and `afterRemove` events on the `composite`. * @method remove * @param {composite} this * @param {} object * @param {boolean} [deep=false] * @return {composite} The original composite with the objects removed */ remove(object: any, deep?: boolean): this; /** * Adds a composite to the given composite. * @private * @method addComposite * @param {composite} this * @param {composite} compositeB * @return {composite} The original compositeA with the objects from compositeB added */ addComposite(compositeB: Composite): this; /** * Removes a composite from the given composite, and optionally searching its children recursively. * @private * @method removeComposite * @param {composite} this * @param {composite} compositeB * @param {boolean} [deep=false] * @return {composite} The original compositeA with the composite removed */ removeComposite(compositeB: Composite, deep?: boolean): this; /** * Removes a composite from the given composite. * @private * @method removeCompositeAt * @param {composite} this * @param {number} position * @return {composite} The original composite with the composite removed */ removeCompositeAt(position: number): this; /** * Adds a body to the given composite. * @private * @method addBody * @param {composite} this * @param {body} body * @return {composite} The original composite with the body added */ addBody(body: Body): this; /** * Removes a body from the given composite, and optionally searching its children recursively. * @private * @method removeBody * @param {composite} composite * @param {body} body * @param {boolean} [deep=false] * @return {composite} The original composite with the body removed */ removeBody(body: Body, deep?: boolean): this; /** * Removes a body from the given composite. * @private * @method removeBodyAt * @param {composite} composite * @param {number} position * @return {composite} The original composite with the body removed */ removeBodyAt(position: number): this; /** * Adds a constraint to the given composite. * @private * @method addConstraint * @param {composite} this * @param {constraint} constraint * @return {composite} The original composite with the constraint added */ addConstraint(constraint: Constraint): this; /** * Removes a constraint from the given composite, and optionally searching its children recursively. * @private * @method removeConstraint * @param {composite} this * @param {constraint} constraint * @param {boolean} [deep=false] * @return {composite} The original composite with the constraint removed */ removeConstraint(constraint: Constraint, deep?: boolean): this; /** * Removes a body from the given composite. * @private * @method removeConstraintAt * @param {composite} this * @param {number} position * @return {composite} The original composite with the constraint removed */ removeConstraintAt(position: number): this; /** * Removes all bodies, constraints and composites from the given composite. * Optionally clearing its children recursively. * @method clear * @param {composite} this * @param {boolean} keepStatic * @param {boolean} [deep=false] */ clear(keepStatic: boolean, deep?: boolean): this; /** * Returns all bodies in the given composite, including all bodies in its children, recursively. * @method allBodies * @param {composite} composite * @return {body[]} All the bodies */ allBodies(): Body[]; /** * Returns all constraints in the given composite, including all constraints in its children, recursively. * @method allConstraints * @param {composite} composite * @return {constraint[]} All the constraints */ allConstraints(): Constraint[]; /** * Returns all composites in the given composite, including all composites in its children, recursively. * @method allComposites * @param {composite} this * @return {composite[]} All the composites */ allComposites(): Composite[]; /** * Assigns new ids for all objects in the composite, recursively. * @method rebase * @param {composite} composite * @return {composite} Returns composite */ rebase(): this; /** * Translates all children in the composite by a given vector relative to their current positions, * without imparting any velocity. * @method translate * @param {composite} composite * @param {vector} translation * @param {bool} [recursive=true] */ translate(translation: Vector, recursive?: boolean): this; /** * Rotates all children in the composite by a given angle about the given point, without imparting any angular velocity. * @method rotate * @param {composite} composite * @param {number} rotation * @param {vector} point * @param {bool} [recursive=true] */ rotate(rotation: number, point: Vector, recursive?: boolean): this; /** * Scales all children in the composite, including updating physical properties (mass, area, axes, inertia), from a world-space point. * @method scale * @param {composite} composite * @param {number} scaleX * @param {number} scaleY * @param {vector} point * @param {bool} [recursive=true] */ scale(scaleX: number, scaleY: number, point: Vector, recursive?: boolean): this; /** * Returns the union of the bounds of all of the composite's bodies. * @method bounds * @param {composite} this The composite. * @returns {bounds} The composite bounds. */ mkbounds(): Bounds; } export declare class World extends Composite { gravity: Vector; bounds: Bounds; upsideDown: boolean; constructor(options?: any); }