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.
 
 
 

33 lines
875 B

/**
* Created by Alex on 2/23/2015.
*/
var BarnesHut = require("./compontents/BarnesHutSolver")
var SpringSolver = require("./compontents/SpringSolver")
var CentralGravitySolver = require("./compontents/CentralGravitySolver")
function PhysicsEngine(body, options) {
this.body = body;
this.nodesSolver = new BarnesHut(body, options);
this.edgesSolver = new SpringSolver(body, options);
this.gravitySolver = new CentralGravitySolver(body, options);
}
PhysicsEngine.prototype.calculateField = function () {
this.nodesSolver.solve();
};
PhysicsEngine.prototype.calculateSprings = function () {
this.edgesSolver.solve();
};
PhysicsEngine.prototype.calculateCentralGravity = function () {
this.gravitySolver.solve();
};
PhysicsEngine.prototype.calculate = function () {
this.calculateCentralGravity();
this.calculateField();
this.calculateSprings();
};