vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
805 B

  1. /**
  2. * Created by Alex on 2/23/2015.
  3. */
  4. import {BarnesHut} from "./components/physics/BarnesHutSolver";
  5. import {SpringSolver} from "./components/physics/SpringSolver";
  6. import {CentralGravitySolver} from "./components/physics/CentralGravitySolver";
  7. class PhysicsEngine {
  8. constructor(body, options) {
  9. this.body = body;
  10. this.nodesSolver = new BarnesHut(body, options);
  11. this.edgesSolver = new SpringSolver(body, options);
  12. this.gravitySolver = new CentralGravitySolver(body, options);
  13. }
  14. calculateField() {
  15. this.nodesSolver.solve();
  16. };
  17. calculateSprings() {
  18. this.edgesSolver.solve();
  19. };
  20. calculateCentralGravity() {
  21. this.gravitySolver.solve();
  22. };
  23. calculate() {
  24. this.calculateCentralGravity();
  25. this.calculateField();
  26. this.calculateSprings();
  27. };
  28. }