@@ -107,7 +107,7 @@ declare namespace Matter {
107107 * @param {number } y
108108 * @param {number } width
109109 * @param {number } height
110- * @param {number } slope
110+ * @param {number } slope Must be a number < 1.
111111 * @param {any } [options]
112112 * @returns {Body } A new trapezoid body
113113 */
@@ -421,6 +421,17 @@ declare namespace Matter {
421421 * are both true.
422422 */
423423 collisionFilter ?: ICollisionFilter | undefined ;
424+ /**
425+ * Temporarily may hold parameters to be passed to `Vertices.chamfer` where supported by external functions.
426+ *
427+ * See `Vertices.chamfer` for possible parameters this object may hold.
428+ *
429+ * Currently only functions inside `Matter.Bodies` provide a utility using this property as a vertices pre-processing option.
430+ *
431+ * Alternatively consider using `Vertices.chamfer` directly on vertices before passing them to a body creation function.
432+ *
433+ */
434+ chamfer ?: IChamfer | null | undefined ;
424435 }
425436
426437 export interface IBodyRenderOptions {
@@ -1626,6 +1637,14 @@ declare namespace Matter {
16261637 */
16271638 static pointBWorld ( constraint : Constraint ) : Vector ;
16281639
1640+ /**
1641+ * Returns the current length of the constraint. This is the distance between both of the constraint's end points. See constraint.length for the target rest length.
1642+ * @method currentLength
1643+ * @param {constraint } constraint
1644+ * @returns {number } the current length
1645+ */
1646+ static currentLength ( constraint : Constraint ) : number ;
1647+
16291648 /**
16301649 * The first possible `Body` that this constraint is attached to.
16311650 *
@@ -1853,7 +1872,7 @@ declare namespace Matter {
18531872 * Therefore the value is always `1` (no correction) when `delta` constant (or when no correction is desired, which is the default).
18541873 * See the paper on <a href="http://lonesock.net/article/verlet.html">Time Corrected Verlet</a> for more information.
18551874 *
1856- * Triggers `beforeUpdate` and `afterUpdate` events.
1875+ * Triggers `beforeUpdate`, `beforeSolve` and `afterUpdate` events.
18571876 * Triggers `collisionStart`, `collisionActive` and `collisionEnd` events.
18581877 * @method update
18591878 * @param {engine } engine
@@ -1964,7 +1983,7 @@ declare namespace Matter {
19641983 world : World ;
19651984 }
19661985
1967- export interface IGridDefinition { }
1986+ export interface IGridDefinition { }
19681987
19691988 /**
19701989 * This module has now been replaced by `Matter.Detector`.
@@ -2354,12 +2373,22 @@ declare namespace Matter {
23542373 background ?: string | undefined ;
23552374
23562375 /**
2357- * Sets wireframe background if `render.options.wireframes` is enabled
2376+ * A CSS color string to use for background when `render.options.wireframes` is enabled.
2377+ * This may be also set to `'transparent'` or equivalent.
23582378 *
23592379 * default undefined
23602380 */
23612381 wireframeBackground ?: string | undefined ;
23622382
2383+
2384+ /**
2385+ * A CSS color string to use for stroke when `render.options.wireframes` is enabled.
2386+ * This may be also set to `'transparent'` or equivalent.
2387+ *
2388+ * default '#bbb'
2389+ */
2390+ wireframeStrokeStyle ?: string | undefined ;
2391+
23632392 /**
23642393 * Sets opacity of sleeping body if `render.options.showSleeping` is enabled
23652394 *
@@ -2408,6 +2437,7 @@ declare namespace Matter {
24082437 * From left to right, the values shown are:
24092438 * - average render frequency (e.g. 60 fps)
24102439 * - exact engine delta time used for last update (e.g. 16.66ms)
2440+ * - average updates per frame (e.g. 1)
24112441 * - average engine execution duration (e.g. 5.00ms)
24122442 * - average render execution duration (e.g. 0.40ms)
24132443 * - average effective play speed (e.g. '1.00x' is 'real-time')
@@ -2491,27 +2521,27 @@ declare namespace Matter {
24912521 interface IRenderLookAtObject {
24922522 bounds ?: Bounds | undefined ;
24932523 position ?:
2494- | {
2495- x : number ;
2496- y : number ;
2497- }
2498- | undefined ;
2524+ | {
2525+ x : number ;
2526+ y : number ;
2527+ }
2528+ | undefined ;
24992529 min ?:
2500- | {
2501- x : number ;
2502- y : number ;
2503- }
2504- | undefined ;
2530+ | {
2531+ x : number ;
2532+ y : number ;
2533+ }
2534+ | undefined ;
25052535 max ?:
2506- | {
2507- x : number ;
2508- y : number ;
2509- }
2510- | undefined ;
2536+ | {
2537+ x : number ;
2538+ y : number ;
2539+ }
2540+ | undefined ;
25112541 }
25122542
25132543 /**
2514- * The `Matter.Render` module is a simple HTML5 canvas based renderer for visualising instances of `Matter.Engine`.
2544+ * The `Matter.Render` module is a lightweight, optional utility which provides a simple canvas based renderer for visualising instances of `Matter.Engine`.
25152545 * It is intended for development and debugging purposes, but may also be suitable for simple games.
25162546 * It includes a number of drawing options including wireframe, vector with support for sprites and viewports.
25172547 */
@@ -2545,6 +2575,23 @@ declare namespace Matter {
25452575 * @param {number } pixelRatio
25462576 */
25472577 static setPixelRatio ( render : Render , pixelRatio : number ) : void ;
2578+ /**
2579+ * Sets the render `width` and `height`.
2580+ *
2581+ * Updates the canvas accounting for `render.options.pixelRatio`.
2582+ *
2583+ * Updates the bottom right render bound `render.bounds.max` relative to the provided `width` and `height`.
2584+ * The top left render bound `render.bounds.min` isn't changed.
2585+ *
2586+ * Follow this call with `Render.lookAt` if you need to change the render bounds.
2587+ *
2588+ * See also `Render.setPixelRatio`.
2589+ * @method setSize
2590+ * @param {render } render
2591+ * @param {number } width The width (in CSS pixels)
2592+ * @param {number } height The height (in CSS pixels)
2593+ */
2594+ static setSize ( render : Render , width : number , height : number ) : void ;
25482595 /**
25492596 * Renders the given `engine`'s `Matter.World` object.
25502597 * This is the entry point for all rendering and should be called every time the scene changes.
@@ -3670,6 +3717,7 @@ declare namespace Matter {
36703717 * @event afterUpdate
36713718 * @param { } event An event object
36723719 * @param {number } event.timestamp The engine.timing.timestamp of the event
3720+ * @param {number } event.delta The delta time in milliseconds value used in the update
36733721 * @param { } event.source The source object of the event
36743722 * @param { } event.name The name of the event
36753723 */
@@ -3707,13 +3755,26 @@ declare namespace Matter {
37073755 */
37083756 static on < C extends IEngineCallback > ( obj : Engine , name : "beforeUpdate" , callback : C ) : C ;
37093757
3758+ /**
3759+ * Fired after bodies updated based on their velocity and forces, but before any collision detection, constraints and resolving etc.
3760+ *
3761+ * @event beforeSolve
3762+ * @param { } event An event object
3763+ * @param {number } event.timestamp The engine.timing.timestamp of the event
3764+ * @param {number } event.delta The delta time in milliseconds value used in the update
3765+ * @param { } event.source The source object of the event
3766+ * @param { } event.name The name of the event
3767+ */
3768+ static on < C extends IEngineCallback > ( obj : Engine , name : "beforeSolve" , callback : C ) : C ;
3769+
37103770 /**
37113771 * Fired after engine update, provides a list of all pairs that are colliding in the current tick (if any)
37123772 *
37133773 * @event collisionActive
37143774 * @param { } event An event object
37153775 * @param { } event.pairs List of affected pairs
37163776 * @param {number } event.timestamp The engine.timing.timestamp of the event
3777+ * @param {number } event.delta The delta time in milliseconds value used in the update
37173778 * @param { } event.source The source object of the event
37183779 * @param { } event.name The name of the event
37193780 */
@@ -3726,6 +3787,7 @@ declare namespace Matter {
37263787 * @param { } event An event object
37273788 * @param { } event.pairs List of affected pairs
37283789 * @param {number } event.timestamp The engine.timing.timestamp of the event
3790+ * @param {number } event.delta The delta time in milliseconds value used in the update
37293791 * @param { } event.source The source object of the event
37303792 * @param { } event.name The name of the event
37313793 */
@@ -3738,6 +3800,7 @@ declare namespace Matter {
37383800 * @param { } event An event object
37393801 * @param { } event.pairs List of affected pairs
37403802 * @param {number } event.timestamp The engine.timing.timestamp of the event
3803+ * @param {number } event.delta The delta time in milliseconds value used in the update
37413804 * @param { } event.source The source object of the event
37423805 * @param { } event.name The name of the event
37433806 */
@@ -3897,7 +3960,7 @@ declare namespace Matter {
38973960 * @param { } module The module.
38983961 * @returns {boolean } `true` if `plugin.for` is applicable to `module`, otherwise `false`.
38993962 */
3900- static isFor ( plugin : Plugin , module : { name ?: string | undefined ; [ _ : string ] : any } ) : boolean ;
3963+ static isFor ( plugin : Plugin , module : { name ?: string | undefined ; [ _ : string ] : any } ) : boolean ;
39013964
39023965 /**
39033966 * Installs the plugins by calling `plugin.install` on each plugin specified in `plugins` if passed, otherwise `module.uses`.
@@ -3916,7 +3979,7 @@ declare namespace Matter {
39163979 * @param [plugins=module.uses] { } The plugins to install on module (optional, defaults to `module.uses`).
39173980 */
39183981 static use (
3919- module : { uses ?: Array < Plugin | string > | undefined ; [ _ : string ] : any } ,
3982+ module : { uses ?: Array < Plugin | string > | undefined ; [ _ : string ] : any } ,
39203983 plugins : Array < Plugin | string > ,
39213984 ) : void ;
39223985
0 commit comments