You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/core/Runner.js
+31-30Lines changed: 31 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ var Common = require('./Common');
68
68
* This runner favours a smoother user experience over perfect time keeping.
69
69
* The number of updates per frame is kept within limits specified by `runner.maxFrameTime`, `runner.maxUpdates` and `runner.maxFrameDelta`.
70
70
* When device performance is too limited the simulation may appear to slow down compared to real time.
71
-
* As an alternative, to directly step the engine in your own game loop implementation, see `Engine.update`.
71
+
* As an alternative see `Engine.update` to directly step the engine in your own game loop implementation.
72
72
* @method run
73
73
* @param {runner} runner
74
74
* @param {engine} [engine]
@@ -92,7 +92,7 @@ var Common = require('./Common');
92
92
/**
93
93
* Used by the game loop inside `Runner.run`.
94
94
*
95
-
* As an alternative to directly step the engine in your own game loop implementation, see `Engine.update`.
95
+
* As an alternative see `Engine.update` to directly step the engine in your own game loop implementation.
96
96
* @method tick
97
97
* @param {runner} runner
98
98
* @param {engine} engine
@@ -218,7 +218,7 @@ var Common = require('./Common');
218
218
/**
219
219
* Ends execution of `Runner.run` on the given `runner`, by canceling the frame loop.
220
220
*
221
-
* To temporarily pause the runner, see `runner.enabled`.
221
+
* Alternatively to temporarily pause the runner, see `runner.enabled`.
222
222
* @method stop
223
223
* @param {runner} runner
224
224
*/
@@ -227,7 +227,7 @@ var Common = require('./Common');
227
227
};
228
228
229
229
/**
230
-
* Schedules a `callback` on this `runner` for the next animation frame.
230
+
* Schedules `callback` on this `runner` for the next animation frame.
231
231
* @private
232
232
* @method _onNextFrame
233
233
* @param {runner} runner
@@ -343,37 +343,37 @@ var Common = require('./Common');
343
343
/**
344
344
* The fixed timestep size used for `Engine.update` calls in milliseconds.
345
345
*
346
-
* This `delta` value is recommended to be `16.666` ms or lower (equivalent to at least 60hz).
346
+
* This `delta` value is recommended to be `1000 / 60` ms or smaller (i.e. equivalent to at least 60hz).
347
347
*
348
-
* Lower `delta` values provide a higher quality results at the cost of performance.
348
+
* Smaller `delta` values provide higher quality results at the cost of performance.
349
349
*
350
-
* This value should be held fixed during running, otherwise quality may be affected.
350
+
* You should avoid changing `delta` during running, otherwise quality may be affected.
351
351
*
352
-
* For smoothest results choose an evenly divisible factor of your target framerates, this helps provide an equal number of updates per frame.
352
+
* For smoothest results choose a `delta` using an integer multiple of display FPS, i.e. `1000 / (n * fps)` as this helps distribute an equal number of updates over each display frame.
353
353
*
354
-
* Rounding to the nearest 1 Hz is recommended for smoother results (see `runner.frameDeltaSnapping`).
354
+
* For example with a 60 Hz `delta` i.e. `1000 / 60` the runner will on average perform one update per frame on displays running 60 FPS, or one update every two frames on displays running 120 FPS, etc.
355
355
*
356
-
* For example with a `delta` of `1000 / 60` the runner will on average perform one update per frame for displays at 60 FPS, or one update every two frames for displays at 120 FPS.
356
+
* Where as e.g. using a 240 Hz `delta` i.e. `1000 / 240` the runner will on average perform four updates per frame on displays running 60 FPS, or two updates per frame on displays running 120 FPS, etc.
357
357
*
358
-
* `Runner.run` will call multiple engine updates to simulate the time elapsed between frames, but the number of allowed calls may be limited by the runner's performance budgets.
358
+
* Therefore note that `Runner.run` can call multiple engine updates to simulate the time elapsed between frames, but the number of actual updates in any particular frame may be restricted by the runner's performance budgets.
359
+
*
360
+
* These performance budgets are specified by `runner.maxFrameTime` and `runner.maxUpdates`. See those properties for details.
359
361
*
360
-
* These performance budgets are specified by `runner.maxFrameTime`, `runner.maxUpdates`, `runner.maxFrameDelta`. See those properties for details.
361
-
*
362
362
* @property delta
363
363
* @type number
364
364
* @default 1000 / 60
365
365
*/
366
366
367
367
/**
368
-
* A flag that can be toggled to enable or disable tick calls on this runner, therefore pausing engine updates while the loop remains running.
368
+
* A flag that can be toggled to enable or disable tick calls on this runner, therefore pausing engine updates while the runner loop remains running.
369
369
*
370
370
* @property enabled
371
371
* @type boolean
372
372
* @default true
373
373
*/
374
374
375
375
/**
376
-
* The accumulated time elapsed that has yet to be simulated, in milliseconds.
376
+
* The accumulated time elapsed that has yet to be simulated in milliseconds.
377
377
* This value is clamped within some limits (see `Runner.tick` code).
378
378
*
379
379
* @private
@@ -383,51 +383,53 @@ var Common = require('./Common');
383
383
*/
384
384
385
385
/**
386
-
* The measured time elapsed between the last two browser frames in milliseconds.
386
+
* The measured time elapsed between the last two browser frames measured in milliseconds.
387
387
* This value is clamped inside `runner.maxFrameDelta`.
388
388
*
389
-
* You may use this to estimate the browser FPS (for the current instant) whilst running use `1000 / runner.frameDelta`.
389
+
* You may use this to estimate the browser FPS (for the current frame) whilst running as `1000 / runner.frameDelta`.
390
390
*
391
391
* @readonly
392
392
* @property frameDelta
393
393
* @type number
394
394
*/
395
395
396
396
/**
397
-
* This option applies averaging to the frame delta to smooth noisy frame rates.
397
+
* Applies averaging to smooth frame rate measurements and therefore stabilise play rate.
398
398
*
399
399
* @property frameDeltaSmoothing
400
400
* @type boolean
401
401
* @default true
402
402
*/
403
403
404
404
/**
405
-
* Rounds frame delta to the nearest 1 Hz.
406
-
* It follows that your choice of `runner.delta` should be rounded to the nearest 1 Hz for best results.
407
-
* This option helps smooth noisy refresh rates and simplify hardware differences e.g. 59.94Hz vs 60Hz display refresh rates.
405
+
* Rounds measured frame delta to the nearest 1 Hz.
406
+
* Your choice of `runner.delta` should be rounded to the nearest 1 Hz for best results.
407
+
* This option helps smooth frame rate measurements and unify display hardware differences e.g. 59.94Hz vs 60Hz refresh rates.
408
408
*
409
409
* @property frameDeltaSnapping
410
410
* @type boolean
411
411
* @default true
412
412
*/
413
413
414
414
/**
415
-
* Clamps the maximum `runner.frameDelta` in milliseconds.
416
-
* This is to avoid simulating periods where the browser thread is paused e.g. whilst minimised.
415
+
* Clamps the maximum measured `runner.frameDelta` in milliseconds.
416
+
* Therefore avoids simulating long periods measured between frames e.g. periods the thread is frozen whilst the browser has been minimised.
417
417
*
418
418
* @property maxFrameDelta
419
419
* @type number
420
420
* @default 500
421
421
*/
422
422
423
423
/**
424
-
* The runner will attempt to limit engine update rate should the browser frame rate drop below a set level (50 FPS using the default `runner.maxFrameTime` value `1000 / 50` milliseconds).
424
+
* A performance budget that limits execution time allowed for this runner per display frame in milliseconds.
425
+
*
426
+
* To calculate the display FPS at which this throttle is applied use `1000 / maxFrameTime`.
425
427
*
426
-
* This budget is intended to help maintain browser interactivity and help improve framerate recovery during temporary high CPU spikes.
428
+
* This performance budget is intended to help maintain browser interactivity and help improve framerate recovery during temporary high CPU usage.
427
429
*
428
-
* It will only cover time elapsed whilst executing the functions called in the scope of this runner, including `Engine.update` etc. and its related event callbacks.
430
+
* This only covers the measured time elapsed executing the functions called in the scope of the runner tick, including `Engine.update` etc. and its related user event callbacks.
429
431
*
430
-
* For any significant additional processing you perform on the same thread but outside the scope of this runner e.g. rendering time, you may wish to reduce this budget.
432
+
* You may wish to reduce this budget to allow for any significant additional processing you perform on the same thread outside the scope of this runner, e.g. rendering time.
431
433
*
432
434
* See also `runner.maxUpdates`.
433
435
*
@@ -437,10 +439,9 @@ var Common = require('./Common');
437
439
*/
438
440
439
441
/**
440
-
* A hard limit for maximum engine updates allowed per frame.
442
+
* An optional hard limit for maximum engine updates allowed per frame tick in addition to `runner.maxFrameTime`.
441
443
*
442
-
* If not provided, it is automatically set by `Runner.create` based on `runner.delta` and `runner.maxFrameTime`.
443
-
* If you change `runner.delta` or `runner.maxFrameTime`, you may need to manually update this value afterwards.
444
+
* Unless you set a value it is automatically chosen based on `runner.delta` and `runner.maxFrameTime`.
0 commit comments