better centering by limiting evolution and attracter influence zone
This commit is contained in:
@@ -330,7 +330,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(this.center)
|
if(this.center)
|
||||||
this.slowDownNearCenter();
|
this.limitEvolutionZone();
|
||||||
|
|
||||||
if(!this.p.resting()){
|
if(!this.p.resting()){
|
||||||
// this.checkVelocityThreshold();
|
// this.checkVelocityThreshold();
|
||||||
@@ -432,7 +432,7 @@
|
|||||||
this.attract.on = false;
|
this.attract.on = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node.prototype.slowDownNearCenter = function(){
|
Node.prototype.limitEvolutionZone = function(){
|
||||||
// smouthly slow down node near center
|
// smouthly slow down node near center
|
||||||
// if(this.id == 1)
|
// if(this.id == 1)
|
||||||
// console.log('this.p.velocity', this.p.velocity);
|
// console.log('this.p.velocity', this.p.velocity);
|
||||||
@@ -441,13 +441,12 @@
|
|||||||
if( this.p.velocity.length() > 0.4 ){
|
if( this.p.velocity.length() > 0.4 ){
|
||||||
this.p.velocity.multiplyScalar(0.995);
|
this.p.velocity.multiplyScalar(0.995);
|
||||||
}
|
}
|
||||||
// if(Math.abs(this.p.velocity.x) > 1){
|
}
|
||||||
// this.p.velocity.x *= 0.99;
|
if( Math.abs(_attracter.position.x - this.x) > _canvas.width/3
|
||||||
// }
|
|| Math.abs(_attracter.position.y - this.y) > _canvas.height/3){
|
||||||
// if(Math.abs(this.p.velocity.y) > 1){
|
this.attract.on = true;
|
||||||
// this.p.velocity.y *= 0.99;
|
}else{
|
||||||
// }
|
this.attract.on = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -330,7 +330,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(this.center)
|
if(this.center)
|
||||||
this.slowDownNearCenter();
|
this.limitEvolutionZone();
|
||||||
|
|
||||||
if(!this.p.resting()){
|
if(!this.p.resting()){
|
||||||
// this.checkVelocityThreshold();
|
// this.checkVelocityThreshold();
|
||||||
@@ -432,7 +432,7 @@
|
|||||||
this.attract.on = false;
|
this.attract.on = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node.prototype.slowDownNearCenter = function(){
|
Node.prototype.limitEvolutionZone = function(){
|
||||||
// smouthly slow down node near center
|
// smouthly slow down node near center
|
||||||
// if(this.id == 1)
|
// if(this.id == 1)
|
||||||
// console.log('this.p.velocity', this.p.velocity);
|
// console.log('this.p.velocity', this.p.velocity);
|
||||||
@@ -441,13 +441,12 @@
|
|||||||
if( this.p.velocity.length() > 0.4 ){
|
if( this.p.velocity.length() > 0.4 ){
|
||||||
this.p.velocity.multiplyScalar(0.995);
|
this.p.velocity.multiplyScalar(0.995);
|
||||||
}
|
}
|
||||||
// if(Math.abs(this.p.velocity.x) > 1){
|
}
|
||||||
// this.p.velocity.x *= 0.99;
|
if( Math.abs(_attracter.position.x - this.x) > _canvas.width/3
|
||||||
// }
|
|| Math.abs(_attracter.position.y - this.y) > _canvas.height/3){
|
||||||
// if(Math.abs(this.p.velocity.y) > 1){
|
this.attract.on = true;
|
||||||
// this.p.velocity.y *= 0.99;
|
}else{
|
||||||
// }
|
this.attract.on = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user