From 6cc38d330082767ead9078719a46e732ef2010b2 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Wed, 21 Mar 2018 15:07:04 +0100 Subject: [PATCH] better centering by limiting evolution and attracter influence zone --- .../assets/dist/scripts/corpus.min.js | 17 ++++++++--------- .../figli/edlp_corpus/assets/scripts/corpus.js | 17 ++++++++--------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/sites/all/modules/figli/edlp_corpus/assets/dist/scripts/corpus.min.js b/sites/all/modules/figli/edlp_corpus/assets/dist/scripts/corpus.min.js index d7f9a6bee..99b8efebd 100644 --- a/sites/all/modules/figli/edlp_corpus/assets/dist/scripts/corpus.min.js +++ b/sites/all/modules/figli/edlp_corpus/assets/dist/scripts/corpus.min.js @@ -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; } } diff --git a/sites/all/modules/figli/edlp_corpus/assets/scripts/corpus.js b/sites/all/modules/figli/edlp_corpus/assets/scripts/corpus.js index d7f9a6bee..99b8efebd 100644 --- a/sites/all/modules/figli/edlp_corpus/assets/scripts/corpus.js +++ b/sites/all/modules/figli/edlp_corpus/assets/scripts/corpus.js @@ -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; } }