xtras/web-workers/collision-worker.js
/* Moves each ball; when finished sends an message to the main script with a
 * copy of this balls array containing the updated positions. 
 * The collision detection loop is running at 30 fps while the render loop is
 * running at 60 fps, so it's up to the main script to coordinate.
 */
Moves each ball; when finished sends an message to the main script with a
copy of this balls array containing the updated positions.
The collision detection loop is running at 30 fps while the render loop is
running at 60 fps, so it's up to the main script to coordinate.
Moves each ball ; when finished sends an message to the main script with a copy of this balls array containing the updated positions . The collision detection loop is running at 30 fps while the render loop is running at 60 fps so it ' s up to the main script to coordinate .
function processFrame () {
  balls.forEach(move);
  for (var ballA, i = 0, len = numBalls - 1; i < len; i++) {
    ballA = balls[i];
    for (var ballB, j = i + 1; j < numBalls; j++) {
      ballB = balls[j];
      checkCollision(ballA, ballB);
    }
  }
  self.postMessage(balls);
}
function processFrame ( ) { balls . forEach ( move ) ; for ( var ballA , i = 0 , len = numBalls - 1 ; i < len ; i ++ ) { ballA = balls [ i ] ; for ( var ballB , j = i + 1 ; j < numBalls ; j ++ ) { ballB = balls [ j ] ; checkCollision ( ballA , ballB ) ; } } self . postMessage ( balls ) ; }
Moves each ball; when finished sends an message to the main script with a
 copy of this balls array containing the updated positions.
Moves each ball ; when finished sends an message to the main script with a copy of this balls array containing the updated positions .
//these iterations were in the drawFrame function //calculations done, send updated values back to the main script