From dff414fe82b3f481c7c5d325b66bda29dbc1ac48 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 6 Oct 2020 13:47:49 +0100 Subject: [PATCH] Added Grid Config typedefs --- src/gameobjects/mesh/Mesh.js | 23 ++++++++++--------- .../mesh/typedefs/MeshGridConfig.js | 14 +++++++++++ src/gameobjects/mesh/typedefs/index.js | 9 ++++++++ 3 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 src/gameobjects/mesh/typedefs/MeshGridConfig.js create mode 100644 src/gameobjects/mesh/typedefs/index.js diff --git a/src/gameobjects/mesh/Mesh.js b/src/gameobjects/mesh/Mesh.js index 3f4abac1c..7cd2e88a9 100644 --- a/src/gameobjects/mesh/Mesh.js +++ b/src/gameobjects/mesh/Mesh.js @@ -282,15 +282,23 @@ var Mesh = new Class({ }, /** - * Creates a grid based on the given parameters and adds it to this Mesh. + * Creates a grid based on the given configuration object and adds it to this Mesh. * - * The size of the grid is given in pixels. + * The size of the grid is given in pixels. An example configuration may be: + * + * `{ width: 256, height: 256, widthSegments: 2, heightSegments: 2, tile: true }` + * + * This will create a grid Mesh 256 x 256 pixels in size, split into 2x2 segments, with + * the texture tiling across the cells. * * You can optionally split the grid into segments both vertically and horizontally. This will * generate two faces per grid segment as a result. * + * The `tile` parameter allows you to control if the tile will repeat across the grid + * segments, or be displayed in full. + * * You may add multiple grids to a single Mesh, although they will act as one when - * moved or rotated. You can offset the grid via the `posX` and `posY` parameters. + * moved or rotated. You can offset the grid via the `x` and `y` properties. * * UV coordinates are generated based on the currently set texture `Frame` of this Mesh. For * example, if this Mesh is using a full texture, the UVs will be in the range 0 to 1. If it's @@ -300,14 +308,7 @@ var Mesh = new Class({ * @method Phaser.GameObjects.Mesh#addGrid * @since 3.50.0 * - * @param {number} [width=128] - The width of the grid in pixels. - * @param {number} [height=128] - The height of the grid in pixels. - * @param {number} [widthSegments=1] - The number of segments to split the grid horizontally in to. - * @param {number} [heightSegments=1] - The number of segments to split the grid vertically in to. - * @param {number} [posX=0] - Offset the grid x position by this amount. - * @param {number} [posY=0] - Offset the grid y position by this amount. - * @param {number|number[]} [colors=0xffffff] - An array of colors, one per vertex, or a single color value applied to all vertices. - * @param {number|number[]} [alphas=1] - An array of alpha values, one per vertex, or a single alpha value applied to all vertices. + * @param {Phaser.Types.GameObjects.Mesh.MeshGridConfig} config - A Grid configuration object. * * @return {this} This Mesh Game Object. */ diff --git a/src/gameobjects/mesh/typedefs/MeshGridConfig.js b/src/gameobjects/mesh/typedefs/MeshGridConfig.js new file mode 100644 index 000000000..cc54d0fdd --- /dev/null +++ b/src/gameobjects/mesh/typedefs/MeshGridConfig.js @@ -0,0 +1,14 @@ +/** + * @typedef {object} Phaser.Types.GameObjects.Mesh.MeshGridConfig + * @since 3.50.0 + * + * @property {number} [width=128] - The width of the grid in pixels. + * @property {number} [height=128] - The height of the grid in pixels. + * @property {number} [widthSegments=1] - The number of segments to split the grid horizontally in to. + * @property {number} [heightSegments=1] - The number of segments to split the grid vertically in to. + * @property {number} [x=0] - Offset the grid x position by this amount. + * @property {number} [y=0] - Offset the grid y position by this amount. + * @property {number|number[]} [colors=0xffffff] - An array of colors, one per vertex, or a single color value applied to all vertices. + * @property {number|number[]} [alphas=1] - An array of alpha values, one per vertex, or a single alpha value applied to all vertices. + * @property {boolean} [tile=false] - Should the texture tile (repeat) across the grid segments, or display as a single texture? + */ diff --git a/src/gameobjects/mesh/typedefs/index.js b/src/gameobjects/mesh/typedefs/index.js new file mode 100644 index 000000000..be2056cb7 --- /dev/null +++ b/src/gameobjects/mesh/typedefs/index.js @@ -0,0 +1,9 @@ +/** + * @author Richard Davey + * @copyright 2020 Photon Storm Ltd. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Types.GameObjects.Mesh + */