From d5b9c684a32f2ef08d0b661d7d4e7503b9ce64b7 Mon Sep 17 00:00:00 2001 From: Lukas Dachtler Date: Mon, 26 Feb 2024 23:42:20 +0100 Subject: [PATCH 1/3] marked updateVelocity as optional parameter --- src/physics/matter-js/lib/body/Body.js | 8 ++++---- types/matter.d.ts | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/physics/matter-js/lib/body/Body.js b/src/physics/matter-js/lib/body/Body.js index cb668ed6b..2362e5b4d 100644 --- a/src/physics/matter-js/lib/body/Body.js +++ b/src/physics/matter-js/lib/body/Body.js @@ -540,7 +540,7 @@ var Axes = require('../geometry/Axes'); * @method setPosition * @param {body} body * @param {vector} position - * @param {boolean} updateVelocity + * @param {boolean} [updateVelocity=false] */ Body.setPosition = function(body, position, updateVelocity) { var delta = Vector.sub(position, body.position); @@ -569,7 +569,7 @@ var Axes = require('../geometry/Axes'); * @method setAngle * @param {body} body * @param {number} angle - * @param {boolean} updateVelocity + * @param {boolean} [updateVelocity=false] */ Body.setAngle = function(body, angle, updateVelocity) { var delta = angle - body.angle; @@ -695,7 +695,7 @@ var Axes = require('../geometry/Axes'); * @method translate * @param {body} body * @param {vector} translation - * @param {boolean} [updateVelocity] + * @param {boolean} [updateVelocity=false] */ Body.translate = function(body, translation, updateVelocity) { Body.setPosition(body, Vector.add(body.position, translation), updateVelocity); @@ -707,7 +707,7 @@ var Axes = require('../geometry/Axes'); * @param {body} body * @param {number} rotation * @param {vector} [point] - * @param {boolean} [updateVelocity] + * @param {boolean} [updateVelocity=false] */ Body.rotate = function(body, rotation, point, updateVelocity) { if (!point) { diff --git a/types/matter.d.ts b/types/matter.d.ts index a01f4cc38..477243854 100644 --- a/types/matter.d.ts +++ b/types/matter.d.ts @@ -1434,7 +1434,7 @@ declare namespace MatterJS { * A `Number` specifying the delta time, in ms, since the last game step */ deltaTime: number; - + /** * An array of `Vector` objects that specify the convex hull of the rigid body. * These should be provided about the origin `(0, 0)`. E.g. @@ -2266,7 +2266,7 @@ declare namespace MatterJS { * @method rotate * @param {body} body * @param {number} rotation - * @param {boolean} [updateVelocity] + * @param {boolean} [updateVelocity=false] */ static rotate (body: BodyType, rotation: number, updateVelocity?: boolean): void; @@ -2367,18 +2367,18 @@ declare namespace MatterJS { * @method setPosition * @param {body} body * @param {vector} position - * @param {boolean} updateVelocity + * @param {boolean} [updateVelocity=false] */ - static setPosition (body: BodyType, position: Vector, updateVelocity: boolean): void; + static setPosition (body: BodyType, position: Vector, updateVelocity?: boolean): void; /** * Sets the angle of the body instantly. Angular velocity, position, force etc. are unchanged. * @method setAngle * @param {body} body * @param {number} angle - * @param {boolean} updateVelocity + * @param {boolean} [updateVelocity=false] */ - static setAngle (body: BodyType, angle: number, updateVelocity: boolean): void; + static setAngle (body: BodyType, angle: number, updateVelocity?: boolean): void; /** * Sets the linear velocity of the body instantly. Position, angle, force etc. are unchanged. See also `Body.applyForce`. @@ -2419,7 +2419,7 @@ declare namespace MatterJS { * @method translate * @param {body} body * @param {vector} translation - * @param {boolean} [updateVelocity] + * @param {boolean} [updateVelocity=false] */ static translate (body: BodyType, translation: Vector, updateVelocity?: boolean): void; @@ -2507,7 +2507,7 @@ declare namespace MatterJS { * @method rotate * @param {body} body * @param {number} rotation - * @param {boolean} [updateVelocity] + * @param {boolean} [updateVelocity=false] */ rotate (body: BodyType, rotation: number, updateVelocity?: boolean): void; @@ -2608,18 +2608,18 @@ declare namespace MatterJS { * @method setPosition * @param {body} body * @param {vector} position - * @param {boolean} updateVelocity + * @param {boolean} [updateVelocity=false] */ - setPosition (body: BodyType, position: Vector, updateVelocity: boolean): void; + setPosition (body: BodyType, position: Vector, updateVelocity?: boolean): void; /** * Sets the angle of the body instantly. Angular velocity, position, force etc. are unchanged. * @method setAngle * @param {body} body * @param {number} angle - * @param {boolean} updateVelocity + * @param {boolean} [updateVelocity=false] */ - setAngle (body: BodyType, angle: number, updateVelocity: boolean): void; + setAngle (body: BodyType, angle: number, updateVelocity?: boolean): void; /** * Sets the linear velocity of the body instantly. Position, angle, force etc. are unchanged. See also `Body.applyForce`. @@ -2668,7 +2668,7 @@ declare namespace MatterJS { * @method translate * @param {body} body * @param {vector} translation - * @param {boolean} [updateVelocity] + * @param {boolean} [updateVelocity=false] */ translate (body: BodyType, translation: Vector, updateVelocity?: boolean): void; From 929267011a4d202c04fb378bd114af052daf58e0 Mon Sep 17 00:00:00 2001 From: Lukas Dachtler Date: Wed, 6 Mar 2024 22:57:05 +0100 Subject: [PATCH 2/3] included reference for phaser types --- types/matter.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/matter.d.ts b/types/matter.d.ts index 477243854..585f5ad82 100644 --- a/types/matter.d.ts +++ b/types/matter.d.ts @@ -5,6 +5,7 @@ // Piotr Pietrzak , // Richard Davey +/// declare namespace MatterJS { // -------------------------------------------------------------- @@ -405,7 +406,7 @@ declare namespace MatterJS { * @property gameObject * @type Phaser.GameObjects.GameObject */ - gameObject?: any; + gameObject?: Phaser.GameObjects.GameObject; /** * Scale the influence of World gravity when applied to this body. @@ -1860,7 +1861,7 @@ declare namespace MatterJS { * @property gameObject * @type Phaser.GameObjects.GameObject */ - gameObject?: any; + gameObject?: Phaser.GameObjects.GameObject; /** * The scale of the Body. From f17e1df7f4291d59da97876bdf7b71d9ee7346d5 Mon Sep 17 00:00:00 2001 From: Lukas Dachtler Date: Thu, 7 Mar 2024 00:27:18 +0100 Subject: [PATCH 3/3] declared type for onCollideWith --- types/matter.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/matter.d.ts b/types/matter.d.ts index 585f5ad82..56fa184ba 100644 --- a/types/matter.d.ts +++ b/types/matter.d.ts @@ -469,13 +469,13 @@ declare namespace MatterJS { onCollideActiveCallback?: Function; /** - * A collision callback dictionary used by the `Body.setOnCollideWith` function. + * A collision callback dictionary _(body id -> function)_ used by the `Body.setOnCollideWith` function. * * @property onCollideWith - * @type object - * @default null + * @type {Object.} + * @default {} */ - onCollideWith?: any; + onCollideWith?: Record; } @@ -1953,13 +1953,13 @@ declare namespace MatterJS { onCollideActiveCallback?: Function; /** - * A collision callback dictionary used by the `Body.setOnCollideWith` function. + * A collision callback dictionary _(body id -> function)_ used by the `Body.setOnCollideWith` function. * * @property onCollideWith - * @type object - * @default null + * @type {Object.} + * @default {} */ - onCollideWith?: any; + onCollideWith?: Record; /** * Sets the onCollideWith callback.