Optimize setTension() CPU usage

This commit is contained in:
Ian Gulliver
2019-07-03 20:00:05 +00:00
parent b066001423
commit 27411817b1
5 changed files with 14 additions and 9 deletions

View File

@@ -67,9 +67,14 @@ class Layout {
iterate() {
let objects = Array.from(this.nodes_);
objects.push(...this.groups_);
this.setTension(objects);
this.sortByMostTension(objects);
for (let group of this.groups_) {
// Groups go in the list after nodes, and nodes must have tension set
// properly first.
group.setTension();
objects.push(group);
}
let newOffset = null;
let newTension = this.getTotalTension(objects);