Merge pull request #63 from WebOnWebOff/master
Allow configuration of minimum energy threshold
This commit is contained in:
commit
1d51239af1
|
@ -325,11 +325,12 @@
|
||||||
|
|
||||||
// -----------
|
// -----------
|
||||||
var Layout = Springy.Layout = {};
|
var Layout = Springy.Layout = {};
|
||||||
Layout.ForceDirected = function(graph, stiffness, repulsion, damping) {
|
Layout.ForceDirected = function(graph, stiffness, repulsion, damping, minEnergyThreshold) {
|
||||||
this.graph = graph;
|
this.graph = graph;
|
||||||
this.stiffness = stiffness; // spring stiffness constant
|
this.stiffness = stiffness; // spring stiffness constant
|
||||||
this.repulsion = repulsion; // repulsion constant
|
this.repulsion = repulsion; // repulsion constant
|
||||||
this.damping = damping; // velocity damping factor
|
this.damping = damping; // velocity damping factor
|
||||||
|
this.minEnergyThreshold = minEnergyThreshold || 0.01; //threshold used to determine render stop
|
||||||
|
|
||||||
this.nodePoints = {}; // keep track of points associated with nodes
|
this.nodePoints = {}; // keep track of points associated with nodes
|
||||||
this.edgeSprings = {}; // keep track of springs associated with edges
|
this.edgeSprings = {}; // keep track of springs associated with edges
|
||||||
|
@ -508,7 +509,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop simulation when energy of the system goes below a threshold
|
// stop simulation when energy of the system goes below a threshold
|
||||||
if (t._stop || t.totalEnergy() < 0.01) {
|
if (t._stop || t.totalEnergy() < t.minEnergyThreshold) {
|
||||||
t._started = false;
|
t._started = false;
|
||||||
if (onRenderStop !== undefined) { onRenderStop(); }
|
if (onRenderStop !== undefined) { onRenderStop(); }
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user