fixe map node on hiver or opened kan160

This commit is contained in:
Bachir Soussi Chiadmi
2018-03-20 20:20:12 +01:00
parent 2ba37cd319
commit 55a8452d49
2 changed files with 14 additions and 10 deletions
@@ -321,6 +321,11 @@
Node.prototype.onUpdate = function(){
// this.p.velocity.multiplyScalar(0.99);
if(this.hover || this.opened){
this.p.fixed = true;
}else{
this.p.fixed = false;
}
if(this.center)
this.slowDownNearCenter();
@@ -530,14 +535,11 @@
for (var q = n+1; q < _nodes.length; q++) {
if(q===n) continue;
// avoid impact between center and aside particules
if((_nodes[n].center && _nodes[q].aside) || (_nodes[n].aside && _nodes[q].center))
continue;
// TODO: what if centered nodes are repulsing each other ??
margin = _nodes[n].center ? 1 : 1;
margin = _nodes[n].center ? 0 : 0; // in px
// avoid impact between two centered particulses that comes to the center
if(_nodes[n].center && _nodes[q].center){
@@ -548,7 +550,7 @@
d = _nodes[n].p.distanceTo(_nodes[q].p);
full_rad = _nodes[n].r*margin + _nodes[q].r*margin;
full_rad = _nodes[n].r + _nodes[q].r + margin;
// if not colliding skip following
if(d > full_rad) continue;
@@ -321,6 +321,11 @@
Node.prototype.onUpdate = function(){
// this.p.velocity.multiplyScalar(0.99);
if(this.hover || this.opened){
this.p.fixed = true;
}else{
this.p.fixed = false;
}
if(this.center)
this.slowDownNearCenter();
@@ -530,14 +535,11 @@
for (var q = n+1; q < _nodes.length; q++) {
if(q===n) continue;
// avoid impact between center and aside particules
if((_nodes[n].center && _nodes[q].aside) || (_nodes[n].aside && _nodes[q].center))
continue;
// TODO: what if centered nodes are repulsing each other ??
margin = _nodes[n].center ? 1 : 1;
margin = _nodes[n].center ? 0 : 0; // in px
// avoid impact between two centered particulses that comes to the center
if(_nodes[n].center && _nodes[q].center){
@@ -548,7 +550,7 @@
d = _nodes[n].p.distanceTo(_nodes[q].p);
full_rad = _nodes[n].r*margin + _nodes[q].r*margin;
full_rad = _nodes[n].r + _nodes[q].r + margin;
// if not colliding skip following
if(d > full_rad) continue;