Skip to content

Engine configuration

xam4lor edited this page Jun 10, 2020 · 12 revisions

This page describes how setEngineConfig and addObjects should be used, and what are all of their parameters. To understand were to use them, please read the corresponding wiki page.


The setEngineConfig function

Inside the runSimulator(simulator) function (more infos in the pSEngine basics wiki page, you can use the simulator.setEngineConfig function to change the engine configuration based on what your simulation requires.

To explain how to do that, lets admit that there is a parameter called plotter.scale.x and that to set his value to 4. To do that, you will need to use the following function:

function runSimulator(simulator) {
   simulator.setEngineConfig((engineConf) => {
      engineConf.plotter.scale.x = 4;
   });
}

Here below, you can usefull configuration parameters of the engine, sorted in function of their use. For more in-depth engine configuration, you will find every parameters in the Simulator.js file, in getDefaultEngineConfig() function.

The default parameter of the configuration is written in front of the : character. For example, if you don't change the runner.simulationSpeed parameter, it will be at value 1.

  • runner
    • divId : 'simulationContent'
    • **UPDATE_FPS **: 120
    • DRAW_FPS : 60
    • simulationSpeed : 1
  • window
    • proportions
      • isRelative : true
      • width : 0.99
      • height : 0.99
  • plotter
    • scale
      • x : 10 (simulation size is 20 meters width long (10 right + 10 left from origin)
      • y : 10 (simulation size is 20 meters height long (10 top + 10 bottom from origin)
      • squareByX : true (true : keep proportions based on X value)
    • offset
      • x : 0 (X offset from the origin in meters)
      • y : 0 (Y offset from the origin in meters)
    • backgroundColor
      • draw : true (draws background each time draw() function is triggered)
      • color : { r : 0, g : 0, b : 0 } (color of the background)

Previous (Using animations) - Back to wiki home

Clone this wiki locally