Skip to content

Commit

Permalink
fixed NaN case
Browse files Browse the repository at this point in the history
  • Loading branch information
lucastakejame committed Feb 5, 2018
1 parent 3b6f4bc commit 970629f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ window.onload = function(){
var dx = params.mousex-p.x,
dy = params.mousey-p.y,
length = Math.sqrt(dx*dx + dy*dy);
dx /= length;
dy /= length;

// force of fixed intensity on mouse-position direction
p.applyForce(0.25*dx, 0.25*dy);
if(length > 10)
{
dx = dx/length || 0 ;
dy = dy/length || 0 ;

// force of fixed intensity on mouse-position direction
p.applyForce(0.25*dx, 0.25*dy);
}
}

if(params.rotateVelocity)
Expand Down

0 comments on commit 970629f

Please sign in to comment.