Allow configuration of minimum energy threshold
This commit is contained in:
parent
28ca9cc5be
commit
50eed3e039
|
@ -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