提交 d31b247a 编写于 作者: S sushuang

Fix the last commit.

上级 86150da8
......@@ -190,7 +190,7 @@ define(function (require) {
force: {
initLayout: null,
// Node repulsion. Can be an array to represent range.
repulsion: [1, 50],
repulsion: [0, 50],
gravity: 0.1,
// Edge length. Can be an array to represent range.
......
......@@ -83,6 +83,11 @@ define(function (require) {
vec2.sub(v12, n2.p, n1.p);
var d = vec2.len(v12) - e.d;
var w = n2.w / (n1.w + n2.w);
if (isNaN(w)) {
w = 0;
}
vec2.normalize(v12, v12);
!n1.fixed && scaleAndAdd(n1.p, n1.p, v12, w * d * friction);
......
......@@ -50,13 +50,8 @@ define(function (require) {
var nodes = nodeData.mapArray('value', function (value, idx) {
var point = nodeData.getItemLayout(idx);
var rep = numberUtil.linearMap(value, nodeDataExtent, repulsion);
var halfRep = (repulsion[0] + repulsion[1]) / 2;
if (isNaN(rep)) {
rep = halfRep;
}
// rep can not be 0.
if (rep <= 0) {
rep = Math.max(1e-4, Math.min(1, halfRep));
rep = (repulsion[0] + repulsion[1]) / 2;
}
return {
w: rep,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册