diff --git a/src/framework/app-base.js b/src/framework/app-base.js index 200346c956a..fc01e0b5282 100644 --- a/src/framework/app-base.js +++ b/src/framework/app-base.js @@ -129,6 +129,27 @@ class AppBase extends EventHandler { * @returns {void} */ + /** @private */ + _destroyRequested = false; + + /** @private */ + _inFrameUpdate = false; + + /** @private */ + _time = 0; + + /** @private */ + _librariesLoaded = false; + + /** @private */ + _fillMode = FILLMODE_KEEP_ASPECT; + + /** @private */ + _resolutionMode = RESOLUTION_FIXED; + + /** @private */ + _allowResize = true; + /** * A request id returned by requestAnimationFrame, allowing us to cancel it. * @@ -136,6 +157,65 @@ class AppBase extends EventHandler { */ frameRequestId; + /** + * Scales the global time delta. Defaults to 1. + * + * @type {number} + * @example + * // Set the app to run at half speed + * this.app.timeScale = 0.5; + */ + timeScale = 1; + + /** + * Clamps per-frame delta time to an upper bound. Useful since returning from a tab + * deactivation can generate huge values for dt, which can adversely affect game state. + * Defaults to 0.1 (seconds). + * + * @type {number} + * @example + * // Don't clamp inter-frame times of 200ms or less + * this.app.maxDeltaTime = 0.2; + */ + maxDeltaTime = 0.1; // Maximum delta is 0.1s or 10 fps. + + /** + * The total number of frames the application has updated since start() was called. + * + * @type {number} + * @ignore + */ + frame = 0; + + /** + * When true, the application's render function is called every frame. Setting autoRender to + * false is useful to applications where the rendered image may often be unchanged over time. + * This can heavily reduce the application's load on the CPU and GPU. Defaults to true. + * + * @type {boolean} + * @example + * // Disable rendering every frame and only render on a keydown event + * this.app.autoRender = false; + * this.app.keyboard.on('keydown', (event) => { + * this.app.renderNextFrame = true; + * }); + */ + autoRender = true; + + /** + * Set to true to render the scene on the next iteration of the main loop. This only has an + * effect if {@link AppBase#autoRender} is set to false. The value of renderNextFrame is set + * back to false again as soon as the scene has been rendered. + * + * @type {boolean} + * @example + * // Render the scene only while space key is pressed + * if (this.app.keyboard.isPressed(pc.KEY_SPACE)) { + * this.app.renderNextFrame = true; + * } + */ + renderNextFrame = false; + /** * Create a new AppBase instance. * @@ -163,87 +243,12 @@ class AppBase extends EventHandler { setApplication(this); app = this; - - /** @private */ - this._destroyRequested = false; - - /** @private */ - this._inFrameUpdate = false; - - /** @private */ - this._time = 0; - - /** - * Scales the global time delta. Defaults to 1. - * - * @type {number} - * @example - * // Set the app to run at half speed - * this.app.timeScale = 0.5; - */ - this.timeScale = 1; - - /** - * Clamps per-frame delta time to an upper bound. Useful since returning from a tab - * deactivation can generate huge values for dt, which can adversely affect game state. - * Defaults to 0.1 (seconds). - * - * @type {number} - * @example - * // Don't clamp inter-frame times of 200ms or less - * this.app.maxDeltaTime = 0.2; - */ - this.maxDeltaTime = 0.1; // Maximum delta is 0.1s or 10 fps. - - /** - * The total number of frames the application has updated since start() was called. - * - * @type {number} - * @ignore - */ - this.frame = 0; - - /** - * When true, the application's render function is called every frame. Setting autoRender - * to false is useful to applications where the rendered image may often be unchanged over - * time. This can heavily reduce the application's load on the CPU and GPU. Defaults to - * true. - * - * @type {boolean} - * @example - * // Disable rendering every frame and only render on a keydown event - * this.app.autoRender = false; - * this.app.keyboard.on('keydown', function (event) { - * this.app.renderNextFrame = true; - * }, this); - */ - this.autoRender = true; - - /** - * Set to true to render the scene on the next iteration of the main loop. This only has an - * effect if {@link AppBase#autoRender} is set to false. The value of renderNextFrame - * is set back to false again as soon as the scene has been rendered. - * - * @type {boolean} - * @example - * // Render the scene only while space key is pressed - * if (this.app.keyboard.isPressed(pc.KEY_SPACE)) { - * this.app.renderNextFrame = true; - * } - */ - this.renderNextFrame = false; - - this._librariesLoaded = false; - this._fillMode = FILLMODE_KEEP_ASPECT; - this._resolutionMode = RESOLUTION_FIXED; - this._allowResize = true; } /** * Initialize the app. * - * @param {AppOptions} appOptions - Options specifying the init - * parameters for the app. + * @param {AppOptions} appOptions - Options specifying the init parameters for the app. */ init(appOptions) { const device = appOptions.graphicsDevice; diff --git a/src/framework/stats.js b/src/framework/stats.js index f741678dd52..078c20e94fe 100644 --- a/src/framework/stats.js +++ b/src/framework/stats.js @@ -11,8 +11,7 @@ class ApplicationStats { /** * Create a new ApplicationStats instance. * - * @param {GraphicsDevice} device - The - * graphics device. + * @param {GraphicsDevice} device - The graphics device. */ constructor(device) { this.frame = {