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(); }
|
if (onRenderStart !== undefined) { onRenderStart(); }
|
||||||
|
|
||||||
Springy.requestAnimationFrame(function step() {
|
Springy.requestAnimationFrame(function step() {
|
||||||
t.applyCoulombsLaw();
|
t.tick(0.03);
|
||||||
t.applyHookesLaw();
|
|
||||||
t.attractToCentre();
|
|
||||||
t.updateVelocity(0.03);
|
|
||||||
t.updatePosition(0.03);
|
|
||||||
|
|
||||||
if (render !== undefined) {
|
if (render !== undefined) {
|
||||||
render();
|
render();
|
||||||
|
@ -522,6 +518,14 @@
|
||||||
this._stop = true;
|
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
|
// Find the nearest point to a particular position
|
||||||
Layout.ForceDirected.prototype.nearest = function(pos) {
|
Layout.ForceDirected.prototype.nearest = function(pos) {
|
||||||
var min = {node: null, point: null, distance: null};
|
var min = {node: null, point: null, distance: null};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user