Added tick for manually stepping through simulation

This commit is contained in:
Dennis Hotson 2014-06-01 18:29:54 +10:00
parent f64bda19bc
commit 441ccfcc2b

View File

@ -498,11 +498,7 @@
if (onRenderStart !== undefined) { onRenderStart(); }
Springy.requestAnimationFrame(function step() {
t.applyCoulombsLaw();
t.applyHookesLaw();
t.attractToCentre();
t.updateVelocity(0.03);
t.updatePosition(0.03);
t.tick(0.03);
if (render !== undefined) {
render();
@ -522,6 +518,14 @@
this._stop = true;
}
Layout.ForceDirected.prototype.tick = function(timestep) {
this.applyCoulombsLaw();
this.applyHookesLaw();
this.attractToCentre();
this.updateVelocity(timestep);
this.updatePosition(timestep);
};
// Find the nearest point to a particular position
Layout.ForceDirected.prototype.nearest = function(pos) {
var min = {node: null, point: null, distance: null};