myPhysicsLab provides JavaScript classes to build real-time interactive animated physics simulations
JavaScript Mathematica HTML Makefile Perl TeX Other
Latest commit 01aa290 Jan 13, 2017 @myphysicslab SimRunner stops Timer when window inactive
SimRunner listens for blur and focus events to stop and start the Timer.
This means the simulation will only run when the browser window is
the frontmost active window.  This helps reduce CPU usage when
the user is not viewing the simulation.

There is a "non-stop" Parameter which allows the simulation to run
even when the window is not active. This is useful if you want to view
two simulations running in separate browser windows.

Timer: new method startFiring() which must be used to start the Timer.
Timer keeps track of when it is firing (executing callbacks).
Removed method fire().

Increase version number to 2.0.0 because the Timer API now requires
calling startFiring(), and the fire() method was removed.

myPhysicsLab README

myPhysicsLab provides JavaScript classes to build real-time interactive animated physics simulations.

The myPhysicsLab website shows the simulations running and contains explanations of the math behind them.

Author and License

myPhysicsLab is provided as open source software under the Apache 2.0 License. See the accompanying file named LICENSE. The author is Erik Neumann

Source code is available at


It is possible to customize a myPhysicsLab simulation without building from source code, see Customizing myPhysicsLab Simulations.

To build from source code the required tools are

Once the prerequisites are on your system, follow these steps:

  1. Download the myPhysicsLab source code from

  2. Copy the file to and edit to specify location of Closure Compiler in the CLOSURE_COMPILER variable.

  3. Create a symbolic link to closure-library in the directory that has the makefile. Example of how to create the symbolic link:

    $ ln -s ../closure-library/ closure-library
  4. Execute make at the command line. (Set your directory to where the makefile is). This will compile all applications and tests in all language versions (using the default option COMPILE_LEVEL=simple). Execute make help to see available options.

  5. Open the file /build/index_en.html with a browser. This has links to all the files that were built.

NOTE: the HTML files in the source directories cannot be used directly from a browser. You must complete the build process first.

See Building myPhysicsLab Software for more information about the build process.


See myPhysicsLab Documentation for overview of architecture and for detailed documentation of software.


There are around 50 different simulations in the source code, each of which has has an example file which is mainly for development and testing.

The example files are available online in two forms: advanced-compiled which loads faster and simple-compiled which allows for more customization.