Added tick
for manually stepping through simulation
This commit is contained in:
parent
f64bda19bc
commit
441ccfcc2b
14
springy.js
14
springy.js
|
@ -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};
|
||||
|
|
Loading…
Reference in New Issue
Block a user