diff --git a/lib/network/modules/PhysicsEngine.js b/lib/network/modules/PhysicsEngine.js index b8f0a6ee..cc3fa775 100644 --- a/lib/network/modules/PhysicsEngine.js +++ b/lib/network/modules/PhysicsEngine.js @@ -524,18 +524,6 @@ class PhysicsEngine { edgeType: {}, toId: edge.toId, fromId: edge.fromId, - // TODO when will toId not match to.id given that connected is true - // can we rewrite SpringSolver to only use toId and not to.id - // and remove these parameters - to: { - // if assumption above is not valid TODO update to.id and from.id when updating connected - // id: edge.to.id - id: edge.toId - }, - from: { - // id: edge.from.id - id: edge.fromId - }, options: { length: edge.length } diff --git a/lib/network/modules/components/physics/SpringSolver.js b/lib/network/modules/components/physics/SpringSolver.js index ac10617d..b16069bb 100644 --- a/lib/network/modules/components/physics/SpringSolver.js +++ b/lib/network/modules/components/physics/SpringSolver.js @@ -29,9 +29,9 @@ class SpringSolver { if (this.body.nodes[edge.toId] !== undefined && this.body.nodes[edge.fromId] !== undefined) { if (edge.edgeType.via !== undefined) { edgeLength = edge.options.length === undefined ? this.options.springLength : edge.options.length; - node1 = nodes[edge.to.id]; + node1 = nodes[edge.toId]; node2 = nodes[edge.edgeType.via.id]; - node3 = nodes[edge.from.id]; + node3 = nodes[edge.fromId]; this._calculateSpringForce(node1, node2, 0.5 * edgeLength); this._calculateSpringForce(node2, node3, 0.5 * edgeLength); @@ -40,7 +40,7 @@ class SpringSolver { // the * 1.5 is here so the edge looks as large as a smooth edge. It does not initially because the smooth edges use // the support nodes which exert a repulsive force on the to and from nodes, making the edge appear larger. edgeLength = edge.options.length === undefined ? this.options.springLength * 1.5: edge.options.length; - this._calculateSpringForce(nodes[edge.from.id], nodes[edge.to.id], edgeLength); + this._calculateSpringForce(nodes[edge.fromId], nodes[edge.toId], edgeLength); } } }