Skip to content

Commit 7fc1e8c

Browse files
authored
Refactor MiniStats options types (#7500)
* Refactor MiniStats options types * Limit width * Rename
1 parent 6fe52a3 commit 7fc1e8c

File tree

2 files changed

+39
-26
lines changed

2 files changed

+39
-26
lines changed

src/extras/mini-stats/mini-stats.js

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,43 @@ import { Render2d } from './render2d.js';
1414
* @import { GraphicsDevice } from '../../platform/graphics/graphics-device.js'
1515
*/
1616

17+
/**
18+
* @typedef {object} MiniStatsSizeOptions
19+
* @property {number} width - Width of the graph area.
20+
* @property {number} height - Height of the graph area.
21+
* @property {number} spacing - Spacing between graphs.
22+
* @property {boolean} graphs - Whether to show graphs.
23+
*/
24+
25+
/**
26+
* @typedef {object} MiniStatsProcessorOptions
27+
* @property {boolean} enabled - Whether to show the graph.
28+
* @property {number} watermark - Watermark - shown as a line on the graph, useful for displaying a
29+
* budget.
30+
*/
31+
32+
/**
33+
* @typedef {object} MiniStatsGraphOptions
34+
* @property {string} name - Display name.
35+
* @property {string[]} stats - Path to data inside Application.stats.
36+
* @property {number} [decimalPlaces] - Number of decimal places (defaults to none).
37+
* @property {string} [unitsName] - Units (defaults to "").
38+
* @property {number} [watermark] - Watermark - shown as a line on the graph, useful for displaying
39+
* a budget.
40+
*/
41+
42+
/**
43+
* @typedef {object} MiniStatsOptions
44+
* @property {MiniStatsSizeOptions[]} sizes - Sizes of area to render individual graphs in and
45+
* spacing between individual graphs.
46+
* @property {number} startSizeIndex - Index into sizes array for initial setting.
47+
* @property {number} textRefreshRate - Refresh rate of text stats in ms.
48+
* @property {MiniStatsProcessorOptions} cpu - CPU graph options.
49+
* @property {MiniStatsProcessorOptions} gpu - GPU graph options.
50+
* @property {MiniStatsGraphOptions[]} stats - Array of options to render additional graphs based
51+
* on stats collected into Application.stats.
52+
*/
53+
1754
/**
1855
* MiniStats is a small graphical overlay that displays realtime performance metrics. By default,
1956
* it shows CPU and GPU utilization, frame timings and draw call count. It can also be configured
@@ -24,31 +61,7 @@ class MiniStats {
2461
* Create a new MiniStats instance.
2562
*
2663
* @param {AppBase} app - The application.
27-
* @param {object} [options] - Options for the MiniStats instance.
28-
* @param {object[]} [options.sizes] - Sizes of area to render individual graphs in and spacing
29-
* between individual graphs.
30-
* @param {number} [options.sizes[].width] - Width of the graph area.
31-
* @param {number} [options.sizes[].height] - Height of the graph area.
32-
* @param {number} [options.sizes[].spacing] - Spacing between graphs.
33-
* @param {boolean} [options.sizes[].graphs] - Whether to show graphs.
34-
* @param {number} [options.startSizeIndex] - Index into sizes array for initial setting.
35-
* @param {number} [options.textRefreshRate] - Refresh rate of text stats in ms.
36-
* @param {object} [options.cpu] - CPU graph options.
37-
* @param {boolean} [options.cpu.enabled] - Whether to show the CPU graph.
38-
* @param {number} [options.cpu.watermark] - Watermark - shown as a line on the graph, useful for
39-
* displaying a budget.
40-
* @param {object} [options.gpu] - GPU graph options.
41-
* @param {boolean} [options.gpu.enabled] - Whether to show the GPU graph.
42-
* @param {number} [options.gpu.watermark] - Watermark - shown as a line on the graph, useful for
43-
* displaying a budget.
44-
* @param {object[]} [options.stats] - Array of options to render additional graphs based on
45-
* stats collected into {@link AppBase#stats}.
46-
* @param {string} [options.stats[].name] - Display name.
47-
* @param {string[]} options.stats[].stats - Path to data inside {@link AppBase#stats}.
48-
* @param {number} [options.stats[].decimalPlaces] - Number of decimal places (defaults to none).
49-
* @param {string} [options.stats[].unitsName] - Units (defaults to "").
50-
* @param {number} [options.stats[].watermark] - Watermark - shown as a line on the graph, useful
51-
* for displaying a budget.
64+
* @param {MiniStatsOptions} [options] - Options for the MiniStats instance.
5265
* @example
5366
* // create a new MiniStats instance using default options
5467
* const miniStats = new pc.MiniStats(app);

src/framework/application.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ import { XrManager } from './xr/xr-manager.js';
6868
* Application is a subclass of {@link AppBase}, which represents the base functionality for all
6969
* PlayCanvas applications. It acts as a convenience class by internally registering all
7070
* {@link ComponentSystem}s and {@link ResourceHandler}s implemented in the PlayCanvas Engine. This
71-
* makes app setup simple but results in the full engine being included when bundling for your
71+
* makes app setup simple but results in the full engine being included when bundling your
7272
* application.
7373
*/
7474
class Application extends AppBase {

0 commit comments

Comments
 (0)