Bladeren bron

better centering by limiting evolution and attracter influence zone

Bachir Soussi Chiadmi 7 jaren geleden
bovenliggende
commit
6cc38d3300

+ 8 - 9
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;
           }
         }
 

+ 8 - 9
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;
           }
         }