From 5be749c9885888f6da5ec65f5e1761252cf8c78a Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 18 Nov 2022 21:39:47 +0000 Subject: [PATCH] Added setCentre. Fix #6065 --- types/matter.d.ts | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/types/matter.d.ts b/types/matter.d.ts index 9f5e8565b..464dc855c 100644 --- a/types/matter.d.ts +++ b/types/matter.d.ts @@ -2306,11 +2306,24 @@ declare namespace MatterJS { * Note that this method will ensure that the first part in `body.parts` will always be the `body`. * @method setParts * @param {body} body - * @param [body] parts + * @param {body[]} parts * @param {bool} [autoHull=true] */ static setParts (body: BodyType, parts: BodyType[], 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} body + * @param {vector} centre + * @param {bool} relative + */ + static setCentre (body: BodyType, centre: Vector, relative: boolean): void; + /** * Sets the position of the body instantly. Velocity, angle, force etc. are unchanged. * @method setPosition @@ -2489,6 +2502,19 @@ declare namespace MatterJS { */ setParts (body: BodyType, parts: BodyType[], 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} body + * @param {vector} centre + * @param {bool} relative + */ + setCentre (body: BodyType, centre: Vector, relative: boolean): void; + /** * Sets the position of the body instantly. Velocity, angle, force etc. are unchanged. * @method setPosition