-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathstepTimer.ts
22 lines (19 loc) · 1000 Bytes
/
stepTimer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Copyright 2020-2024, University of Colorado Boulder
// @author Sam Reid (PhET Interactive Simulations)
import axon from './axon.js';
import Timer from './Timer.js';
/**
* Register and return a singleton timer, which can be used to schedule events. This ticks under the following circumstances:
* 1) When a JOIST/Sim is active, during the step event
* 2) In various accessibility tests that require timing
* 3) In SCENERY/Display's animation loop, which is run by various test and example HTML files
*
* In order to run an event when a simulation is inactive and not stepping, see animationFrameTimer.
*
* Listeners added with addListener are called with a {number} dt argument (in seconds) via timer.emit in
* Sim.stepSimulation. Listeners added with setTimeout/setInterval are called with no arguments. This is not specific
* to the running screen, it is global across all screens.
*/
const stepTimer = new Timer();
axon.register( 'stepTimer', stepTimer );
export default stepTimer;