Browse Source

replace to.id and from.id with toId and fromId

webworkersNetwork^2^2
Eric VanDever 9 years ago
parent
commit
822235747e
2 changed files with 3 additions and 15 deletions
  1. +0
    -12
      lib/network/modules/PhysicsEngine.js
  2. +3
    -3
      lib/network/modules/components/physics/SpringSolver.js

+ 0
- 12
lib/network/modules/PhysicsEngine.js View File

@ -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
}

+ 3
- 3
lib/network/modules/components/physics/SpringSolver.js View File

@ -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);
}
}
}

Loading…
Cancel
Save