import { Body, World } from "./body"; import { Pair, Pairs, Grid } from "./collision"; import { Render } from "./render"; import { Mouse, MouseConstraint } from "./mouse"; export declare class Sleeping { /** * Puts bodies to sleep or wakes them up depending on their motion. * @method update * @param {body[]} bodies * @param {number} timeScale */ static update(bodies: Body[], timeScale: number): void; /** * Given a set of colliding pairs, wakes the sleeping bodies involved. * @method afterCollisions * @param {pair[]} pairs * @param {number} timeScale */ static afterCollisions(pairs: Pair[], timeScale: number): void; /** * Set a body as sleeping or awake. * @method set * @param {body} body * @param {boolean} isSleeping */ static set(body: Body, isSleeping: boolean): void; } /** * The `Matter.Engine` module contains methods for creating and manipulating engines. * An engine is a controller that manages updating the simulation of the world. * See `Matter.Runner` for an optional game loop utility. * * See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). * * @class Engine */ export declare type Timing = { timestamp: number; timeScale: number; }; export declare class Engine { world: World; pairs: Pairs; broadphase: Grid; render: Render | undefined; mouse: Mouse | undefined; mouseConstraint: MouseConstraint | undefined; positionIterations: number; velocityIterations: number; constraintIterations: number; enableSleeping: boolean; events: never[]; timing: Timing; /** * Creates a new engine. The options parameter is an object that specifies any properties you wish to override the defaults. * All properties have default values, and many are pre-calculated automatically based on other properties. * See the properties section below for detailed information on what you can pass via the `options` object. * @method create * @param {object} [options] * @return {engine} engine */ constructor(world: World); setRender(render: Render): Mouse; /** * Applys a mass dependant force to all given bodies. * @method _bodiesApplyGravity * @private * @param {body[]} bodies * @param {vector} gravity */ private bodiesApplyGravity; /** * Applys `Body.update` to all given `bodies`. * @method _bodiesUpdate * @private * @param {body[]} bodies * @param {number} deltaTime * The amount of time elapsed between updates * @param {number} timeScale * @param {number} correction * The Verlet correction factor (deltaTime / lastDeltaTime) * @param {bounds} worldBounds */ private bodiesUpdate; /** * Moves the simulation forward in time by `delta` ms. * The `correction` argument is an optional `Number` that specifies the time correction factor to apply to the update. * This can help improve the accuracy of the simulation in cases where `delta` is changing between updates. * The value of `correction` is defined as `delta / lastDelta`, i.e. the percentage change of `delta` over the last step. * Therefore the value is always `1` (no correction) when `delta` constant (or when no correction is desired, which is the default). * See the paper on Time Corrected Verlet for more information. * * Triggers `beforeUpdate` and `afterUpdate` events. * Triggers `collisionStart`, `collisionActive` and `collisionEnd` events. * @method update * @param {engine} engine * @param {number} [delta=16.666] * @param {number} [correction=1] */ update(delta?: number, correction?: number): void; /** * Clears the engine including the world, pairs and broadphase. * @method clear * @param {engine} this */ clear(): void; /** * Zeroes the `body.force` and `body.torque` force buffers. * @method _bodiesClearForces * @private * @param {body[]} bodies */ private static bodiesClearForces; /** * Applys a mass dependant force to all given bodies. * @method _bodiesApplyGravity * @private * @param {body[]} bodies * @param {vector} gravity */ private static bodiesApplyGravity; /** * Applys `Body.update` to all given `bodies`. * @method _bodiesUpdate * @private * @param {body[]} bodies * @param {number} deltaTime * The amount of time elapsed between updates * @param {number} timeScale * @param {number} correction * The Verlet correction factor (deltaTime / lastDeltaTime) * @param {bounds} worldBounds */ private static bodiesUpdate; } export declare class Runner { fps: number; correction: number; deltaSampleSize: number; counterTimestamp: number; frameCounter: number; deltaHistory: number[]; timePrev: number; timeScalePrev: number; frameRequestId: number; isFixed: boolean; enabled: boolean; delta: number; deltaMin: number; deltaMax: number; /** * Creates a new Runner. The options parameter is an object that specifies any properties you wish to override the defaults. * @method create * @param {} options */ constructor(options?: any); /** * Continuously ticks a `Matter.Engine` by calling `Runner.tick` on the `requestAnimationFrame` event. * @method run * @param {engine} engine */ static run(runner: Runner, engine: Engine): Runner; /** * A game loop utility that updates the engine and renderer by one step (a 'tick'). * Features delta smoothing, time correction and fixed or dynamic timing. * Triggers `beforeTick`, `tick` and `afterTick` events on the engine. * Consider just `Engine.update(engine, delta)` if you're using your own loop. * @method tick * @param {runner} runner * @param {engine} engine * @param {number} time */ static tick(runner: Runner, engine: Engine, time: number): void; /** * Ends execution of `Runner.run` on the given `runner`, by canceling the animation frame request event loop. * If you wish to only temporarily pause the engine, see `engine.enabled` instead. * @method stop * @param {runner} runner */ static stop(runner: Runner): void; /** * Alias for `Runner.run`. * @method start * @param {runner} runner * @param {engine} engine */ static start(runner: Runner, engine: Engine): void; } /** * The `Matter` module is the top level namespace. It also includes a function for installing plugins on top of the library. * * @class Matter */ export declare class Matter { static version: string; }