better centering by limiting evolution and attracter influence zone

This commit is contained in:
Bachir Soussi Chiadmi
2018-03-21 15:07:04 +01:00
parent 123e3ad7c1
commit 6cc38d3300
2 changed files with 16 additions and 18 deletions
@@ -330,7 +330,7 @@
}
if(this.center)
this.slowDownNearCenter();
this.limitEvolutionZone();
if(!this.p.resting()){
// this.checkVelocityThreshold();
@@ -432,7 +432,7 @@
this.attract.on = false;
}
Node.prototype.slowDownNearCenter = function(){
Node.prototype.limitEvolutionZone = function(){
// smouthly slow down node near center
// if(this.id == 1)
// console.log('this.p.velocity', this.p.velocity);
@@ -441,13 +441,12 @@
if( this.p.velocity.length() > 0.4 ){
this.p.velocity.multiplyScalar(0.995);
}
// if(Math.abs(this.p.velocity.x) > 1){
// this.p.velocity.x *= 0.99;
// }
// if(Math.abs(this.p.velocity.y) > 1){
// this.p.velocity.y *= 0.99;
// }
}
if( Math.abs(_attracter.position.x - this.x) > _canvas.width/3
|| Math.abs(_attracter.position.y - this.y) > _canvas.height/3){
this.attract.on = true;
}else{
this.attract.on = false;
}
}
@@ -330,7 +330,7 @@
}
if(this.center)
this.slowDownNearCenter();
this.limitEvolutionZone();
if(!this.p.resting()){
// this.checkVelocityThreshold();
@@ -432,7 +432,7 @@
this.attract.on = false;
}
Node.prototype.slowDownNearCenter = function(){
Node.prototype.limitEvolutionZone = function(){
// smouthly slow down node near center
// if(this.id == 1)
// console.log('this.p.velocity', this.p.velocity);
@@ -441,13 +441,12 @@
if( this.p.velocity.length() > 0.4 ){
this.p.velocity.multiplyScalar(0.995);
}
// if(Math.abs(this.p.velocity.x) > 1){
// this.p.velocity.x *= 0.99;
// }
// if(Math.abs(this.p.velocity.y) > 1){
// this.p.velocity.y *= 0.99;
// }
}
if( Math.abs(_attracter.position.x - this.x) > _canvas.width/3
|| Math.abs(_attracter.position.y - this.y) > _canvas.height/3){
this.attract.on = true;
}else{
this.attract.on = false;
}
}