Option to manually tick simulation forward

This commit is contained in:
Dennis Hotson 2013-03-14 23:19:16 +11:00
parent d7a26171b0
commit f13bd76552

View File

@ -462,6 +462,14 @@ Layout.requestAnimationFrame = __bind(window.requestAnimationFrame ||
}, window); }, window);
Layout.ForceDirected.prototype.tick = function(timestep) {
this.applyCoulombsLaw();
this.applyHookesLaw();
this.attractToCentre();
this.updateVelocity(timestep);
this.updatePosition(timestep);
};
// start simulation // start simulation
Layout.ForceDirected.prototype.start = function(render, done) { Layout.ForceDirected.prototype.start = function(render, done) {
var t = this; var t = this;
@ -471,11 +479,8 @@ Layout.ForceDirected.prototype.start = function(render, done) {
this._stop = false; this._stop = false;
Layout.requestAnimationFrame(function step() { Layout.requestAnimationFrame(function step() {
t.applyCoulombsLaw();
t.applyHookesLaw(); t.tick(0.03);
t.attractToCentre();
t.updateVelocity(0.03);
t.updatePosition(0.03);
if (render !== undefined) { if (render !== undefined) {
render(); render();