@@ -238,7 +238,8 @@ class p5 {
238
238
constants . P2D
239
239
) ;
240
240
241
- // Record the time when sketch starts
241
+ // Record the time when setup starts. millis() will start at 0 within
242
+ // setup, but this isn't documented, locked-in behavior yet.
242
243
this . _millisStart = window . performance . now ( ) ;
243
244
244
245
const context = this . _isGlobal ? window : this ;
@@ -274,6 +275,10 @@ class p5 {
274
275
275
276
// Run `postsetup` hooks
276
277
await this . _runLifecycleHook ( 'postsetup' ) ;
278
+
279
+ // Record the time when the draw loop starts so that millis() starts at 0
280
+ // when the draw loop begins.
281
+ this . _millisStart = window . performance . now ( ) ;
277
282
}
278
283
279
284
// While '#_draw' here is async, it is not awaited as 'requestAnimationFrame'
@@ -468,11 +473,11 @@ for (const k in constants) {
468
473
* If `setup()` is declared `async` (e.g. `async function setup()`),
469
474
* execution pauses at each `await` until its promise resolves.
470
475
* For example, `font = await loadFont(...)` waits for the font asset
471
- * to load because `loadFont()` function returns a promise, and the await
476
+ * to load because `loadFont()` function returns a promise, and the await
472
477
* keyword means the program will wait for the promise to resolve.
473
478
* This ensures that all assets are fully loaded before the sketch continues.
474
479
475
- *
480
+ *
476
481
* loading assets.
477
482
*
478
483
* Note: `setup()` doesn’t have to be declared, but it’s common practice to do so.
0 commit comments