Merge pull request #6746 from lukas-dachtler/fix/matterJSTypes

fixed MatterJS type definitions
This commit is contained in:
Richard Davey 2024-09-03 14:44:05 +01:00 committed by GitHub
commit b8839e4e70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 27 deletions

View file

@ -542,7 +542,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);
@ -571,7 +571,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;
@ -697,7 +697,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);
@ -709,7 +709,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) {

47
types/matter.d.ts vendored
View file

@ -5,6 +5,7 @@
// Piotr Pietrzak <https://github.com/hasparus>,
// Richard Davey <rich@photonstorm.com>
/// <reference types="./phaser" />
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.
@ -468,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.<number, Function>}
* @default {}
*/
onCollideWith?: any;
onCollideWith?: Record<number, Function>;
}
@ -1434,7 +1435,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.
@ -1860,7 +1861,7 @@ declare namespace MatterJS {
* @property gameObject
* @type Phaser.GameObjects.GameObject
*/
gameObject?: any;
gameObject?: Phaser.GameObjects.GameObject;
/**
* The scale of the Body.
@ -1952,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.<number, Function>}
* @default {}
*/
onCollideWith?: any;
onCollideWith?: Record<number, Function>;
/**
* Sets the onCollideWith callback.
@ -2266,7 +2267,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 +2368,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 +2420,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 +2508,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 +2609,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 +2669,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;